Re: [PATCH] blk-mq: fix incorrect rq start_time_ns and alloc_time_ns after throttled

From: Tejun Heo
Date: Mon Jun 05 2023 - 14:31:38 EST


Hello,

On Thu, Jun 01, 2023 at 01:39:19PM +0800, chengming.zhou@xxxxxxxxx wrote:
> From: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx>
>
> iocost rely on rq start_time_ns and alloc_time_ns to tell the saturation
> state of the block device.
>
> If any qos ->throttle() end up blocking, the cached rq start_time_ns and
> alloc_time_ns will include its throtted time, which can confuse its user.

I don't follow. rq_qos_throttle() happens before a request is allocated, so
whether ->throttle() blocks or not doesn't affect alloc_time_ns or
start_time_ns.

> This patch add nr_flush counter in blk_plug, so we can tell if the task
> has throttled in any qos ->throttle(), in which case we need to correct
> the rq start_time_ns and alloc_time_ns.
>
> Another solution may be make rq_qos_throttle() return bool to indicate
> if it has throttled in any qos ->throttle(). But this need more changes.
>
> Signed-off-by: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx>

Depending on the flush behavior and adjusting alloc_time_ns seems fragile to
me and will likely confuse other users of alloc_time_ns too.

Maybe I'm misunderstanding the problem you're describing. Can you give a
concrete example of how the current code would misbehave?

Thanks.

--
tejun