All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] block: fix the problem of io_ticks becoming smaller
@ 2021-07-05 13:38 brookxu
  0 siblings, 0 replies; only message in thread
From: brookxu @ 2021-07-05 13:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel

From: Chunguang Xu <brookxu@tencent.com>

Before the wraparound occurs, the value of io_ticks should
be monotonically increasing, but we sometimes find that io_ticks
will become smaller, which leads to abnormal values in monitoring
tools. On the IO submission path, blk_account_io_start() may
interrupt the system interruption. When the interruption returns,
the value of part->stamp may have been updated by other cores, so
the time value now collected before the interruption may be less
than part->stamp, and then make the calculated value of io_ticks
become smaller. Therefore, when now is less than part->stamp, we
should do nothing.

v2: sorry, fix compile error due to the missed ')'

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
---
 block/blk-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 514838c..bbf56ae 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1243,7 +1243,7 @@ static void update_io_ticks(struct block_device *part, unsigned long now,
 	unsigned long stamp;
 again:
 	stamp = READ_ONCE(part->bd_stamp);
-	if (unlikely(stamp != now)) {
+	if (unlikely(time_after(now, stamp))) {
 		if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp))
 			__part_stat_add(part, io_ticks, end ? now - stamp : 1);
 	}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-05 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 13:38 [PATCH v2] block: fix the problem of io_ticks becoming smaller brookxu

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.