X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=stat.c;h=eb40bd7f44bb7c4c40c84fc5c70fa9648f996772;hb=e82ec77644f4fb7eccb3441485762c1c1c574b2f;hp=2cf11947d99adac33ef3195a08f8039d3399492b;hpb=b2ed1c4a07c6afc4ae90482ca5f70026a4bc34e6;p=fio.git diff --git a/stat.c b/stat.c index 2cf11947..eb40bd7f 100644 --- a/stat.c +++ b/stat.c @@ -414,6 +414,18 @@ static void display_lat(const char *name, unsigned long long min, free(maxp); } +static double convert_agg_kbytes_percent(struct group_run_stats *rs, int ddir, int mean) +{ + double p_of_agg = 100.0; + if (rs && rs->agg[ddir] > 1024) { + p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024.0); + + if (p_of_agg > 100.0) + p_of_agg = 100.0; + } + return p_of_agg; +} + static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, int ddir, struct buf_output *out) { @@ -551,11 +563,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, else bw_str = "kB"; - if (rs->agg[ddir]) { - p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); - if (p_of_agg > 100.0) - p_of_agg = 100.0; - } + p_of_agg = convert_agg_kbytes_percent(rs, ddir, mean); if (rs->unit_base == 1) { min *= 8.0; @@ -1070,12 +1078,10 @@ static void show_thread_status_normal(struct thread_stat *ts, if (strlen(ts->description)) log_buf(out, " Description : [%s]\n", ts->description); - if (ts->io_bytes[DDIR_READ]) - show_ddir_status(rs, ts, DDIR_READ, out); - if (ts->io_bytes[DDIR_WRITE]) - show_ddir_status(rs, ts, DDIR_WRITE, out); - if (ts->io_bytes[DDIR_TRIM]) - show_ddir_status(rs, ts, DDIR_TRIM, out); + for_each_rw_ddir(ddir) { + if (ts->io_bytes[ddir]) + show_ddir_status(rs, ts, ddir, out); + } show_latencies(ts, out); @@ -1376,11 +1382,7 @@ static void add_ddir_status_json(struct thread_stat *ts, } if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { - if (rs->agg[ddir]) { - p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); - if (p_of_agg > 100.0) - p_of_agg = 100.0; - } + p_of_agg = convert_agg_kbytes_percent(rs, ddir, mean); } else { min = max = 0; p_of_agg = mean = dev = 0.0; @@ -1506,12 +1508,8 @@ static void json_add_job_opts(struct json_object *root, const char *name, json_object_add_value_object(root, name, dir_object); flist_for_each(entry, opt_list) { - const char *pos = ""; - p = flist_entry(entry, struct print_option, list); - if (p->value) - pos = p->value; - json_object_add_value_string(dir_object, p->name, pos); + json_object_add_value_string(dir_object, p->name, p->value); } } @@ -2301,7 +2299,7 @@ void __show_run_stats(void) free(opt_lists); } -void __show_running_run_stats(void) +int __show_running_run_stats(void) { struct thread_data *td; unsigned long long *rt; @@ -2315,9 +2313,9 @@ void __show_running_run_stats(void) for_each_td(td, i) { td->update_rusage = 1; - td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ]; - td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE]; - td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM]; + for_each_rw_ddir(ddir) { + td->ts.io_bytes[ddir] = td->io_bytes[ddir]; + } td->ts.total_run_time = mtime_since(&td->epoch, &ts); rt[i] = mtime_since(&td->start, &ts); @@ -2352,6 +2350,8 @@ void __show_running_run_stats(void) free(rt); fio_sem_up(stat_sem); + + return 0; } static bool status_file_disabled; @@ -3134,3 +3134,4 @@ uint32_t *io_u_block_info(struct thread_data *td, struct io_u *io_u) assert(idx < td->ts.nr_block_infos); return info; } +