From b3ffdf82604b0417666f2a17be81f819807e189e Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 28 Feb 2023 17:37:17 -0700 Subject: [PATCH] Test for_each_td() Signed-off-by: Jens Axboe --- backend.c | 9 ++------- dedupe.c | 1 - engines/libblkio.c | 1 - eta.c | 11 +++++------ fio.h | 8 ++++++-- init.c | 2 -- iolog.c | 1 - libfio.c | 2 -- rate-submit.c | 1 - stat.c | 4 ---- steadystate.c | 4 +--- verify.c | 1 - zbd.c | 5 ----- 13 files changed, 14 insertions(+), 36 deletions(-) diff --git a/backend.c b/backend.c index 975ef489..35d7cb62 100644 --- a/backend.c +++ b/backend.c @@ -93,7 +93,6 @@ static void sig_int(int sig) #ifdef WIN32 static void sig_break(int sig) { - struct thread_data *td; int i; sig_int(sig); @@ -2056,7 +2055,6 @@ err: static void reap_threads(unsigned int *nr_running, uint64_t *t_rate, uint64_t *m_rate) { - struct thread_data *td; unsigned int cputhreads, realthreads, pending; int i, status, ret; @@ -2284,7 +2282,6 @@ static bool waitee_running(struct thread_data *me) { const char *waitee = me->o.wait_for; const char *self = me->o.name; - struct thread_data *td; int i; if (!waitee) @@ -2311,7 +2308,6 @@ static bool waitee_running(struct thread_data *me) */ static void run_threads(struct sk_out *sk_out) { - struct thread_data *td; unsigned int i, todo, nr_running, nr_started; uint64_t m_rate, t_rate; uint64_t spent; @@ -2519,7 +2515,7 @@ reap: do_usleep(100000); for (i = 0; i < this_jobs; i++) { - td = map[i]; + struct thread_data *td = map[i]; if (!td) continue; if (td->runstate == TD_INITIALIZED) { @@ -2538,7 +2534,7 @@ reap: log_err("fio: %d job%s failed to start\n", left, left > 1 ? "s" : ""); for (i = 0; i < this_jobs; i++) { - td = map[i]; + struct thread_data *td = map[i]; if (!td) continue; kill(td->pid, SIGTERM); @@ -2589,7 +2585,6 @@ static void free_disk_util(void) int fio_backend(struct sk_out *sk_out) { - struct thread_data *td; int i; if (exec_profile) { diff --git a/dedupe.c b/dedupe.c index 8214a786..58ad94c0 100644 --- a/dedupe.c +++ b/dedupe.c @@ -8,7 +8,6 @@ int init_global_dedupe_working_set_seeds(void) { int i; - struct thread_data *td; for_each_td(td, i) { if (!td->o.dedupe_global) diff --git a/engines/libblkio.c b/engines/libblkio.c index 054aa800..b875a15a 100644 --- a/engines/libblkio.c +++ b/engines/libblkio.c @@ -283,7 +283,6 @@ static bool possibly_null_strs_equal(const char *a, const char *b) */ static int total_threaded_subjobs(bool hipri) { - struct thread_data *td; unsigned int i; int count = 0; diff --git a/eta.c b/eta.c index 6017ca31..5269a0d7 100644 --- a/eta.c +++ b/eta.c @@ -381,7 +381,6 @@ bool eta_time_within_slack(unsigned int time) */ bool calc_thread_status(struct jobs_eta *je, int force) { - struct thread_data *td; int i, unified_rw_rep; uint64_t rate_time, disp_time, bw_avg_time, *eta_secs; unsigned long long io_bytes[DDIR_RWDIR_CNT] = {}; @@ -392,6 +391,7 @@ bool calc_thread_status(struct jobs_eta *je, int force) static unsigned long long disp_io_bytes[DDIR_RWDIR_CNT]; static unsigned long long disp_io_iops[DDIR_RWDIR_CNT]; static struct timespec rate_prev_time, disp_prev_time; + bool all_in_ramp = false; if (!force) { if (!(output_format & FIO_OUTPUT_NORMAL) && @@ -417,6 +417,7 @@ bool calc_thread_status(struct jobs_eta *je, int force) bw_avg_time = ULONG_MAX; unified_rw_rep = 0; for_each_td(td, i) { + all_in_ramp |= in_ramp_time(td); unified_rw_rep += td->o.unified_rw_rep; if (is_power_of_2(td->o.kb_base)) je->is_pow2 = 1; @@ -481,10 +482,8 @@ bool calc_thread_status(struct jobs_eta *je, int force) if (exitall_on_terminate) { je->eta_sec = INT_MAX; - for_each_td(td, i) { - if (eta_secs[i] < je->eta_sec) - je->eta_sec = eta_secs[i]; - } + if (eta_secs[i] < je->eta_sec) + je->eta_sec = eta_secs[i]; } else { unsigned long eta_stone = 0; @@ -505,7 +504,7 @@ bool calc_thread_status(struct jobs_eta *je, int force) fio_gettime(&now, NULL); rate_time = mtime_since(&rate_prev_time, &now); - if (write_bw_log && rate_time > bw_avg_time && !in_ramp_time(td)) { + if (write_bw_log && rate_time > bw_avg_time && !all_in_ramp) { calc_rate(unified_rw_rep, rate_time, io_bytes, rate_io_bytes, je->rate); memcpy(&rate_prev_time, &now, sizeof(now)); diff --git a/fio.h b/fio.h index 09c44149..dcd29be3 100644 --- a/fio.h +++ b/fio.h @@ -754,8 +754,12 @@ extern void lat_target_reset(struct thread_data *); /* * Iterates all threads/processes within all the defined jobs */ -#define for_each_td(td, i) \ - for ((i) = 0, (td) = &segments[0].threads[0]; (i) < (int) thread_number; (i)++, (td) = tnumber_to_td((i))) +#define for_each_td(__td, __i) \ + (__i) = 0; \ + for (struct thread_data *__td = &segments[0].threads[0]; \ + (__i) < (int) thread_number; \ + (__i++), td = tnumber_to_td(__i)) + #define for_each_file(td, f, i) \ if ((td)->files_index) \ for ((i) = 0, (f) = (td)->files[0]; \ diff --git a/init.c b/init.c index 78c6c803..7ae8f23d 100644 --- a/init.c +++ b/init.c @@ -1405,7 +1405,6 @@ static void gen_log_name(char *name, size_t size, const char *logtype, static int check_waitees(char *waitee) { - struct thread_data *td; int i, ret = 0; for_each_td(td, i) { @@ -1448,7 +1447,6 @@ static bool wait_for_ok(const char *jobname, struct thread_options *o) static int verify_per_group_options(struct thread_data *td, const char *jobname) { - struct thread_data *td2; int i; for_each_td(td2, i) { diff --git a/iolog.c b/iolog.c index ea779632..71c19bf7 100644 --- a/iolog.c +++ b/iolog.c @@ -1875,7 +1875,6 @@ void td_writeout_logs(struct thread_data *td, bool unit_logs) void fio_writeout_logs(bool unit_logs) { - struct thread_data *td; int i; for_each_td(td, i) diff --git a/libfio.c b/libfio.c index ac521974..7ed1c2c6 100644 --- a/libfio.c +++ b/libfio.c @@ -240,7 +240,6 @@ void fio_mark_td_terminate(struct thread_data *td) void fio_terminate_threads(unsigned int group_id, unsigned int terminate) { - struct thread_data *td; pid_t pid = getpid(); int i; @@ -279,7 +278,6 @@ void fio_terminate_threads(unsigned int group_id, unsigned int terminate) int fio_running_or_pending_io_threads(void) { - struct thread_data *td; int i; int nr_io_threads = 0; diff --git a/rate-submit.c b/rate-submit.c index 3cc17eaa..46926c63 100644 --- a/rate-submit.c +++ b/rate-submit.c @@ -13,7 +13,6 @@ static void check_overlap(struct io_u *io_u) { int i, res; - struct thread_data *td; /* * Allow only one thread to check for overlap at a time to prevent two diff --git a/stat.c b/stat.c index b963973a..02438777 100644 --- a/stat.c +++ b/stat.c @@ -2366,7 +2366,6 @@ void init_thread_stat(struct thread_stat *ts) static void init_per_prio_stats(struct thread_stat *threadstats, int nr_ts) { - struct thread_data *td; struct thread_stat *ts; int i, j, last_ts, idx; enum fio_ddir ddir; @@ -2419,7 +2418,6 @@ static void init_per_prio_stats(struct thread_stat *threadstats, int nr_ts) void __show_run_stats(void) { struct group_run_stats *runstats, *rs; - struct thread_data *td; struct thread_stat *threadstats, *ts; int i, j, k, nr_ts, last_ts, idx; bool kb_base_warned = false; @@ -2722,7 +2720,6 @@ void __show_run_stats(void) int __show_running_run_stats(void) { - struct thread_data *td; unsigned long long *rt; struct timespec ts; int i; @@ -3554,7 +3551,6 @@ static int add_iops_samples(struct thread_data *td, struct timespec *t) */ int calc_log_samples(void) { - struct thread_data *td; unsigned int next = ~0U, tmp = 0, next_mod = 0, log_avg_msec_min = -1U; struct timespec now; int i; diff --git a/steadystate.c b/steadystate.c index ad19318c..a78cecc4 100644 --- a/steadystate.c +++ b/steadystate.c @@ -23,7 +23,7 @@ static void steadystate_alloc(struct thread_data *td) void steadystate_setup(void) { - struct thread_data *td, *prev_td; + struct thread_data *prev_td; int i, prev_groupid; if (!steadystate_enabled) @@ -200,7 +200,6 @@ int steadystate_check(void) { int i, j, ddir, prev_groupid, group_ramp_time_over = 0; unsigned long rate_time; - struct thread_data *td, *td2; struct timespec now; uint64_t group_bw = 0, group_iops = 0; uint64_t td_iops, td_bytes; @@ -302,7 +301,6 @@ int td_steadystate_init(struct thread_data *td) { struct steadystate_data *ss = &td->ss; struct thread_options *o = &td->o; - struct thread_data *td2; int j; memset(ss, 0, sizeof(*ss)); diff --git a/verify.c b/verify.c index ddfadcc8..8758942f 100644 --- a/verify.c +++ b/verify.c @@ -1568,7 +1568,6 @@ static int fill_file_completions(struct thread_data *td, struct all_io_list *get_all_io_list(int save_mask, size_t *sz) { struct all_io_list *rep; - struct thread_data *td; size_t depth; void *next; int i, nr; diff --git a/zbd.c b/zbd.c index d6f8f800..f335b891 100644 --- a/zbd.c +++ b/zbd.c @@ -524,7 +524,6 @@ out: /* Verify whether direct I/O is used for all host-managed zoned block drives. */ static bool zbd_using_direct_io(void) { - struct thread_data *td; struct fio_file *f; int i, j; @@ -639,7 +638,6 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td, */ static bool zbd_verify_sizes(void) { - struct thread_data *td; struct fio_file *f; int i, j; @@ -655,7 +653,6 @@ static bool zbd_verify_sizes(void) static bool zbd_verify_bs(void) { - struct thread_data *td; struct fio_file *f; int i, j; @@ -1010,7 +1007,6 @@ void zbd_free_zone_info(struct fio_file *f) */ static int zbd_init_zone_info(struct thread_data *td, struct fio_file *file) { - struct thread_data *td2; struct fio_file *f2; int i, j, ret; @@ -1289,7 +1285,6 @@ static uint32_t pick_random_zone_idx(const struct fio_file *f, static bool any_io_in_flight(void) { - struct thread_data *td; int i; for_each_td(td, i) { -- 2.25.1