The following changes since commit 4ad09b569a2689b3b67744eaccd378d013eb82a7: t/io_uring: abstract out init_new_io() helper (2023-03-14 14:03:32 -0600) are available in the Git repository at: git://git.kernel.dk/fio.git master for you to fetch changes up to a967e54d34afe3bb10cd521d78bcaea2dd8c7cdc: stat: Fix ioprio print (2023-03-15 19:18:47 -0400) ---------------------------------------------------------------- Damien Le Moal (1): stat: Fix ioprio print os/os-dragonfly.h | 2 ++ os/os-linux.h | 3 ++ os/os.h | 2 ++ stat.c | 85 +++++++++++++++++++++++++++++-------------------------- 4 files changed, 52 insertions(+), 40 deletions(-) --- Diff of recent changes: diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h index 5b37a37e..bde39101 100644 --- a/os/os-dragonfly.h +++ b/os/os-dragonfly.h @@ -175,6 +175,8 @@ static inline int fio_getaffinity(int pid, os_cpu_mask_t *mask) #define ioprio_set(which, who, ioprio_class, ioprio) \ ioprio_set(which, who, ioprio) +#define ioprio(ioprio) (ioprio) + static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) { struct partinfo pi; diff --git a/os/os-linux.h b/os/os-linux.h index 7a78b42d..2f9f7e79 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -153,6 +153,9 @@ static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio) ioprio_value(ioprio_class, ioprio)); } +#define ioprio_class(ioprio) ((ioprio) >> IOPRIO_CLASS_SHIFT) +#define ioprio(ioprio) ((ioprio) & 7) + #ifndef CONFIG_HAVE_GETTID static inline int gettid(void) { diff --git a/os/os.h b/os/os.h index ebaf8af5..036fc233 100644 --- a/os/os.h +++ b/os/os.h @@ -116,12 +116,14 @@ extern int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu); #endif #ifndef FIO_HAVE_IOPRIO_CLASS +#define ioprio_class(prio) 0 #define ioprio_value_is_class_rt(prio) (false) #define IOPRIO_MIN_PRIO_CLASS 0 #define IOPRIO_MAX_PRIO_CLASS 0 #endif #ifndef FIO_HAVE_IOPRIO #define ioprio_value(prioclass, prio) (0) +#define ioprio(ioprio) 0 #define ioprio_set(which, who, prioclass, prio) (0) #define IOPRIO_MIN_PRIO 0 #define IOPRIO_MAX_PRIO 0 diff --git a/stat.c b/stat.c index e0a2dcc6..56be330b 100644 --- a/stat.c +++ b/stat.c @@ -590,17 +590,18 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, /* Only print per prio stats if there are >= 2 prios with samples */ if (get_nr_prios_with_samples(ts, ddir) >= 2) { for (i = 0; i < ts->nr_clat_prio[ddir]; i++) { - if (calc_lat(&ts->clat_prio[ddir][i].clat_stat, &min, - &max, &mean, &dev)) { - char buf[64]; + char buf[64]; - snprintf(buf, sizeof(buf), - "%s prio %u/%u", - clat_type, - ts->clat_prio[ddir][i].ioprio >> 13, - ts->clat_prio[ddir][i].ioprio & 7); - display_lat(buf, min, max, mean, dev, out); - } + if (!calc_lat(&ts->clat_prio[ddir][i].clat_stat, &min, + &max, &mean, &dev)) + continue; + + snprintf(buf, sizeof(buf), + "%s prio %u/%u", + clat_type, + ioprio_class(ts->clat_prio[ddir][i].ioprio), + ioprio(ts->clat_prio[ddir][i].ioprio)); + display_lat(buf, min, max, mean, dev, out); } } @@ -632,20 +633,22 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, /* Only print per prio stats if there are >= 2 prios with samples */ if (get_nr_prios_with_samples(ts, ddir) >= 2) { for (i = 0; i < ts->nr_clat_prio[ddir]; i++) { - uint64_t prio_samples = ts->clat_prio[ddir][i].clat_stat.samples; - - if (prio_samples > 0) { - snprintf(prio_name, sizeof(prio_name), - "%s prio %u/%u (%.2f%% of IOs)", - clat_type, - ts->clat_prio[ddir][i].ioprio >> 13, - ts->clat_prio[ddir][i].ioprio & 7, - 100. * (double) prio_samples / (double) samples); - show_clat_percentiles(ts->clat_prio[ddir][i].io_u_plat, - prio_samples, ts->percentile_list, - ts->percentile_precision, - prio_name, out); - } + uint64_t prio_samples = + ts->clat_prio[ddir][i].clat_stat.samples; + + if (!prio_samples) + continue; + + snprintf(prio_name, sizeof(prio_name), + "%s prio %u/%u (%.2f%% of IOs)", + clat_type, + ioprio_class(ts->clat_prio[ddir][i].ioprio), + ioprio(ts->clat_prio[ddir][i].ioprio), + 100. * (double) prio_samples / (double) samples); + show_clat_percentiles(ts->clat_prio[ddir][i].io_u_plat, + prio_samples, ts->percentile_list, + ts->percentile_precision, + prio_name, out); } } } @@ -1508,22 +1511,24 @@ static void add_ddir_status_json(struct thread_stat *ts, json_object_add_value_array(dir_object, "prios", array); for (i = 0; i < ts->nr_clat_prio[ddir]; i++) { - if (ts->clat_prio[ddir][i].clat_stat.samples > 0) { - struct json_object *obj = json_create_object(); - unsigned long long class, level; - - class = ts->clat_prio[ddir][i].ioprio >> 13; - json_object_add_value_int(obj, "prioclass", class); - level = ts->clat_prio[ddir][i].ioprio & 7; - json_object_add_value_int(obj, "prio", level); - - tmp_object = add_ddir_lat_json(ts, - ts->clat_percentiles | ts->lat_percentiles, - &ts->clat_prio[ddir][i].clat_stat, - ts->clat_prio[ddir][i].io_u_plat); - json_object_add_value_object(obj, obj_name, tmp_object); - json_array_add_value_object(array, obj); - } + struct json_object *obj; + + if (!ts->clat_prio[ddir][i].clat_stat.samples) + continue; + + obj = json_create_object(); + + json_object_add_value_int(obj, "prioclass", + ioprio_class(ts->clat_prio[ddir][i].ioprio)); + json_object_add_value_int(obj, "prio", + ioprio(ts->clat_prio[ddir][i].ioprio)); + + tmp_object = add_ddir_lat_json(ts, + ts->clat_percentiles | ts->lat_percentiles, + &ts->clat_prio[ddir][i].clat_stat, + ts->clat_prio[ddir][i].io_u_plat); + json_object_add_value_object(obj, obj_name, tmp_object); + json_array_add_value_object(array, obj); } }