block: fix the problem of io_ticks becoming smaller
PATCH v2 1/1 block: fix the problem of io_ticks becoming smaller
From: Chunguang Xu <[email protected]>
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 <[email protected]>
--- block/blk-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-core.c +1 -1
@@ -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 ); }
Signature · 1 line
1.8.3.1