iozone: support on nuttx

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-12-09 17:49:34 +08:00 committed by Xiang Xiao
parent fe5b68142e
commit 5b0b44f24e
5 changed files with 243 additions and 0 deletions

1
testing/iozone/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
iozone/

30
testing/iozone/Kconfig Normal file
View File

@ -0,0 +1,30 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config TESTING_IOZONE
tristate "IOzone, filesystem benchmark tool"
default n
---help---
https://www.iozone.org/
if TESTING_IOZONE
config TESTING_IOZONE_PROGNAME
string "Program name"
default "iozone"
config TESTING_IOZONE_PRIORITY
int "IOzone task priority"
default 100
config TESTING_IOZONE_STACKSIZE
int "IOzone stack size"
default 8192
config TESTING_IOZONE_VERSION
string "iozone version"
default "3_493"
endif

23
testing/iozone/Make.defs Normal file
View File

@ -0,0 +1,23 @@
############################################################################
# apps/testing/iozone/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_TESTING_IOZONE),)
CONFIGURED_APPS += $(APPDIR)/testing/iozone
endif

64
testing/iozone/Makefile Normal file
View File

@ -0,0 +1,64 @@
############################################################################
# apps/testing/iozone/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
PROGNAME = $(CONFIG_TESTING_IOZONE_PROGNAME)
PRIORITY = $(CONFIG_TESTING_IOZONE_PRIORITY)
STACKSIZE = $(CONFIG_TESTING_IOZONE_STACKSIZE)
MODULE = $(CONFIG_TESTING_IOZONE)
CFLAGS += -Dunix -DHAVE_ANSIC_C -DHAVE_PREAD -DNAME='"nuttx"'
CFLAGS += -DNO_MADVISE -DNO_FORK -D__FreeBSD__ -DNO_THREADS
CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wno-shadow
CFLAGS += -Wno-unused-but-set-variable -Wno-strict-prototypes
CFLAGS += -Wno-misleading-indentation -Wno-maybe-uninitialized
CFLAGS += -DMAXBUFFERSIZE=32*1024 -DMAXSTREAMS=8 -DMAXNAMESIZE=NAME_MAX
CFLAGS += -DRECLEN_START=1024
CSRCS = iozone/src/current/libbif.c
MAINSRC = iozone/src/current/iozone.c
CONFIG_TESTING_IOZONE_URL ?= "https://www.iozone.org/src/current/"
IOZONE_UNPACKNAME = iozone
IOZONE_VERSION = $(patsubst "%",%,$(strip $(CONFIG_TESTING_IOZONE_VERSION)))
IOZONE_ZIP = iozone$(IOZONE_VERSION).tgz
$(IOZONE_ZIP):
@echo "Downloading: $(IOZONE_ZIP)"
$(Q) curl -O -L $(CONFIG_TESTING_IOZONE_URL)/$(IOZONE_ZIP)
$(IOZONE_UNPACKNAME): $(IOZONE_ZIP)
@echo "Unpacking: $(IOZONE_ZIP) -> $(IOZONE_UNPACKNAME)"
$(Q) tar zxvf $(IOZONE_ZIP)
$(Q) mv iozone$(IOZONE_VERSION) $(IOZONE_UNPACKNAME)
$(Q) echo "Patching $(IOZONE_UNPACKNAME)"
$(Q) cat iozone.patch | patch -s -N -d $(IOZONE_UNPACKNAME) -p1
$(Q) touch $(IOZONE_UNPACKNAME)
context:: $(IOZONE_UNPACKNAME)
distclean::
$(call DELDIR, $(IOZONE_UNPACKNAME))
$(call DELFILE, $(IOZONE_ZIP))
include $(APPDIR)/Application.mk

125
testing/iozone/iozone.patch Normal file
View File

