This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit e9172a31956e55de9ddc44d9bc23e83ed4fe937a Author: chenrun1 <[email protected]> AuthorDate: Wed Apr 3 17:27:33 2024 +0800 fio:Added fio download link and corresponding fix patch Source codeļ¼https://github.com/ldorau/fio Signed-off-by: chenrun1 <[email protected]> --- .../0001-external-fio-fix-compile-warning.patch | 193 +++++++++ .../0002-external-fio-add-os-nuttx-support.patch | 81 ++++ ...xternal-fio-modify-smaller-size-for-nuttx.patch | 65 +++ ...04-external-fio-fix-runtime-error-by-asan.patch | 32 ++ .../0005-external-fio-fix-compile-warning.patch | 172 ++++++++ ...o-reinit-global-var-issue-when-run-multip.patch | 438 +++++++++++++++++++++ .../fio/0007-external-fio-add-engine-init.patch | 181 +++++++++ .../0008-fio-fix-memory-leak-run-cpuio.fio.patch | 30 ++ ...9-fio-fix-memory-leak-ioengine-filecreate.patch | 62 +++ .../0010-fio-fix-memory-leak-ioengine-exec.patch | 31 ++ benchmarks/fio/Makefile | 25 ++ 11 files changed, 1310 insertions(+) diff --git a/benchmarks/fio/0001-external-fio-fix-compile-warning.patch b/benchmarks/fio/0001-external-fio-fix-compile-warning.patch new file mode 100644 index 000000000..3161db25d --- /dev/null +++ b/benchmarks/fio/0001-external-fio-fix-compile-warning.patch @@ -0,0 +1,193 @@ +From b51436a258fc010a0ac15b551a9b010e54fccb11 Mon Sep 17 00:00:00 2001 +From: dongjiuzhu1 <[email protected]> +Date: Tue, 30 May 2023 22:01:51 +0800 +Subject: [PATCH 01/10] external/fio: fix compile warning + +Signed-off-by: dongjiuzhu1 <[email protected]> +--- + backend.c | 2 +- + init.c | 4 ++-- + server.c | 2 +- + stat.c | 28 +++++++++++++++------------- + zbd.c | 2 +- + 5 files changed, 20 insertions(+), 18 deletions(-) + +diff --git fio/backend.c fio/backend.c +index fe614f6e..0fa10657 100644 +--- fio/backend.c ++++ fio/backend.c +@@ -1950,7 +1950,7 @@ static void *thread_main(void *data) + * another thread is checking its io_u's for overlap + */ + if (td_offload_overlap(td)) { +- int res = pthread_mutex_lock(&overlap_check); ++ res = pthread_mutex_lock(&overlap_check); + assert(res == 0); + } + td_set_runstate(td, TD_FINISHING); +diff --git fio/init.c fio/init.c +index f6a8056a..de9d9d27 100644 +--- fio/init.c ++++ fio/init.c +@@ -2524,12 +2524,12 @@ static void show_closest_option(const char *name) + log_err("Did you mean %s?\n", l_opts[best_option].name); + } + +-static int parse_output_format(const char *optarg) ++static int parse_output_format(const char *arg) + { + char *p, *orig, *opt; + int ret = 0; + +- p = orig = strdup(optarg); ++ p = orig = strdup(arg); + + output_format = 0; + +diff --git fio/server.c fio/server.c +index b453be5f..23da2ecf 100644 +--- fio/server.c ++++ fio/server.c +@@ -356,7 +356,7 @@ static int verify_convert_cmd(struct fio_net_cmd *cmd) + } + + if (cmd->pdu_len > FIO_SERVER_MAX_FRAGMENT_PDU) { +- log_err("fio: command payload too large: %u\n", cmd->pdu_len); ++ log_err("fio: command payload too large: %"PRIu32"\n", cmd->pdu_len); + return 1; + } + +diff --git fio/stat.c fio/stat.c +index 949af5ed..6a39ae6e 100644 +--- fio/stat.c ++++ fio/stat.c +@@ -45,10 +45,12 @@ void update_rusage_stat(struct thread_data *td) + &td->ru_end.ru_utime); + ts->sys_time += mtime_since_tv(&td->ru_start.ru_stime, + &td->ru_end.ru_stime); ++#ifndef __NuttX__ + ts->ctx += td->ru_end.ru_nvcsw + td->ru_end.ru_nivcsw + - (td->ru_start.ru_nvcsw + td->ru_start.ru_nivcsw); + ts->minf += td->ru_end.ru_minflt - td->ru_start.ru_minflt; + ts->majf += td->ru_end.ru_majflt - td->ru_start.ru_majflt; ++#endif + + memcpy(&td->ru_start, &td->ru_end, sizeof(td->ru_end)); + } +@@ -346,7 +348,7 @@ void show_group_stats(struct group_run_stats *rs, struct buf_output *out) + const char *str[] = { " READ", " WRITE" , " TRIM"}; + int i; + +- log_buf(out, "\nRun status group %d (all jobs):\n", rs->groupid); ++ log_buf(out, "\nRun status group %"PRIu32" (all jobs):\n", rs->groupid); + + for (i = 0; i < DDIR_RWDIR_CNT; i++) { + const int i2p = is_power_of_2(rs->kb_base); +@@ -595,7 +597,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, + char buf[64]; + + snprintf(buf, sizeof(buf), +- "%s prio %u/%u", ++ "%s prio %"PRIu32"/%"PRIu32"", + clat_type, + ts->clat_prio[ddir][i].ioprio >> 13, + ts->clat_prio[ddir][i].ioprio & 7); +@@ -636,7 +638,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, + + if (prio_samples > 0) { + snprintf(prio_name, sizeof(prio_name), +- "%s prio %u/%u (%.2f%% of IOs)", ++ "%s prio %"PRIu32"/%"PRIu32" (%.2f%% of IOs)", + clat_type, + ts->clat_prio[ddir][i].ioprio >> 13, + ts->clat_prio[ddir][i].ioprio & 7, +@@ -896,7 +898,7 @@ static void show_block_infos(int nr_block_infos, uint32_t *block_infos, + uint32_t block_info = percentiles[i]; + #define LINE_LENGTH 75 + char str[LINE_LENGTH]; +- int strln = snprintf(str, LINE_LENGTH, " %3.2fth=%u%c", ++ int strln = snprintf(str, LINE_LENGTH, " %3.2fth=%"PRIu32"%c", + plist[i].u.f, block_info, + i == len - 1 ? '\n' : ','); + assert(strln < LINE_LENGTH); +@@ -1177,11 +1179,11 @@ static void show_thread_status_normal(struct thread_stat *ts, + os_ctime_r((const time_t *) &time_p, time_buf, sizeof(time_buf)); + + if (!ts->error) { +- log_buf(out, "%s: (groupid=%d, jobs=%d): err=%2d: pid=%d: %s", ++ log_buf(out, "%s: (groupid=%"PRIu32", jobs=%"PRIu32"): err=%2"PRIu32": pid=%d: %s", + ts->name, ts->groupid, ts->members, + ts->error, (int) ts->pid, time_buf); + } else { +- log_buf(out, "%s: (groupid=%d, jobs=%d): err=%2d (%s): pid=%d: %s", ++ log_buf(out, "%s: (groupid=%"PRIu32", jobs=%"PRIu32"): err=%2"PRIu32" (%s): pid=%d: %s", + ts->name, ts->groupid, ts->members, + ts->error, ts->verror, (int) ts->pid, + time_buf); +@@ -1253,13 +1255,13 @@ static void show_thread_status_normal(struct thread_stat *ts, + (unsigned long long) ts->drop_io_u[1], + (unsigned long long) ts->drop_io_u[2]); + if (ts->continue_on_error) { +- log_buf(out, " errors : total=%llu, first_error=%d/<%s>\n", ++ log_buf(out, " errors : total=%llu, first_error=%"PRIu32"/<%s>\n", + (unsigned long long)ts->total_err_count, + ts->first_error, + strerror(ts->first_error)); + } + if (ts->latency_depth) { +- log_buf(out, " latency : target=%llu, window=%llu, percentile=%.2f%%, depth=%u\n", ++ log_buf(out, " latency : target=%llu, window=%llu, percentile=%.2f%%, depth=%"PRIu32"\n", + (unsigned long long)ts->latency_target, + (unsigned long long)ts->latency_window, + ts->latency_percentile.u.f, +@@ -1589,9 +1591,9 @@ static void show_thread_status_terse_all(struct thread_stat *ts, + + /* General Info */ + if (ver == 2) +- log_buf(out, "2;%s;%d;%d", ts->name, ts->groupid, ts->error); ++ log_buf(out, "2;%s;%"PRIu32";%"PRIu32"", ts->name, ts->groupid, ts->error); + else +- log_buf(out, "%d;%s;%s;%d;%d", ver, fio_version_string, ++ log_buf(out, "%d;%s;%s;%"PRIu32";%"PRIu32"", ver, fio_version_string, + ts->name, ts->groupid, ts->error); + + /* Log Read Status, or mixed if unified_rw_rep = 1 */ +@@ -1644,7 +1646,7 @@ static void show_thread_status_terse_all(struct thread_stat *ts, + + /* Additional output if continue_on_error set - default off*/ + if (ts->continue_on_error) +- log_buf(out, ";%llu;%d", (unsigned long long) ts->total_err_count, ts->first_error); ++ log_buf(out, ";%llu;%"PRIu32"", (unsigned long long) ts->total_err_count, ts->first_error); + + /* Additional output if description is set */ + if (strlen(ts->description)) { +@@ -2519,11 +2521,11 @@ void __show_run_stats(void) + ts->unified_rw_rep = td->o.unified_rw_rep; + } else if (ts->kb_base != td->o.kb_base && !kb_base_warned) { + log_info("fio: kb_base differs for jobs in group, using" +- " %u as the base\n", ts->kb_base); ++ " %"PRIu32" as the base\n", ts->kb_base); + kb_base_warned = true; + } else if (ts->unit_base != td->o.unit_base && !unit_base_warned) { + log_info("fio: unit_base differs for jobs in group, using" +- " %u as the base\n", ts->unit_base); ++ " %"PRIu32" as the base\n", ts->unit_base); + unit_base_warned = true; + } + +diff --git fio/zbd.c fio/zbd.c +index 627fb968..114fb665 100644 +--- fio/zbd.c ++++ fio/zbd.c +@@ -1491,7 +1491,7 @@ static struct fio_zone_info *zbd_replay_write_order(struct thread_data *td, + } + + if (z->verify_block * min_bs >= z->capacity) { +- log_err("%s: %d * %"PRIu64" >= %"PRIu64"\n", ++ log_err("%s: %"PRIu32" * %"PRIu64" >= %"PRIu64"\n", + f->file_name, z->verify_block, min_bs, z->capacity); + /* + * If the assertion below fails during a test run, adding +-- +2.34.1 + diff --git a/benchmarks/fio/0002-external-fio-add-os-nuttx-support.patch b/benchmarks/fio/0002-external-fio-add-os-nuttx-support.patch new file mode 100644 index 000000000..d103fb719 --- /dev/null +++ b/benchmarks/fio/0002-external-fio-add-os-nuttx-support.patch @@ -0,0 +1,81 @@ +From 8f78b1199f814ad18e1902edf8d9fbf23b05b4d3 Mon Sep 17 00:00:00 2001 +From: dongjiuzhu1 <[email protected]> +Date: Mon, 5 Jun 2023 16:00:49 +0800 +Subject: [PATCH 02/10] external/fio: add os-nuttx support + +Signed-off-by: dongjiuzhu1 <[email protected]> +--- + os/os-nuttx.h | 39 +++++++++++++++++++++++++++++++++++++++ + os/os.h | 3 +++ + 2 files changed, 42 insertions(+) + create mode 100644 os/os-nuttx.h + +diff --git fio/os/os-nuttx.h fio/os/os-nuttx.h +new file mode 100644 +index 00000000..c81ea32c +--- /dev/null ++++ fio/os/os-nuttx.h +@@ -0,0 +1,39 @@ ++#ifndef FIO_OS_NUTTX_H ++#define FIO_OS_NUTTX_H ++ ++#include <errno.h> ++#include <malloc.h> ++#include <sys/mman.h> ++#include <sys/ioctl.h> ++ ++#include <nuttx/fs/ioctl.h> ++ ++#include "../file.h" ++ ++#define FIO_OS os_nuttx ++#define OS_MAP_ANON MAP_ANON ++ ++#define fio_swap16(x) bswap16(x) ++#define fio_swap32(x) bswap32(x) ++#define fio_swap64(x) bswap64(x) ++ ++static inline unsigned long long os_phys_mem(void) ++{ ++ struct mallinfo info; ++ ++ info = mallinfo(); ++ return (unsigned long long)info.arena; ++} ++ ++static inline int blockdev_invalidate_cache(struct fio_file *f) ++{ ++ return ioctl(f->fd, BIOC_FLUSH, 0); ++} ++ ++static inline pid_t setsid(void) ++{ ++ errno = ENOSYS; ++ return -1; ++} ++ ++#endif +diff --git fio/os/os.h fio/os/os.h +index aba6813f..dddff7c1 100644 +--- fio/os/os.h ++++ fio/os/os.h +@@ -24,6 +24,7 @@ enum { + os_windows, + os_android, + os_dragonfly, ++ os_nuttx, + + os_nr, + }; +@@ -53,6 +54,8 @@ typedef enum { + #include "os-windows.h" + #elif defined (__DragonFly__) + #include "os-dragonfly.h" ++#elif defined (__NuttX__) ++#include "os-nuttx.h" + #else + #error "unsupported os" + #endif +-- +2.34.1 + diff --git a/benchmarks/fio/0003-external-fio-modify-smaller-size-for-nuttx.patch b/benchmarks/fio/0003-external-fio-modify-smaller-size-for-nuttx.patch new file mode 100644 index 000000000..c869ffd81 --- /dev/null +++ b/benchmarks/fio/0003-external-fio-modify-smaller-size-for-nuttx.patch @@ -0,0 +1,65 @@ +From c39410be0f4516cd06f6d3597daf025db2efcba1 Mon Sep 17 00:00:00 2001 +From: dongjiuzhu1 <[email protected]> +Date: Mon, 5 Jun 2023 16:02:10 +0800 +Subject: [PATCH 03/10] external/fio: modify smaller size for nuttx + +Signed-off-by: dongjiuzhu1 <[email protected]> +--- + filehash.c | 2 ++ + lib/memcpy.c | 2 ++ + smalloc.c | 7 +++++++ + 3 files changed, 11 insertions(+) + +diff --git fio/filehash.c fio/filehash.c +index 71ec7b18..f13740d2 100644 +--- fio/filehash.c ++++ fio/filehash.c +@@ -11,7 +11,9 @@ + #define HASH_BUCKETS 512 + #define HASH_MASK (HASH_BUCKETS - 1) + ++#ifndef BLOOM_SIZE + #define BLOOM_SIZE 16*1024*1024 ++#endif + + static unsigned int file_hash_size = HASH_BUCKETS * sizeof(struct flist_head); + +diff --git fio/lib/memcpy.c fio/lib/memcpy.c +index a5521343..1b3466c1 100644 +--- fio/lib/memcpy.c ++++ fio/lib/memcpy.c +@@ -9,7 +9,9 @@ + #include "../gettime.h" + #include "../os/os.h" + ++#ifndef BUF_SIZE + #define BUF_SIZE 32 * 1024 * 1024ULL ++#endif + + #define NR_ITERS 64 + +diff --git fio/smalloc.c fio/smalloc.c +index 23243054..142e03d2 100644 +--- fio/smalloc.c ++++ fio/smalloc.c +@@ -18,10 +18,17 @@ + #define SMALLOC_BPI (sizeof(unsigned int) * 8) + #define SMALLOC_BPL (SMALLOC_BPB * SMALLOC_BPI) + ++#ifndef INITIAL_SIZE + #define INITIAL_SIZE 16*1024*1024 /* new pool size */ ++#endif ++ ++#ifndef INITIAL_POOLS + #define INITIAL_POOLS 8 /* maximum number of pools to setup */ ++#endif + ++#ifndef MAX_POOLS + #define MAX_POOLS 16 ++#endif + + #define SMALLOC_PRE_RED 0xdeadbeefU + #define SMALLOC_POST_RED 0x5aa55aa5U +-- +2.34.1 + diff --git a/benchmarks/fio/0004-external-fio-fix-runtime-error-by-asan.patch b/benchmarks/fio/0004-external-fio-fix-runtime-error-by-asan.patch new file mode 100644 index 000000000..49750cdaa --- /dev/null +++ b/benchmarks/fio/0004-external-fio-fix-runtime-error-by-asan.patch @@ -0,0 +1,32 @@ +From 02df0c8355b0adf01696e831f319c60f9ae6efb7 Mon Sep 17 00:00:00 2001 +From: dongjiuzhu1 <[email protected]> +Date: Fri, 9 Jun 2023 14:39:49 +0800 +Subject: [PATCH 04/10] external/fio: fix runtime error by asan + +/home/djz/workspace/test/vela_new/external/fio/fio/arch/arch-x86-common.h:11:7: runtime error: store to +misaligned address 0xf41f0d47 for type 'unsigned int', which requires 4 byte alignment +0xf41f0d47: note: pointer points here + 16 00 00 00 00 bc 0d 1f f4 00 d4 bd 1a 00 00 00 00 5c 2e 44 57 98 0d 1f f4 26 ab b8 56 18 0e 1f + ^ + +Signed-off-by: dongjiuzhu1 <[email protected]> +--- + arch/arch-x86-common.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git fio/arch/arch-x86-common.h fio/arch/arch-x86-common.h +index f32835cc..fe97cf64 100644 +--- fio/arch/arch-x86-common.h ++++ fio/arch/arch-x86-common.h +@@ -59,7 +59,7 @@ static inline void arch_init_amd(void) + static inline void arch_init(char *envp[]) + { + unsigned int level; +- char str[13]; ++ char str[13] __attribute__((aligned(0x8))); + + arch_random = tsc_reliable = 0; + +-- +2.34.1 + diff --git a/benchmarks/fio/0005-external-fio-fix-compile-warning.patch b/benchmarks/fio/0005-external-fio-fix-compile-warning.patch new file mode 100644 index 000000000..827d3f397 --- /dev/null +++ b/benchmarks/fio/0005-external-fio-fix-compile-warning.patch @@ -0,0 +1,172 @@ +From a69a23fb0cf6f9e0ad0cb857dda74e6e9b4bc6da Mon Sep 17 00:00:00 2001 +From: dongjiuzhu1 <[email protected]> +Date: Sat, 10 Jun 2023 18:34:17 +0800 +Subject: [PATCH 05/10] external/fio: fix compile warning + +io/compiler/compiler.h:25:25: warning: comparison of distinct pointer types lacks a cast + 25 | (void)(&__dummy == &__dummy2); \ + | ^~ +fio/os/os.h:291:9: note: in expansion of macro 'typecheck' + 291 | typecheck(uint32_t, val); \ + | ^~~~~~~~~ +fio/verify.c:1628:48: note: in expansion of macro 'cpu_to_le32' + 1628 | s->rand.state32.s[0] = cpu_to_le32(td->random_state.state32.s1); + | ^~~~~~~~~~~ + +Signed-off-by: dongjiuzhu1 <[email protected]> +--- + client.c | 2 +- + engines/fileoperations.c | 4 ++-- + eta.c | 6 +++--- + iolog.c | 2 +- + os/os.h | 2 -- + verify.c | 6 +++--- + zbd.c | 2 +- + 7 files changed, 11 insertions(+), 13 deletions(-) + +diff --git fio/client.c fio/client.c +index 37da74bc..f9a3247e 100644 +--- fio/client.c ++++ fio/client.c +@@ -1406,7 +1406,7 @@ static void client_flush_hist_samples(FILE *f, int hist_coarseness, void *sample + entry = s->data.plat_entry; + io_u_plat = entry->io_u_plat; + +- fprintf(f, "%lu, %u, %llu, ", (unsigned long) s->time, ++ fprintf(f, "%lu, %"PRIu32", %llu, ", (unsigned long) s->time, + io_sample_ddir(s), (unsigned long long) s->bs); + for (j = 0; j < FIO_IO_U_PLAT_NR - stride; j += stride) { + fprintf(f, "%llu, ", (unsigned long long)hist_sum(j, stride, io_u_plat, NULL)); +diff --git fio/engines/fileoperations.c fio/engines/fileoperations.c +index 1db60da1..ed0456c0 100644 +--- fio/engines/fileoperations.c ++++ fio/engines/fileoperations.c +@@ -109,7 +109,7 @@ static int stat_file(struct thread_data *td, struct fio_file *f) + struct timespec start; + int do_lat = !td->o.disable_lat; + struct stat statbuf; +-#ifndef WIN32 ++#if !defined(WIN32) && !defined(__NuttX__) + struct statx statxbuf; + char *abspath; + #endif +@@ -137,7 +137,7 @@ static int stat_file(struct thread_data *td, struct fio_file *f) + ret = lstat(f->file_name, &statbuf); + break; + case FIO_FILESTAT_STATX: +-#ifndef WIN32 ++#if !defined(WIN32) && !defined(__NuttX__) + abspath = realpath(f->file_name, NULL); + if (abspath) { + ret = statx(-1, abspath, 0, STATX_ALL, &statxbuf); +diff --git fio/eta.c fio/eta.c +index 6017ca31..2df3bd5d 100644 +--- fio/eta.c ++++ fio/eta.c +@@ -344,7 +344,7 @@ static void calc_rate(int unified_rw_rep, unsigned long mtime, + + static void calc_iops(int unified_rw_rep, unsigned long mtime, + unsigned long long *io_iops, +- unsigned long long *prev_io_iops, unsigned int *iops) ++ unsigned long long *prev_io_iops, uint32_t *iops) + { + int i; + +@@ -594,7 +594,7 @@ void display_thread_status(struct jobs_eta *je) + p += sprintf(p, "\n"); + } + +- p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open); ++ p += sprintf(p, "Jobs: %"PRIi32" (f=%"PRIi32")", je->nr_running, je->files_open); + + /* rate limits, if any */ + if (je->m_rate[0] || je->m_rate[1] || je->m_rate[2] || +@@ -611,7 +611,7 @@ void display_thread_status(struct jobs_eta *je) + free(mr); + } else if (je->m_iops[0] || je->m_iops[1] || je->m_iops[2] || + je->t_iops[0] || je->t_iops[1] || je->t_iops[2]) { +- p += sprintf(p, ", %d-%d IOPS", ++ p += sprintf(p, ", %"PRIi32"-%"PRIi32" IOPS", + je->m_iops[0] + je->m_iops[1] + je->m_iops[2], + je->t_iops[0] + je->t_iops[1] + je->t_iops[2]); + } +diff --git fio/iolog.c fio/iolog.c +index aa9c3bb1..cdb24a2b 100644 +--- fio/iolog.c ++++ fio/iolog.c +@@ -952,7 +952,7 @@ static void flush_hist_samples(FILE *f, int hist_coarseness, void *samples, + entry_before = flist_first_entry(&entry->list, struct io_u_plat_entry, list); + io_u_plat_before = entry_before->io_u_plat; + +- fprintf(f, "%lu, %u, %llu, ", (unsigned long) s->time, ++ fprintf(f, "%lu, %"PRIu32", %llu, ", (unsigned long) s->time, + io_sample_ddir(s), (unsigned long long) s->bs); + for (j = 0; j < FIO_IO_U_PLAT_NR - stride; j += stride) { + fprintf(f, "%llu, ", (unsigned long long) +diff --git fio/os/os.h fio/os/os.h +index dddff7c1..4d8c7537 100644 +--- fio/os/os.h ++++ fio/os/os.h +@@ -262,7 +262,6 @@ static inline uint64_t fio_swap64(uint64_t val) + __le16_to_cpu(val); \ + }) + #define le32_to_cpu(val) ({ \ +- typecheck(uint32_t, val); \ + __le32_to_cpu(val); \ + }) + #define le64_to_cpu(val) ({ \ +@@ -288,7 +287,6 @@ static inline uint64_t fio_swap64(uint64_t val) + __cpu_to_le16(val); \ + }) + #define cpu_to_le32(val) ({ \ +- typecheck(uint32_t, val); \ + __cpu_to_le32(val); \ + }) + #define cpu_to_le64(val) ({ \ +diff --git fio/verify.c fio/verify.c +index 0e1e4639..ea414749 100644 +--- fio/verify.c ++++ fio/verify.c +@@ -341,7 +341,7 @@ static void log_verify_failure(struct verify_header *hdr, struct vcont *vc) + + offset = vc->io_u->verify_offset; + offset += vc->hdr_num * hdr->len; +- log_err("%.8s: verify failed at file %s offset %llu, length %u" ++ log_err("%.8s: verify failed at file %s offset %llu, length %"PRIu32"" + " (requested block: offset=%llu, length=%llu, flags=%x)\n", + vc->name, vc->io_u->file->file_name, offset, hdr->len, + vc->io_u->verify_offset, vc->io_u->buflen, vc->io_u->flags); +@@ -819,7 +819,7 @@ static int verify_header(struct io_u *io_u, struct thread_data *td, + goto err; + } + if (hdr->len != hdr_len) { +- log_err("verify: bad header length %u, wanted %u", ++ log_err("verify: bad header length %"PRIu32", wanted %u", + hdr->len, hdr_len); + goto err; + } +@@ -854,7 +854,7 @@ static int verify_header(struct io_u *io_u, struct thread_data *td, + + crc = fio_crc32c(p, offsetof(struct verify_header, crc32)); + if (crc != hdr->crc32) { +- log_err("verify: bad header crc %x, calculated %x", ++ log_err("verify: bad header crc %"PRIx32", calculated %"PRIx32"", + hdr->crc32, crc); + goto err; + } +diff --git fio/zbd.c fio/zbd.c +index 114fb665..3933ab2d 100644 +--- fio/zbd.c ++++ fio/zbd.c +@@ -814,7 +814,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f) + break; + + nrz = zbd_report_zones(td, f, offset, zones, +- min((uint32_t)(nr_zones - j), ++ min((unsigned)(nr_zones - j), + ZBD_REPORT_MAX_ZONES)); + if (nrz < 0) { + ret = nrz; +-- +2.34.1 + diff --git a/benchmarks/fio/0006-external-fio-reinit-global-var-issue-when-run-multip.patch b/benchmarks/fio/0006-external-fio-reinit-global-var-issue-when-run-multip.patch new file mode 100644 index 000000000..534f77724 --- /dev/null +++ b/benchmarks/fio/0006-external-fio-reinit-global-var-issue-when-run-multip.patch @@ -0,0 +1,438 @@ +From 6afb9af3dd7734d0f6bd090fba947ffaec43482b Mon Sep 17 00:00:00 2001 +From: dongjiuzhu1 <[email protected]> +Date: Mon, 5 Jun 2023 14:44:53 +0800 +Subject: [PATCH 06/10] external/fio: reinit global var issue when run multiple + times + +Signed-off-by: dongjiuzhu1 <[email protected]> +--- + init.c | 386 +++++++++++++++++++++++++----------------------------- + smalloc.c | 4 + + 2 files changed, 186 insertions(+), 204 deletions(-) + +diff --git fio/init.c fio/init.c +index de9d9d27..9dcad491 100644 +--- fio/init.c ++++ fio/init.c +@@ -96,214 +96,191 @@ static bool did_arg; + * Command line options. These will contain the above, plus a few + * extra that only pertain to fio itself and not jobs. + */ +-static struct option l_opts[FIO_NR_OPTIONS] = { +- { +- .name = (char *) "output", +- .has_arg = required_argument, +- .val = 'o' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "latency-log", +- .has_arg = required_argument, +- .val = 'l' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "bandwidth-log", +- .has_arg = no_argument, +- .val = 'b' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "minimal", +- .has_arg = no_argument, +- .val = 'm' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "output-format", +- .has_arg = required_argument, +- .val = 'F' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "append-terse", +- .has_arg = optional_argument, +- .val = 'f', +- }, +- { +- .name = (char *) "version", +- .has_arg = no_argument, +- .val = 'v' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "help", +- .has_arg = no_argument, +- .val = 'h' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "cmdhelp", +- .has_arg = optional_argument, +- .val = 'c' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "enghelp", +- .has_arg = optional_argument, +- .val = 'i' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "showcmd", +- .has_arg = no_argument, +- .val = 's' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "readonly", +- .has_arg = no_argument, +- .val = 'r' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "eta", +- .has_arg = required_argument, +- .val = 'e' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "eta-interval", +- .has_arg = required_argument, +- .val = 'O' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "eta-newline", +- .has_arg = required_argument, +- .val = 'E' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "debug", +- .has_arg = required_argument, +- .val = 'd' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "parse-only", +- .has_arg = no_argument, +- .val = 'P' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "section", +- .has_arg = required_argument, +- .val = 'x' | FIO_CLIENT_FLAG, +- }, ++static struct option l_opts[FIO_NR_OPTIONS]; ++static void fio_init_global(void) ++{ ++ int i = 0; ++ ++ l_opts[i].name = (char *) "output", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'o' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "latency-log", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'l' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "bandwidth-log", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'b' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "minimal", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'm' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "output-format", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'F' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "append-terse", ++ l_opts[i].has_arg = optional_argument, ++ l_opts[i++].val = 'f', ++ ++ l_opts[i].name = (char *) "version", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'v' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "help", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'h' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "cmdhelp", ++ l_opts[i].has_arg = optional_argument, ++ l_opts[i++].val = 'c' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "enghelp", ++ l_opts[i].has_arg = optional_argument, ++ l_opts[i++].val = 'i' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "showcmd", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 's' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "readonly", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'r' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "eta", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'e' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "eta-interval", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'O' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "eta-newline", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'E' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "debug", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'd' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "parse-only", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'P' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "section", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'x' | FIO_CLIENT_FLAG, ++ + #ifdef CONFIG_ZLIB +- { +- .name = (char *) "inflate-log", +- .has_arg = required_argument, +- .val = 'X' | FIO_CLIENT_FLAG, +- }, ++ l_opts[i].name = (char *) "inflate-log", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'X' | FIO_CLIENT_FLAG, + #endif +- { +- .name = (char *) "alloc-size", +- .has_arg = required_argument, +- .val = 'a' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "profile", +- .has_arg = required_argument, +- .val = 'p' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "warnings-fatal", +- .has_arg = no_argument, +- .val = 'w' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "max-jobs", +- .has_arg = required_argument, +- .val = 'j' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "terse-version", +- .has_arg = required_argument, +- .val = 'V' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "server", +- .has_arg = optional_argument, +- .val = 'S', +- }, ++ ++ l_opts[i].name = (char *) "alloc-size", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'a' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "profile", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'p' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "warnings-fatal", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'w' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "max-jobs", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'j' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "terse-version", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'V' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "server", ++ l_opts[i].has_arg = optional_argument, ++ l_opts[i++].val = 'S', ++ + #ifdef WIN32 +- { +- .name = (char *) "server-internal", +- .has_arg = required_argument, +- .val = 'N', +- }, ++ l_opts[i].name = (char *) "server-internal", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'N', + #endif +- { .name = (char *) "daemonize", +- .has_arg = required_argument, +- .val = 'D', +- }, +- { +- .name = (char *) "client", +- .has_arg = required_argument, +- .val = 'C', +- }, +- { +- .name = (char *) "remote-config", +- .has_arg = required_argument, +- .val = 'R', +- }, +- { +- .name = (char *) "cpuclock-test", +- .has_arg = no_argument, +- .val = 'T', +- }, +- { +- .name = (char *) "crctest", +- .has_arg = optional_argument, +- .val = 'G', +- }, +- { +- .name = (char *) "memcpytest", +- .has_arg = optional_argument, +- .val = 'M', +- }, +- { +- .name = (char *) "idle-prof", +- .has_arg = required_argument, +- .val = 'I', +- }, +- { +- .name = (char *) "status-interval", +- .has_arg = required_argument, +- .val = 'L' | FIO_CLIENT_FLAG, +- }, +- { +- .name = (char *) "trigger-file", +- .has_arg = required_argument, +- .val = 'W', +- }, +- { +- .name = (char *) "trigger-timeout", +- .has_arg = required_argument, +- .val = 'B', +- }, +- { +- .name = (char *) "trigger", +- .has_arg = required_argument, +- .val = 'H', +- }, +- { +- .name = (char *) "trigger-remote", +- .has_arg = required_argument, +- .val = 'J', +- }, +- { +- .name = (char *) "aux-path", +- .has_arg = required_argument, +- .val = 'K', +- }, +- { +- .name = (char *) "merge-blktrace-only", +- .has_arg = no_argument, +- .val = 'A' | FIO_CLIENT_FLAG, +- }, +- { +- .name = NULL, +- }, +-}; ++ ++ l_opts[i].name = (char *) "daemonize", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'D', ++ ++ l_opts[i].name = (char *) "client", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'C', ++ ++ l_opts[i].name = (char *) "remote-config", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'R', ++ ++ l_opts[i].name = (char *) "cpuclock-test", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'T', ++ ++ l_opts[i].name = (char *) "crctest", ++ l_opts[i].has_arg = optional_argument, ++ l_opts[i++].val = 'G', ++ ++ l_opts[i].name = (char *) "memcpytest", ++ l_opts[i].has_arg = optional_argument, ++ l_opts[i++].val = 'M', ++ ++ l_opts[i].name = (char *) "idle-prof", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'I', ++ ++ l_opts[i].name = (char *) "status-interval", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'L' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = (char *) "trigger-file", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'W', ++ ++ l_opts[i].name = (char *) "trigger-timeout", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'B', ++ ++ l_opts[i].name = (char *) "trigger", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'H', ++ ++ l_opts[i].name = (char *) "trigger-remote", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'J', ++ ++ l_opts[i].name = (char *) "aux-path", ++ l_opts[i].has_arg = required_argument, ++ l_opts[i++].val = 'K', ++ ++ l_opts[i].name = (char *) "merge-blktrace-only", ++ l_opts[i].has_arg = no_argument, ++ l_opts[i++].val = 'A' | FIO_CLIENT_FLAG, ++ ++ l_opts[i].name = NULL, ++ ++ thread_number = 0; ++ nr_segments = 0; ++ cur_segment = 0; ++ stat_number = 0; ++ ++ did_arg = false; ++ ini_file = NULL; ++ nr_clients = 0; ++ thread_number = 0; ++ prev_group_jobs = 0; ++ memset(&def_thread, 0, sizeof(def_thread)); ++ memset(segments, 0, sizeof(segments)); ++ memset(cmd_optstr, 0, sizeof(cmd_optstr)); ++} + + void free_threads_shm(void) + { +@@ -3044,6 +3021,7 @@ int fio_init_options(void) + f_out = stdout; + f_err = stderr; + ++ fio_init_global(); + fio_options_fill_optstring(); + fio_options_dup_and_init(l_opts); + +diff --git fio/smalloc.c fio/smalloc.c +index 142e03d2..a93290eb 100644 +--- fio/smalloc.c ++++ fio/smalloc.c +@@ -215,6 +215,10 @@ void sinit(void) + bool ret; + int i; + ++ mp = NULL; ++ nr_pools = 0; ++ smalloc_pool_size = INITIAL_SIZE; ++ + /* + * sinit() can be called more than once if alloc-size is + * set. But we want to allocate space for the struct pool +-- +2.34.1 + diff --git a/benchmarks/fio/0007-external-fio-add-engine-init.patch b/benchmarks/fio/0007-external-fio-add-engine-init.patch new file mode 100644 index 000000000..148bad36a --- /dev/null +++ b/benchmarks/fio/0007-external-fio-add-engine-init.patch @@ -0,0 +1,181 @@ +From b167af3a9446506c6b3f48c0b03ae58bb3f1e9d4 Mon Sep 17 00:00:00 2001 +From: dongjiuzhu1 <[email protected]> +Date: Sat, 10 Jun 2023 15:01:29 +0800 +Subject: [PATCH 07/10] external/fio: add engine init + +Signed-off-by: dongjiuzhu1 <[email protected]> +--- + engines/cpu.c | 2 +- + engines/exec.c | 2 +- + engines/falloc.c | 2 +- + engines/fileoperations.c | 2 +- + engines/ftruncate.c | 2 +- + engines/mmap.c | 2 +- + engines/net.c | 2 +- + engines/null.c | 2 +- + engines/sync.c | 2 +- + libfio.c | 24 ++++++++++++++++++++++++ + 10 files changed, 33 insertions(+), 9 deletions(-) + +diff --git fio/engines/cpu.c fio/engines/cpu.c +index ce74dbce..564a3d7a 100644 +--- fio/engines/cpu.c ++++ fio/engines/cpu.c +@@ -326,7 +326,7 @@ static struct ioengine_ops ioengine = { + .option_struct_size = sizeof(struct cpu_options), + }; + +-static void fio_init fio_cpuio_register(void) ++void fio_cpuio_register(void) + { + register_ioengine(&ioengine); + } +diff --git fio/engines/exec.c fio/engines/exec.c +index 20e50e00..a9025264 100644 +--- fio/engines/exec.c ++++ fio/engines/exec.c +@@ -383,7 +383,7 @@ static struct ioengine_ops ioengine = { + .option_struct_size = sizeof(struct exec_options), + }; + +-static void fio_init fio_exec_register(void) ++void fio_exec_register(void) + { + register_ioengine(&ioengine); + } +diff --git fio/engines/falloc.c fio/engines/falloc.c +index 4b05ed68..9fc3bd5b 100644 +--- fio/engines/falloc.c ++++ fio/engines/falloc.c +@@ -101,7 +101,7 @@ static struct ioengine_ops ioengine = { + .flags = FIO_SYNCIO + }; + +-static void fio_init fio_syncio_register(void) ++void fio_syncio_falloc_register(void) + { + register_ioengine(&ioengine); + } +diff --git fio/engines/fileoperations.c fio/engines/fileoperations.c +index ed0456c0..b302cda5 100644 +--- fio/engines/fileoperations.c ++++ fio/engines/fileoperations.c +@@ -303,7 +303,7 @@ static struct ioengine_ops ioengine_filedelete = { + }; + + +-static void fio_init fio_fileoperations_register(void) ++void fio_fileoperations_register(void) + { + register_ioengine(&ioengine_filecreate); + register_ioengine(&ioengine_filestat); +diff --git fio/engines/ftruncate.c fio/engines/ftruncate.c +index c7ad038c..7ed859a4 100644 +--- fio/engines/ftruncate.c ++++ fio/engines/ftruncate.c +@@ -41,7 +41,7 @@ static struct ioengine_ops ioengine = { + .flags = FIO_SYNCIO | FIO_FAKEIO + }; + +-static void fio_init fio_syncio_register(void) ++void fio_syncio_ftruncate_register(void) + { + register_ioengine(&ioengine); + } +diff --git fio/engines/mmap.c fio/engines/mmap.c +index 55ba1ab3..a47b9686 100644 +--- fio/engines/mmap.c ++++ fio/engines/mmap.c +@@ -327,7 +327,7 @@ static struct ioengine_ops ioengine = { + #endif + }; + +-static void fio_init fio_mmapio_register(void) ++void fio_mmapio_register(void) + { + register_ioengine(&ioengine); + } +diff --git fio/engines/net.c fio/engines/net.c +index c6cec584..0f9fd6be 100644 +--- fio/engines/net.c ++++ fio/engines/net.c +@@ -1450,7 +1450,7 @@ static int str_hostname_cb(void *data, const char *input) + return 0; + } + +-static void fio_init fio_netio_register(void) ++void fio_netio_register(void) + { + register_ioengine(&ioengine_rw); + #ifdef CONFIG_LINUX_SPLICE +diff --git fio/engines/null.c fio/engines/null.c +index 68759c26..2b4695c4 100644 +--- fio/engines/null.c ++++ fio/engines/null.c +@@ -176,7 +176,7 @@ static struct ioengine_ops ioengine = { + .flags = FIO_DISKLESSIO | FIO_FAKEIO, + }; + +-static void fio_init fio_null_register(void) ++void fio_null_register(void) + { + register_ioengine(&ioengine); + } +diff --git fio/engines/sync.c fio/engines/sync.c +index 339ba999..f1047114 100644 +--- fio/engines/sync.c ++++ fio/engines/sync.c +@@ -490,7 +490,7 @@ static struct ioengine_ops ioengine_pvrw2 = { + }; + #endif + +-static void fio_init fio_syncio_register(void) ++void fio_syncio_register(void) + { + register_ioengine(&ioengine_rw); + register_ioengine(&ioengine_prw); +diff --git fio/libfio.c fio/libfio.c +index 1a891776..b634fbc7 100644 +--- fio/libfio.c ++++ fio/libfio.c +@@ -350,6 +350,28 @@ static int endian_check(void) + return 0; + } + ++extern void fio_cpuio_register(void); ++extern void fio_exec_register(void); ++extern void fio_syncio_register(void); ++extern void fio_syncio_ftruncate_register(void); ++extern void fio_syncio_falloc_register(void); ++extern void fio_fileoperations_register(void); ++extern void fio_mmapio_register(void); ++extern void fio_netio_register(void); ++extern void fio_null_register(void); ++void fio_engine_init(void) ++{ ++ fio_cpuio_register(); ++ fio_exec_register(); ++ fio_syncio_register(); ++ fio_syncio_ftruncate_register(); ++ fio_syncio_falloc_register(); ++ fio_fileoperations_register(); ++ fio_mmapio_register(); ++ fio_netio_register(); ++ fio_null_register(); ++} ++ + int initialize_fio(char *envp[]) + { + long ps; +@@ -431,6 +453,8 @@ int initialize_fio(char *envp[]) + page_mask = ps - 1; + + fio_keywords_init(); ++ ++ fio_engine_init(); + return 0; + } + +-- +2.34.1 + diff --git a/benchmarks/fio/0008-fio-fix-memory-leak-run-cpuio.fio.patch b/benchmarks/fio/0008-fio-fix-memory-leak-run-cpuio.fio.patch new file mode 100644 index 000000000..200927a18 --- /dev/null +++ b/benchmarks/fio/0008-fio-fix-memory-leak-run-cpuio.fio.patch @@ -0,0 +1,30 @@ +From 4104f7946da6a608f40dc6028d2f6570daad8ef0 Mon Sep 17 00:00:00 2001 +From: guohao15 <[email protected]> +Date: Wed, 18 Oct 2023 11:09:12 +0800 +Subject: [PATCH 08/10] fio:fix memory leak run cpuio.fio + +Signed-off-by: guohao15 <[email protected]> +--- + init.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git fio/init.c fio/init.c +index 9dcad491..57d8ae18 100644 +--- fio/init.c ++++ fio/init.c +@@ -493,8 +493,11 @@ static struct thread_data *get_new_job(bool global, struct thread_data *parent, + td->thread_number = thread_number; + td->subjob_number = 0; + +- if (jobname) ++ if (jobname) { ++ if (td->o.name) ++ free(td->o.name); + td->o.name = strdup(jobname); ++ } + + if (!parent->o.group_reporting || parent == &def_thread) + stat_number++; +-- +2.34.1 + diff --git a/benchmarks/fio/0009-fio-fix-memory-leak-ioengine-filecreate.patch b/benchmarks/fio/0009-fio-fix-memory-leak-ioengine-filecreate.patch new file mode 100644 index 000000000..b74e3a533 --- /dev/null +++ b/benchmarks/fio/0009-fio-fix-memory-leak-ioengine-filecreate.patch @@ -0,0 +1,62 @@ +From a7b806befaf11eccf7f769187717dda1ec352fdc Mon Sep 17 00:00:00 2001 +From: guohao15 <[email protected]> +Date: Wed, 18 Oct 2023 21:14:05 +0800 +Subject: [PATCH 09/10] fio:fix memory leak ioengine=filecreate + +Signed-off-by: guohao15 <[email protected]> +--- + gettime.c | 2 +- + init.c | 10 ++++++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git fio/gettime.c fio/gettime.c +index 14462420..2f0207d5 100644 +--- fio/gettime.c ++++ fio/gettime.c +@@ -37,7 +37,7 @@ static pthread_key_t tv_tls_key; + + enum fio_cs fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE; + int fio_clock_source_set = 0; +-static enum fio_cs fio_clock_source_inited = CS_INVAL; ++enum fio_cs fio_clock_source_inited = CS_INVAL; + + #ifdef FIO_DEBUG_TIME + +diff --git fio/init.c fio/init.c +index 57d8ae18..c8f53e62 100644 +--- fio/init.c ++++ fio/init.c +@@ -90,6 +90,10 @@ unsigned int *fio_warned = NULL; + static char cmd_optstr[256]; + static bool did_arg; + ++extern enum fio_cs fio_clock_source; ++extern int fio_clock_source_set; ++extern enum fio_cs fio_clock_source_inited; ++ + #define FIO_CLIENT_FLAG (1 << 16) + + /* +@@ -277,6 +281,11 @@ static void fio_init_global(void) + nr_clients = 0; + thread_number = 0; + prev_group_jobs = 0; ++ ++ fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE; ++ fio_clock_source_set = 0; ++ fio_clock_source_inited = CS_INVAL; ++ + memset(&def_thread, 0, sizeof(def_thread)); + memset(segments, 0, sizeof(segments)); + memset(cmd_optstr, 0, sizeof(cmd_optstr)); +@@ -3073,6 +3082,7 @@ int parse_options(int argc, char *argv[]) + + free(ini_file); + fio_options_free(&def_thread); ++ fio_dump_options_free(&def_thread); + filesetup_mem_free(); + + if (!thread_number) { +-- +2.34.1 + diff --git a/benchmarks/fio/0010-fio-fix-memory-leak-ioengine-exec.patch b/benchmarks/fio/0010-fio-fix-memory-leak-ioengine-exec.patch new file mode 100644 index 000000000..f07b7e8ed --- /dev/null +++ b/benchmarks/fio/0010-fio-fix-memory-leak-ioengine-exec.patch @@ -0,0 +1,31 @@ +From 6b211dc0191f0ebef454fdc8f5602474bed65471 Mon Sep 17 00:00:00 2001 +From: guohao15 <[email protected]> +Date: Wed, 18 Oct 2023 17:42:33 +0800 +Subject: [PATCH 10/10] fio:fix memory leak ioengine=exec + +Signed-off-by: guohao15 <[email protected]> +--- + engines/exec.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git fio/engines/exec.c fio/engines/exec.c +index a9025264..fbefb99e 100644 +--- fio/engines/exec.c ++++ fio/engines/exec.c +@@ -188,7 +188,13 @@ static int exec_background(struct thread_options *o, struct exec_options *eo) + free(outfilename); + free(errfilename); + } ++ for (int i = 0; i < arguments_nb_items; i++) ++ free(arguments_array[i]); ++ free(arguments_array); + free(expanded_arguments); ++ free(exec_cmd); ++ free(outfilename); ++ free(errfilename); + return 0; + } + +-- +2.34.1 + diff --git a/benchmarks/fio/Makefile b/benchmarks/fio/Makefile index a23544a85..34c80c934 100644 --- a/benchmarks/fio/Makefile +++ b/benchmarks/fio/Makefile @@ -59,4 +59,29 @@ CSRCS += fio/engines/exec.c fio/engines/cpu.c fio/engines/sync.c fio/engines/ftr fio/engines/falloc.c fio/engines/fileoperations.c fio/engines/mmap.c \ fio/engines/null.c fio/engines/net.c +ifeq ($(wildcard fio/.git),) +VERSION ?= master +fio.zip: + $(Q) curl -L https://github.com/ldorau/fio/archive/refs/heads/master.zip -o fio.zip + $(Q) unzip -o fio.zip + $(Q) mv fio-$(VERSION) fio + $(Q) patch -p0 < 0001-external-fio-fix-compile-warning.patch + $(Q) patch -p0 < 0002-external-fio-add-os-nuttx-support.patch + $(Q) patch -p0 < 0003-external-fio-modify-smaller-size-for-nuttx.patch + $(Q) patch -p0 < 0004-external-fio-fix-runtime-error-by-asan.patch + $(Q) patch -p0 < 0005-external-fio-fix-compile-warning.patch + $(Q) patch -p0 < 0006-external-fio-reinit-global-var-issue-when-run-multip.patch + $(Q) patch -p0 < 0007-external-fio-add-engine-init.patch + $(Q) patch -p0 < 0008-fio-fix-memory-leak-run-cpuio.fio.patch + $(Q) patch -p0 < 0009-fio-fix-memory-leak-ioengine-filecreate.patch + $(Q) patch -p0 < 0010-fio-fix-memory-leak-ioengine-exec.patch + +context:: fio.zip + +distclean:: + $(call DELDIR, fio) + $(call DELFILE, fio.zip) + +endif + include $(APPDIR)/Application.mk
