mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Elijah Wright <git@elijahs.space>
To: Bart Van Assche <bvanassche@acm.org>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: mq-deadline: check if elevator is attached to queue in dd_finish_request
Date: Tue, 17 Jun 2025 15:52:28 -0700	[thread overview]
Message-ID: <b2644203-b1cd-4bc9-9afe-bd0ae0390ae4@elijahs.space> (raw)
In-Reply-To: <1e25d17b-f481-485c-85a6-d5a8440c1c96@acm.org>

I see. would it be possible to detach the elevator from the queue in 
elevator_exit instead?

On 6/17/2025 3:25 PM, Bart Van Assche wrote:
> On 6/17/25 1:56 PM, Elijah Wright wrote:
>> in dd_finish_request(), per_prio points to a rq->elv.priv[0], which 
>> could be
>> free memory if an in-flight requests completes after its associated 
>> scheduler
>> has been freed
>>
>> Signed-off-by: Elijah Wright <git@elijahs.space>
>> ---
>>   block/mq-deadline.c | 16 +++++++++-------
>>   1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/block/mq-deadline.c b/block/mq-deadline.c
>> index 2edf1cac06d5..4d7b21b144d3 100644
>> --- a/block/mq-deadline.c
>> +++ b/block/mq-deadline.c
>> @@ -751,13 +751,15 @@ static void dd_finish_request(struct request *rq)
>>   {
>>       struct dd_per_prio *per_prio = rq->elv.priv[0];
>> -    /*
>> -     * The block layer core may call dd_finish_request() without having
>> -     * called dd_insert_requests(). Skip requests that bypassed I/O
>> -     * scheduling. See also blk_mq_request_bypass_insert().
>> -     */
>> -    if (per_prio)
>> -        atomic_inc(&per_prio->stats.completed);
>> +    if (rq->q->elevator) {
>> +        /*
>> +        * The block layer core may call dd_finish_request() without 
>> having
>> +        * called dd_insert_requests(). Skip requests that bypassed I/O
>> +        * scheduling. See also blk_mq_request_bypass_insert().
>> +        */
>> +        if (per_prio)
>> +            atomic_inc(&per_prio->stats.completed);
>> +    }
>>   }
> 
> The warnings in dd_exit_sched() will be triggered if dd_finish_request()
> is ever called with rq->q->elevator == NULL.
> 
> If this can happen, it should be fixed in the block layer core instead
> of in the mq-deadline scheduler.
> 
> Thanks,
> 
> Bart.


  reply	other threads:[~2025-06-17 22:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17 20:56 Elijah Wright
2025-06-17 22:25 ` Bart Van Assche
2025-06-17 22:52   ` Elijah Wright [this message]
2025-06-18  0:19     ` Bart Van Assche

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=b2644203-b1cd-4bc9-9afe-bd0ae0390ae4@elijahs.space \
    --to=git@elijahs.space \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®