All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-iocost: account flush sequence latency only once
@ 2026-10-29  9:24 Zhe Liu
  2026-10-29 17:13 ` Tejun Heo
  2026-10-30  1:49 ` Tao Cui
  0 siblings, 2 replies; 3+ messages in thread
From: Zhe Liu @ 2026-10-29  9:24 UTC (permalink / raw)
  To: tj, josef, axboe; +Cc: cgroups, linux-block, linux-kernel, Zhe Liu, stable

A flush sequence with a DATA phase can complete its original request
twice. Both completions invoke ioc_rqos_done(), causing the request to
contribute two latency samples and adding the same queue wait time
twice. This gives such requests disproportionate weight compared to
ordinary writes, distorting the device-wide latency and queue wait
feedback used to adjust iocost's virtual time rate.

Skip requests marked RQF_FLUSH_SEQ in ioc_rqos_done(). The flag is set
when the request enters the flush machinery and is still set when the
data phase completes; blk_flush_restore_request() clears it before the
final completion, so accounting happens only once, after the whole
sequence finishes. The remaining sample covers the request's lifetime
through any postflush, and its queue wait time is accumulated only
once.

Fixes: 7caa47151ab2e ("blkcg: implement blk-iocost")
Cc: stable@vger.kernel.org
Signed-off-by: Zhe Liu <liuzhe1@kylinos.cn>
---
 block/blk-iocost.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 2ae40138e041..601029221e6f 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2868,6 +2868,9 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq)
 	if (!ioc->enabled || !rq->alloc_time_ns || !rq->start_time_ns)
 		return;
 
+	if (rq->rq_flags & RQF_FLUSH_SEQ)
+		return;
+
 	switch (req_op(rq)) {
 	case REQ_OP_READ:
 		pidx = QOS_RLAT;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-iocost: account flush sequence latency only once
  2026-10-29  9:24 [PATCH] blk-iocost: account flush sequence latency only once Zhe Liu
@ 2026-10-29 17:13 ` Tejun Heo
  2026-10-30  1:49 ` Tao Cui
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2026-10-29 17:13 UTC (permalink / raw)
  To: Zhe Liu; +Cc: josef, axboe, cgroups, linux-block, linux-kernel, stable

On Thu, Oct 29, 2026 at 05:24:24PM +0800, Zhe Liu wrote:
> +	if (rq->rq_flags & RQF_FLUSH_SEQ)
> +		return;

Can you please wrap the test in unlikely()?

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

--
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-iocost: account flush sequence latency only once
  2026-10-29  9:24 [PATCH] blk-iocost: account flush sequence latency only once Zhe Liu
  2026-10-29 17:13 ` Tejun Heo
@ 2026-10-30  1:49 ` Tao Cui
  1 sibling, 0 replies; 3+ messages in thread
From: Tao Cui @ 2026-10-30  1:49 UTC (permalink / raw)
  To: Zhe Liu, tj, josef, axboe
  Cc: cui.tao, cgroups, linux-block, linux-kernel, stable

Hi, Zhe

在 2026/10/29 17:24, Zhe Liu 写道:
> A flush sequence with a DATA phase can complete its original request
> twice. Both completions invoke ioc_rqos_done(), causing the request to
> contribute two latency samples and adding the same queue wait time
> twice. This gives such requests disproportionate weight compared to
> ordinary writes, distorting the device-wide latency and queue wait
> feedback used to adjust iocost's virtual time rate.
> 
> Skip requests marked RQF_FLUSH_SEQ in ioc_rqos_done(). The flag is set
> when the request enters the flush machinery and is still set when the
> data phase completes; blk_flush_restore_request() clears it before the
> final completion, so accounting happens only once, after the whole
> sequence finishes. The remaining sample covers the request's lifetime
> through any postflush, and its queue wait time is accumulated only
> once.
> 
> Fixes: 7caa47151ab2e ("blkcg: implement blk-iocost")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhe Liu <liuzhe1@kylinos.cn>
> ---
>  block/blk-iocost.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index 2ae40138e041..601029221e6f 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -2868,6 +2868,9 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq)
>  	if (!ioc->enabled || !rq->alloc_time_ns || !rq->start_time_ns)
>  		return;
>  
> +	if (rq->rq_flags & RQF_FLUSH_SEQ)
> +		return;
> +
>  	switch (req_op(rq)) {
>  	case REQ_OP_READ:
>  		pidx = QOS_RLAT;

Reviewed-by: Tao Cui <cuitao@kylinos.cn>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-30  1:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29  9:24 [PATCH] blk-iocost: account flush sequence latency only once Zhe Liu
2026-10-29 17:13 ` Tejun Heo
2026-10-30  1:49 ` Tao Cui

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.