From: Niklas Cassel Date: Wed, 15 Dec 2021 12:26:04 +0000 (+0000) Subject: stat: sum sync_stat before reassigning bool first X-Git-Tag: fio-3.29~2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=e86afa536b175a90546e20d7d19f2418ee1bca78;p=fio.git stat: sum sync_stat before reassigning bool first Currently, sum_stat(&dst->sync_stat, &src->sync_stat, first, false) is called after the summing the stats on a per ddir level. The for-loop that sums the stats on a per ddir level will reassign bool first to false when unified_rw_rep is used. This means that the call to sum_stat() for sync_stat will be called with first == false, even when it is the first sync_stat being summed, leading to incorrect sync_stat calculations when unified_rw_rep is used. In order to ensure that sync_stat is not incorrectly affected by the reassignment of first, move the sync_stat summing before the for-loop. Signed-off-by: Niklas Cassel Link: https://lore.kernel.org/r/20211215122557.95600-1-Niklas.Cassel@wdc.com Signed-off-by: Jens Axboe --- diff --git a/stat.c b/stat.c index 7e84058d..ec44c79e 100644 --- a/stat.c +++ b/stat.c @@ -2130,6 +2130,8 @@ void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, { int k, l, m; + sum_stat(&dst->sync_stat, &src->sync_stat, first, false); + for (l = 0; l < DDIR_RWDIR_CNT; l++) { if (!(dst->unified_rw_rep == UNIFIED_MIXED)) { sum_stat(&dst->clat_stat[l], &src->clat_stat[l], first, false); @@ -2166,7 +2168,6 @@ void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, } } - sum_stat(&dst->sync_stat, &src->sync_stat, first, false); dst->usr_time += src->usr_time; dst->sys_time += src->sys_time; dst->ctx += src->ctx;