@ -0,0 +1,125 @@
diff --git a/src/current/iozone.c b/src/current/iozone.c
index eda702d..59ee513 100644
--- a/src/current/iozone.c
+++ b/src/current/iozone.c
@@ -82,11 +82,12 @@ extern int h_errno; /* imported for errors */
#endif
#endif
+#include <sys/types.h>
#ifdef NO_FORK
+pid_t no_fork(void);
#define fork no_fork
#endif
-#include <sys/types.h>
#include <sys/stat.h>
#if defined (__LP64__) || defined(OSF_64) || defined(__alpha__) || defined(__arch64__) || defined(_LP64) || defined(__s390x__) || defined(__AMD64__)
#define MODE "\tCompiled for 64 bit mode."
@@ -870,16 +871,22 @@ struct master_neutral_command {
/* At 8 Meg switch to large records */
#define CROSSOVER (8*1024)
/*maximum buffer size*/
+#ifndef MAXBUFFERSIZE
#define MAXBUFFERSIZE (8*1024*1024)
+#endif
#else
/* At 16 Meg switch to large records */
#define CROSSOVER (16*1024)
+#ifndef MAXBUFFERSIZE
/* Maximum buffer size*/
#define MAXBUFFERSIZE (16*1024*1024)
#endif
+#endif
/* Maximum number of children. Threads/procs/clients */
+#ifndef MAXSTREAMS
#define MAXSTREAMS 1024
+#endif
/* Minimum buffer size */
#define MINBUFFERSIZE 128
@@ -899,7 +906,9 @@ struct master_neutral_command {
/* Maximum number of characters in filename */
+#ifndef MAXNAMESIZE
#define MAXNAMESIZE 1000
+#endif
/*
* Define the typical output that the user will see on their
@@ -953,7 +962,9 @@ struct master_neutral_command {
/* Default maximum file size. This is 512 MBytes */
#define KILOBYTES_END (1024*512)
/* Default starting record size */
+#ifndef RECLEN_START
#define RECLEN_START 4096
+#endif
/* Default maximum record size */
#define RECLEN_END (MAXBUFFERSIZE)
/* Multiplier for each itteration on file and record size */
@@ -1640,7 +1651,7 @@ char dummyfile1 [MAXNAMESIZE]; /* name of dummy file */
char *filearray[MAXSTREAMS]; /* array of file names */
int blkidx[MAXSTREAMS]; /* array of file names */
char tfile[MAXNAMESIZE];
-char *buffer,*buffer1, *mbuffer,*mainbuffer;
+static char *buffer,*buffer1, *mbuffer,*mainbuffer;
FILE *pi,*r_traj_fd,*w_traj_fd;
VOLATILE char *pbuffer;
char *default_filename="iozone.tmp"; /*default name of temporary file*/
@@ -1805,7 +1816,7 @@ int direct_flag;
int current_client_number;
long long chid;
int file_lock;
-unsigned int pattern;
+static unsigned int pattern;
long long stride = STRIDE;
long long delay,purge,fetchon;
off64_t numrecs64 = (off64_t)NUMRECS;
@@ -19219,7 +19230,7 @@ dump_throughput_cpu()
long long x,y,i,j;
char *port;
char *label;
- char print_str[300];
+ char print_str[512];
x=max_x;
y=max_y;
@@ -19288,7 +19299,7 @@ dump_throughput()
long long x,y,i,j;
char *port;
char *label;
- char print_str[300];
+ char print_str[512];
x=max_x;
y=max_y;
@@ -24340,7 +24351,7 @@ start_monitor(test)
char *test;
#endif
{
- char command_line[256];
+ char command_line[512];
if(strlen(imon_start)!=0)
{
if(imon_sync)
@@ -24358,7 +24369,7 @@ stop_monitor(test)
char *test;
#endif
{
- char command_line[256];
+ char command_line[512];
if(strlen(imon_stop)!=0)
{
if(imon_sync)
@@ -24867,6 +24878,9 @@ int main(void)
/*
** Type definitions (for convenience).
*/
+
+#undef false
+#undef true
#if defined(Windows)
int false = 0;
int true = 1;