The following changes since commit a87ea1a869595ca57052e7645431a397d3c7d5ac: Merge branch 'evelu-peak' of https://github.com/ErwanAliasr1/fio (2021-10-25 12:38:35 -0600) are available in the Git repository at: git://git.kernel.dk/fio.git master for you to fetch changes up to 6619fc32c413c4ff3a24c819037fb9227af3f876: stat: create a init_thread_stat_min_vals() helper (2021-11-08 06:24:48 -0700) ---------------------------------------------------------------- Niklas Cassel (1): stat: create a init_thread_stat_min_vals() helper init.c | 11 +---------- stat.c | 66 +++++++++++++++++++++--------------------------------------------- stat.h | 1 + 3 files changed, 23 insertions(+), 55 deletions(-) --- Diff of recent changes: diff --git a/init.c b/init.c index ec1a2cac..5f069d9a 100644 --- a/init.c +++ b/init.c @@ -1548,16 +1548,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, memcpy(td->ts.percentile_list, o->percentile_list, sizeof(o->percentile_list)); td->ts.sig_figs = o->sig_figs; - for (i = 0; i < DDIR_RWDIR_CNT; i++) { - td->ts.clat_stat[i].min_val = ULONG_MAX; - td->ts.slat_stat[i].min_val = ULONG_MAX; - td->ts.lat_stat[i].min_val = ULONG_MAX; - td->ts.bw_stat[i].min_val = ULONG_MAX; - td->ts.iops_stat[i].min_val = ULONG_MAX; - td->ts.clat_high_prio_stat[i].min_val = ULONG_MAX; - td->ts.clat_low_prio_stat[i].min_val = ULONG_MAX; - } - td->ts.sync_stat.min_val = ULONG_MAX; + init_thread_stat_min_vals(&td->ts); td->ddir_seq_nr = o->ddir_seq_nr; if ((o->stonewall || o->new_group) && prev_group_jobs) { diff --git a/stat.c b/stat.c index 30f9b5c1..cd35b114 100644 --- a/stat.c +++ b/stat.c @@ -483,22 +483,13 @@ static void show_mixed_ddir_status(struct group_run_stats *rs, struct thread_sta struct thread_stat *ts_lcl; int i2p; - int ddir = 0, i; + int ddir = 0; /* Handle aggregation of Reads (ddir = 0), Writes (ddir = 1), and Trims (ddir = 2) */ ts_lcl = malloc(sizeof(struct thread_stat)); memset((void *)ts_lcl, 0, sizeof(struct thread_stat)); ts_lcl->unified_rw_rep = UNIFIED_MIXED; /* calculate mixed stats */ - for (i = 0; i < DDIR_RWDIR_CNT; i++) { - ts_lcl->clat_stat[i].min_val = ULONG_MAX; - ts_lcl->slat_stat[i].min_val = ULONG_MAX; - ts_lcl->lat_stat[i].min_val = ULONG_MAX; - ts_lcl->bw_stat[i].min_val = ULONG_MAX; - ts_lcl->iops_stat[i].min_val = ULONG_MAX; - ts_lcl->clat_high_prio_stat[i].min_val = ULONG_MAX; - ts_lcl->clat_low_prio_stat[i].min_val = ULONG_MAX; - } - ts_lcl->sync_stat.min_val = ULONG_MAX; + init_thread_stat_min_vals(ts_lcl); sum_thread_stats(ts_lcl, ts, 1); @@ -1466,22 +1457,12 @@ static void show_mixed_ddir_status_terse(struct thread_stat *ts, int ver, struct buf_output *out) { struct thread_stat *ts_lcl; - int i; /* Handle aggregation of Reads (ddir = 0), Writes (ddir = 1), and Trims (ddir = 2) */ ts_lcl = malloc(sizeof(struct thread_stat)); memset((void *)ts_lcl, 0, sizeof(struct thread_stat)); ts_lcl->unified_rw_rep = UNIFIED_MIXED; /* calculate mixed stats */ - for (i = 0; i < DDIR_RWDIR_CNT; i++) { - ts_lcl->clat_stat[i].min_val = ULONG_MAX; - ts_lcl->slat_stat[i].min_val = ULONG_MAX; - ts_lcl->lat_stat[i].min_val = ULONG_MAX; - ts_lcl->bw_stat[i].min_val = ULONG_MAX; - ts_lcl->iops_stat[i].min_val = ULONG_MAX; - ts_lcl->clat_high_prio_stat[i].min_val = ULONG_MAX; - ts_lcl->clat_low_prio_stat[i].min_val = ULONG_MAX; - } - ts_lcl->sync_stat.min_val = ULONG_MAX; + init_thread_stat_min_vals(ts_lcl); ts_lcl->lat_percentiles = ts->lat_percentiles; ts_lcl->clat_percentiles = ts->clat_percentiles; ts_lcl->slat_percentiles = ts->slat_percentiles; @@ -1668,22 +1649,12 @@ static void add_mixed_ddir_status_json(struct thread_stat *ts, struct group_run_stats *rs, struct json_object *parent) { struct thread_stat *ts_lcl; - int i; /* Handle aggregation of Reads (ddir = 0), Writes (ddir = 1), and Trims (ddir = 2) */ ts_lcl = malloc(sizeof(struct thread_stat)); memset((void *)ts_lcl, 0, sizeof(struct thread_stat)); ts_lcl->unified_rw_rep = UNIFIED_MIXED; /* calculate mixed stats */ - for (i = 0; i < DDIR_RWDIR_CNT; i++) { - ts_lcl->clat_stat[i].min_val = ULONG_MAX; - ts_lcl->slat_stat[i].min_val = ULONG_MAX; - ts_lcl->lat_stat[i].min_val = ULONG_MAX; - ts_lcl->bw_stat[i].min_val = ULONG_MAX; - ts_lcl->iops_stat[i].min_val = ULONG_MAX; - ts_lcl->clat_high_prio_stat[i].min_val = ULONG_MAX; - ts_lcl->clat_low_prio_stat[i].min_val = ULONG_MAX; - } - ts_lcl->sync_stat.min_val = ULONG_MAX; + init_thread_stat_min_vals(ts_lcl); ts_lcl->lat_percentiles = ts->lat_percentiles; ts_lcl->clat_percentiles = ts->clat_percentiles; ts_lcl->slat_percentiles = ts->slat_percentiles; @@ -2270,22 +2241,27 @@ void init_group_run_stat(struct group_run_stats *gs) gs->min_bw[i] = gs->min_run[i] = ~0UL; } -void init_thread_stat(struct thread_stat *ts) +void init_thread_stat_min_vals(struct thread_stat *ts) { - int j; + int i; + for (i = 0; i < DDIR_RWDIR_CNT; i++) { + ts->clat_stat[i].min_val = ULONG_MAX; + ts->slat_stat[i].min_val = ULONG_MAX; + ts->lat_stat[i].min_val = ULONG_MAX; + ts->bw_stat[i].min_val = ULONG_MAX; + ts->iops_stat[i].min_val = ULONG_MAX; + ts->clat_high_prio_stat[i].min_val = ULONG_MAX; + ts->clat_low_prio_stat[i].min_val = ULONG_MAX; + } + ts->sync_stat.min_val = ULONG_MAX; +} + +void init_thread_stat(struct thread_stat *ts) +{ memset(ts, 0, sizeof(*ts)); - for (j = 0; j < DDIR_RWDIR_CNT; j++) { - ts->lat_stat[j].min_val = -1UL; - ts->clat_stat[j].min_val = -1UL; - ts->slat_stat[j].min_val = -1UL; - ts->bw_stat[j].min_val = -1UL; - ts->iops_stat[j].min_val = -1UL; - ts->clat_high_prio_stat[j].min_val = -1UL; - ts->clat_low_prio_stat[j].min_val = -1UL; - } - ts->sync_stat.min_val = -1UL; + init_thread_stat_min_vals(ts); ts->groupid = -1; } diff --git a/stat.h b/stat.h index a06237e7..9ef8caa4 100644 --- a/stat.h +++ b/stat.h @@ -327,6 +327,7 @@ extern void show_running_run_stats(void); extern void check_for_running_stats(void); extern void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, bool first); extern void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src); +extern void init_thread_stat_min_vals(struct thread_stat *ts); extern void init_thread_stat(struct thread_stat *ts); extern void init_group_run_stat(struct group_run_stats *gs); extern void eta_to_str(char *str, unsigned long eta_sec);