From: "yukuai (C)" <yukuai3@huawei.com>
To: Jan Kara <jack@suse.cz>
Cc: <paolo.valente@linaro.org>, <axboe@kernel.dk>,
<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<yi.zhang@huawei.com>
Subject: Re: [PATCH -next 2/2] block, bfq: make bfq_has_work() more accurate
Date: Fri, 13 May 2022 09:08:13 +0800 [thread overview]
Message-ID: <ef85c1de-21d3-e528-da79-351bc93b9193@huawei.com> (raw)
In-Reply-To: <20220512171025.blstxod6aphulctm@quack3.lan>
在 2022/05/13 1:10, Jan Kara 写道:
> On Thu 12-05-22 09:30:16, yukuai (C) wrote:
>> On 2022/05/11 22:08, Jan Kara wrote:
>>> On Tue 10-05-22 21:16:29, Yu Kuai wrote:
>>>> bfq_has_work() is using busy_queues currently, which is not accurate
>>>> because bfq_queue is busy doesn't represent that it has requests. Since
>>>> bfqd aready has a counter 'queued' to record how many requests are in
>>>> bfq, use it instead of busy_queues.
>>>>
>>>> Noted that bfq_has_work() can be called with 'bfqd->lock' held, thus the
>>>> lock can't be held in bfq_has_work() to protect 'bfqd->queued'.
>>>>
>>>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>>>
>>> So did you find this causing any real problem? Because bfq queue is
>>> accounted among busy queues once bfq_add_bfqq_busy() is called. And that
>>> happens once a new request is inserted into the queue so it should be very
>>> similar to bfqd->queued.
>>>
>>> Honza
>>
>> Hi,
>>
>> The related problem is described here:
>>
>> https://lore.kernel.org/all/20220510112302.1215092-1-yukuai3@huawei.com/
>>
>> The root cause of the panic is a linux-block problem, however, it can
>> be bypassed if bfq_has_work() is accurate. On the other hand,
>> unnecessary run_work will be triggered if bfqq stays busy:
>>
>> __blk_mq_run_hw_queue
>> __blk_mq_sched_dispatch_requests
>> __blk_mq_do_dispatch_sched
>> if (!bfq_has_work())
>> break;
>> blk_mq_delay_run_hw_queues -> run again after 3ms
>
> Ah, I see. So it is the other way around than I thought. Due to idling
> bfq_tot_busy_queues() can be greater than 0 even if there are no requests
> to dispatch. Indeed. OK, the patch makes sense. But please use WRITE_ONCE
> for the updates of bfqd->queued. Otherwise the READ_ONCE does not really
> make sense (it can still result in some bogus value due to compiler
> optimizations on the write side).
Thanks for you adivce, I'll send a new version.
Kuai
prev parent reply other threads:[~2022-05-13 1:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 13:16 [PATCH -next 0/2] block, bfq: make bfq_has_work() more accurate Yu Kuai
2022-05-10 13:16 ` [PATCH -next 1/2] block, bfq: protect 'bfqd->queued' by 'bfqd->lock' Yu Kuai
2022-05-11 13:52 ` Jan Kara
2022-05-10 13:16 ` [PATCH -next 2/2] block, bfq: make bfq_has_work() more accurate Yu Kuai
2022-05-11 14:08 ` Jan Kara
2022-05-12 1:30 ` yukuai (C)
2022-05-12 17:10 ` Jan Kara
2022-05-13 1:08 ` yukuai (C) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef85c1de-21d3-e528-da79-351bc93b9193@huawei.com \
--to=yukuai3@huawei.com \
--cc=axboe@kernel.dk \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paolo.valente@linaro.org \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).