Test for_each_td() for-each-td
authorJens Axboe <axboe@kernel.dk>
Wed, 1 Mar 2023 00:37:17 +0000 (17:37 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 1 Mar 2023 00:37:17 +0000 (17:37 -0700)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
13 files changed:
backend.c
dedupe.c
engines/libblkio.c
eta.c
fio.h
init.c
iolog.c
libfio.c
rate-submit.c
stat.c
steadystate.c
verify.c
zbd.c

index 975ef48938c2badc50bed84d276ffc5c8f348f1e..35d7cb62e1ec2c004c95d62d0e1f977d7f02be8c 100644 (file)
--- 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) {
index 8214a786b04800a6848a706437a77aafa6a27c3e..58ad94c08f6ec5a0d51f9b54eaaaa689807c9777 100644 (file)
--- 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)
index 054aa8001ad1dafc685104e0a65d92d364329d06..b875a15ad46106d66ea3c4fd916adc6f6201ac57 100644 (file)
@@ -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 6017ca3102eb3b5795915a676e1140728b72579c..5269a0d7619333a034afa360ce50c97d81c62dec 100644 (file)
--- 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 09c441491be9a41221042d6d837038adb55d0100..dcd29be3f1f6d63484f621921219b1529c1857dd 100644 (file)
--- 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 78c6c803513b76fc5e861a31901140f9deed873e..7ae8f23de3be82233bee37801d30a4fbbe40914a 100644 (file)
--- 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 ea7796320d889d3e5310165d153f8077579938de..71c19bf7f369ce16751ec61c378d8569f2892a21 100644 (file)
--- 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)
index ac5219744e3dc41906c3ac16a25b6e1d24fc8d74..7ed1c2c626069a6f494e7ab11b8823231378922b 100644 (file)
--- 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;
 
index 3cc17eaa560304b48fc2ec07f163b31fb204b9db..46926c63f07dfced96a542aab6d4c90e1c9cbb4d 100644 (file)
@@ -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 b963973a5824c09663917e994bda0a7f6cb21145..024387778ae516ed97243ee31f0029f41f552497 100644 (file)
--- 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;
index ad19318c2a23f50cda50f6aef7927e4f0adde022..a78cecc41c5ce9d68d09f13111c374328987ea29 100644 (file)
@@ -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));
index ddfadcc87383ba88d6bbb4f6ed5817511f704490..8758942faf41f18881dc1926a51a8af8007a94e3 100644 (file)
--- 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 d6f8f800e3130204c476876b1884d9f3e8508056..f335b891150372f313ef37a52b6fbfd1960df22f 100644 (file)
--- 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) {