From: Damien Le Moal <dlemoal@kernel.org>
To: Yu Kuai <yukuai1@huaweicloud.com>,
hare@suse.de, jack@suse.cz, bvanassche@acm.org, tj@kernel.org,
josef@toxicpanda.com, axboe@kernel.dk
Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, yi.zhang@huawei.com,
yangerkun@huawei.com, johnny.chenyi@huawei.com,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH v3 1/5] blk-mq-sched: introduce high level elevator lock
Date: Mon, 11 Aug 2025 13:34:47 +0900 [thread overview]
Message-ID: <5974ead5-2ef1-4887-91f5-422c87c30273@kernel.org> (raw)
In-Reply-To: <f4429faf-65b7-244f-7cf5-18c08ce4964c@huaweicloud.com>
On 8/11/25 13:25, Yu Kuai wrote:
> Hi,
>
> 在 2025/08/11 11:53, Damien Le Moal 写道:
>> On 8/11/25 10:01, Yu Kuai wrote:
>>>>> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
>>>>> index 55a0fd105147..1a2da5edbe13 100644
>>>>> --- a/block/blk-mq-sched.c
>>>>> +++ b/block/blk-mq-sched.c
>>>>> @@ -113,7 +113,14 @@ static int __blk_mq_do_dispatch_sched(struct blk_mq_hw_ctx *hctx)
>>>>> if (budget_token < 0)
>>>>> break;
>>>>>
>>>>> - rq = e->type->ops.dispatch_request(hctx);
>>>>> + if (blk_queue_sq_sched(q)) {
>>>>> + elevator_lock(e);
>>>>> + rq = e->type->ops.dispatch_request(hctx);
>>>>> + elevator_unlock(e);
>>>>
>>>> I do not think this is safe for bfq since bfq uses the irqsave/irqrestore spin
>>>> lock variant. If it is safe, this needs a big comment block explaining why
>>>> and/or the rules regarding the scheduler use of this lock.
>>>
>>> It's correct, however, this patch doesn't change bfq yet, and it's like:
>>>
>>> elevator_lock
>>> spin_lock_irq(&bfqd->lock)
>>> spin_unlock_irq(&bfqd->lock)
>>> elevator_unlock
>>>
>>> Patch 3 remove bfqd->lock and convert this to:
>>>
>>> elevator_lock_irq
>>> elevator_unlock_irq.
>>
>> I do not understand. Since q->elevator->lock is already taken here, without IRQ
>> disabled, how can bfq_dispatch_request method again take this same lock with IRQ
>> disabled ? That cannot possibly work.
>
> Looks like there is still misunderstanding somehow :( After patch 3,
> bfq_dispatch_work doesn't grab any lock, elevator lock is held before
> calling into dispatch method.
>
> Before:
>
> elevator_lock
> bfq_dispatch_request
> spin_lock_irq(&bfqd->lock)
> spin_unlock_irq(&bfqd->lock)
> elevator_unlock
>
> After:
> elevator_lock_irq
> bfq_dispatch_request
> elevator_unlock_irq
Ah, yes, I see it now.
But that is a nasty change that affects *all* schedulers, even those that do not
need to disable IRQs because they are not using the lock in their completion
path, e.g. mq-deadline. So I do not think that is acceptable.
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-08-11 4:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 8:57 [PATCH v3 0/5] blk-mq-sched: support request batch dispatching for sq elevator Yu Kuai
2025-08-06 8:57 ` [PATCH v3 1/5] blk-mq-sched: introduce high level elevator lock Yu Kuai
2025-08-11 0:44 ` Damien Le Moal
2025-08-11 1:01 ` Yu Kuai
2025-08-11 3:53 ` Damien Le Moal
2025-08-11 4:25 ` Yu Kuai
2025-08-11 4:34 ` Damien Le Moal [this message]
2025-08-11 6:17 ` Yu Kuai
2025-08-06 8:57 ` [PATCH v3 2/5] mq-deadline: switch to use " Yu Kuai
2025-08-06 8:57 ` [PATCH v3 3/5] block, bfq: " Yu Kuai
2025-08-06 8:57 ` [PATCH v3 4/5] blk-mq-sched: refactor __blk_mq_do_dispatch_sched() Yu Kuai
2025-08-06 8:57 ` [PATCH v3 5/5] blk-mq-sched: support request batch dispatching for sq elevator Yu Kuai
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=5974ead5-2ef1-4887-91f5-422c87c30273@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=cgroups@vger.kernel.org \
--cc=hare@suse.de \
--cc=jack@suse.cz \
--cc=johnny.chenyi@huawei.com \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@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
all inboxes | Powered by JetHome®