From 2df7f0812fa7aa3bd8e700aeb0004f8eb522a76a Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Thu, 3 Feb 2022 19:28:25 +0000 Subject: [PATCH] stat: save the default ioprio in struct thread_stat To be able to report clat stats on a per priority granularity (instead of only high/low priority), we need to be able to get the priority value that was used for the stats in clat_stat. When a thread is using a single priority (e.g. option prio/prioclass is used (without any cmdprio options)), all the clat stats for this thread will be stored in clat_stat. The problem with this is sum_thread_stats() does not know the priority value that corresponds to the stats stored in clat_stat. Since we cannot access td->ioprio from sum_thread_stats(), simply mirror td->ioprio inside struct thread_stat. This way, sum_thread_stats() will be able to reuse the global clat stats in clat_stat, without the need to duplicate the data for per priority stats, in the case where there is only a single priority in use. Server version is intentionally not incremented, as it will be incremented in a later patch in the series. No need to bump it multiple times for the same patch series. Signed-off-by: Niklas Cassel Reviewed-by: Damien Le Moal Link: https://lore.kernel.org/r/20220203192814.18552-4-Niklas.Cassel@wdc.com Signed-off-by: Jens Axboe --- backend.c | 1 + client.c | 1 + server.c | 1 + stat.h | 3 +++ 4 files changed, 6 insertions(+) diff --git a/backend.c b/backend.c index f7398b23..abaaeeb8 100644 --- a/backend.c +++ b/backend.c @@ -1786,6 +1786,7 @@ static void *thread_main(void *data) goto err; } td->ioprio = ioprio_value(o->ioprio_class, o->ioprio); + td->ts.ioprio = td->ioprio; } if (td_io_init(td)) diff --git a/client.c b/client.c index 7a4bfc0d..83be6a57 100644 --- a/client.c +++ b/client.c @@ -954,6 +954,7 @@ static void convert_ts(struct thread_stat *dst, struct thread_stat *src) dst->pid = le32_to_cpu(src->pid); dst->members = le32_to_cpu(src->members); dst->unified_rw_rep = le32_to_cpu(src->unified_rw_rep); + dst->ioprio = le32_to_cpu(src->ioprio); for (i = 0; i < DDIR_RWDIR_CNT; i++) { convert_io_stat(&dst->clat_stat[i], &src->clat_stat[i]); diff --git a/server.c b/server.c index cc4cbc2a..6905df90 100644 --- a/server.c +++ b/server.c @@ -1703,6 +1703,7 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) p.ts.pid = cpu_to_le32(ts->pid); p.ts.members = cpu_to_le32(ts->members); p.ts.unified_rw_rep = cpu_to_le32(ts->unified_rw_rep); + p.ts.ioprio = cpu_to_le32(ts->ioprio); for (i = 0; i < DDIR_RWDIR_CNT; i++) { convert_io_stat(&p.ts.clat_stat[i], &ts->clat_stat[i]); diff --git a/stat.h b/stat.h index 15ca4eff..3ce821a7 100644 --- a/stat.h +++ b/stat.h @@ -252,6 +252,9 @@ struct thread_stat { fio_fp64_t ss_deviation; fio_fp64_t ss_criterion; + /* A mirror of td->ioprio. */ + uint32_t ioprio; + uint64_t io_u_plat_high_prio[DDIR_RWDIR_CNT][FIO_IO_U_PLAT_NR] __attribute__((aligned(8)));; uint64_t io_u_plat_low_prio[DDIR_RWDIR_CNT][FIO_IO_U_PLAT_NR]; struct io_stat clat_high_prio_stat[DDIR_RWDIR_CNT] __attribute__((aligned(8))); -- 2.25.1