* [Devel] [PATCH hci-8.1] ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes
@ 2026-10-01 15:23 Vasileios Almpanis
2026-10-01 15:28 ` no-reply
2026-10-06 15:16 ` Konstantin Khorenko
0 siblings, 2 replies; 3+ messages in thread
From: Vasileios Almpanis @ 2026-10-01 15:23 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: devel
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.
Fixes: da4c8c3d0975 ("block: cache current nsec time in struct blk_plug")
Cc: stable@vger.kernel.org
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Link: https://patch.msgid.link/20260930-blk-plug-ts-flush-v1-1-bf8ca7bc5cd6@virtuozzo.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit e0f2224433b15a57125d6ac5d46182f99c6c9d08)
Rebase note: the commit is in the block tree (axboe/linux.git) and not
in mainline yet. In this kernel blk_plug_invalidate_ts() still takes
the task as an argument, so pass current.
https://virtuozzo.atlassian.net/browse/VSTOR-147945
Feature: fix ms/block
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
block/blk-mq.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 14d29634c531..12ae5928a768 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1387,6 +1387,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(current);
last = NULL;
trace_block_plug(rq->q);
}
---
base-commit: dcd9000e6b239a27d1450a9ac7927a41596733e8
change-id: 20261001-blk-flush-ts-plug-02408e49c934
--
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Devel] [PATCH hci-8.1] ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes
2026-10-01 15:23 [Devel] [PATCH hci-8.1] ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes Vasileios Almpanis
@ 2026-10-01 15:28 ` no-reply
2026-10-06 15:16 ` Konstantin Khorenko
1 sibling, 0 replies; 3+ messages in thread
From: no-reply @ 2026-10-01 15:28 UTC (permalink / raw)
To: Konstantin Khorenko, Vasileios Almpanis; +Cc: devel
> 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.
>
> Fixes: da4c8c3d0975 ("block: cache current nsec time in struct blk_plug")
> Cc: stable@vger.kernel.org
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
> Link: https://patch.msgid.link/20260930-blk-plug-ts-flush-v1-1-bf8ca7bc5cd6@virtuozzo.com
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>
> (cherry picked from commit e0f2224433b15a57125d6ac5d46182f99c6c9d08)
>
> Rebase note: the commit is in the block tree (axboe/linux.git) and not
> in mainline yet. In this kernel blk_plug_invalidate_ts() still takes
> the task as an argument, so pass current.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-147945
> Feature: fix ms/block
>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261001-blk-flush-ts-plug-v1-1-22d9a1f0c9bf@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Devel] [PATCH hci-8.1] ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes
2026-10-01 15:23 [Devel] [PATCH hci-8.1] ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes Vasileios Almpanis
2026-10-01 15:28 ` no-reply
@ 2026-10-06 15:16 ` Konstantin Khorenko
1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Khorenko @ 2026-10-06 15:16 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: devel
On Thu, 01 Oct 2026 15:23:59 +0000, Vasileios Almpanis wrote:
> ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes
Applied to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.9.vz10, thanks!
[1/1] ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/7e93484a0858
--
Konstantin Khorenko <khorenko@virtuozzo.com>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-06 15:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 15:23 [Devel] [PATCH hci-8.1] ms/block: drop the cached plug time when blk_add_rq_to_plug() flushes Vasileios Almpanis
2026-10-01 15:28 ` no-reply
2026-10-06 15:16 ` Konstantin Khorenko
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.