All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] stat: sum sync_stat before reassigning bool first
@ 2021-12-15 12:26 Niklas Cassel
  2021-12-15 15:45 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Niklas Cassel @ 2021-12-15 12:26 UTC (permalink / raw)
  To: axboe; +Cc: fio, Niklas Cassel

From: Niklas Cassel <niklas.cassel@wdc.com>

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 <niklas.cassel@wdc.com>
---
 stat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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;
-- 
2.33.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] stat: sum sync_stat before reassigning bool first
  2021-12-15 12:26 [PATCH] stat: sum sync_stat before reassigning bool first Niklas Cassel
@ 2021-12-15 15:45 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-12-15 15:45 UTC (permalink / raw)
  To: Niklas Cassel; +Cc: fio

On Wed, 15 Dec 2021 12:26:04 +0000, Niklas Cassel wrote:
> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> 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.
> 
> [...]

Applied, thanks!

[1/1] stat: sum sync_stat before reassigning bool first
      commit: e86afa536b175a90546e20d7d19f2418ee1bca78

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-15 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 12:26 [PATCH] stat: sum sync_stat before reassigning bool first Niklas Cassel
2021-12-15 15:45 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.