aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-02-28 17:37:17 -0700
committerJens Axboe <axboe@kernel.dk>2023-02-28 17:37:17 -0700
commitb3ffdf82604b0417666f2a17be81f819807e189e (patch)
tree9adfb4ee487a684eec96b59940d1d3841827cc59
parent5a37211238f995657c50e5d0ea6e5e22ff3ca69e (diff)
downloadfio-for-each-td.tar.gz
Test for_each_td()for-each-td
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--backend.c9
-rw-r--r--dedupe.c1
-rw-r--r--engines/libblkio.c1
-rw-r--r--eta.c11
-rw-r--r--fio.h8
-rw-r--r--init.c2
-rw-r--r--iolog.c1
-rw-r--r--libfio.c2
-rw-r--r--rate-submit.c1
-rw-r--r--stat.c4
-rw-r--r--steadystate.c4
-rw-r--r--verify.c1
-rw-r--r--zbd.c5
13 files changed, 14 insertions, 36 deletions
diff --git a/backend.c b/backend.c
index 975ef4893..35d7cb62e 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 8214a786b..58ad94c08 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 054aa8001..b875a15ad 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 6017ca310..5269a0d76 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 09c441491..dcd29be3f 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 78c6c8035..7ae8f23de 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 ea7796320..71c19bf7f 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 ac5219744..7ed1c2c62 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 3cc17eaa5..46926c63f 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 b963973a5..024387778 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 ad19318c2..a78cecc41 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 ddfadcc87..8758942fa 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 d6f8f800e..f335b8911 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) {