]> Git Repo - linux.git/commitdiff
block: fix the problem of io_ticks becoming smaller
authorChunguang Xu <[email protected]>
Mon, 5 Jul 2021 21:47:26 +0000 (05:47 +0800)
committerJens Axboe <[email protected]>
Wed, 7 Jul 2021 12:43:20 +0000 (06:43 -0600)
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 collected before the interruption may be less than part->
stamp. So when this happens, we should do nothing to make io_ticks
more accurate? For kernels less than 5.0, this may cause io_ticks
to become smaller, which in turn may cause abnormal ioutil values.

Signed-off-by: Chunguang Xu <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
block/blk-core.c

index 3eea8d79556561b2b8a457ce56161ccb9cf89c78..04477697ee4b4df8de9edb403ffa45b8286fe345 100644 (file)
@@ -1241,7 +1241,7 @@ static void update_io_ticks(struct block_device *part, unsigned long now,
        unsigned long stamp;
 again:
        stamp = READ_ONCE(part->bd_stamp);
        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);
        }
                if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp))
                        __part_stat_add(part, io_ticks, end ? now - stamp : 1);
        }
This page took 0.057054 seconds and 4 git commands to generate.