block: drop the cached plug time when blk_add_rq_to_plug() flushes
Subsystems (2)
PATCH 1/1 block: drop the cached plug time when blk_add_rq_to_plug() flushes
blk_time_get_ns() caches the current time in the task's plug. The idea is that the cache lives for one plug and is dropped when the plug is flushed. __blk_flush_plug() and finish_task_switch() do that.
blk_add_rq_to_plug() also flushes, when the plug has too many requests or the last request is at least BLK_PLUG_FLUSH_SIZE. But it calls blk_mq_flush_plug_list() directly and never drops the cached time. So a task that keeps submitting without sleeping stamps every request after that with the time first cached in the plug. start_time_ns and io_start_time_ns are stale and the disk stats charge each request for the whole time since the plug began.
Drop the cached time after the flush, same as __blk_flush_plug() does.
--- block/blk-mq.c | 1 + 1 file changed, 1 insertion(+)
block/blk-mq.c +1 -0
@@ -1384,6 +1384,7 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq) (!blk_queue_nomerges(rq->q) && blk_rq_bytes(last) >= BLK_PLUG_FLUSH_SIZE)) {blk_mq_flush_plug_list (plug, false); +blk_plug_invalidate_ts (); last =NULL ;trace_block_plug (rq->q); }
---
base-commit: 551c722f40809618230001baccf219193e22fc5a
change-id: 20260930-blk-plug-ts-flush-365cde9630d8
Signature · 2 lines
Best regards, Vasileios Almpanis Software Developer, Virtuozzo.
Quoted 12 lines · Vasileios Almpanis
blk_time_get_ns()caches the current time in the task's plug. The idea is that the cache lives for one plug and is dropped when the plug is flushed.__blk_flush_plug()andfinish_task_switch()do that.
blk_add_rq_to_plug()also flushes, when the plug has too many requests or the last request is at leastBLK_PLUG_FLUSH_SIZE. But it callsblk_mq_flush_plug_list()directly and never drops the cached time. So a task that keeps submitting without sleeping stamps every request after that with the time first cached in the plug.start_time_nsandio_start_time_nsare stale and the disk stats charge each request for the whole time since the plug began.
Quoted 1 line
[...]
Applied, thanks!
[1/1] block: drop the cached plug time when blk_add_rq_to_plug() flushes
commit: e0f2224433b15a57125d6ac5d46182f99c6c9d08
Best regards,
Signature · 1 line
Jens Axboe