* [PATCH] block: mq-deadline: check if elevator is attached to queue in dd_finish_request
@ 2025-06-17 20:56 Elijah Wright
2025-06-17 22:25 ` Bart Van Assche
0 siblings, 1 reply; 4+ messages in thread
From: Elijah Wright @ 2025-06-17 20:56 UTC (permalink / raw)
To: Jens Axboe, linux-block, linux-kernel; +Cc: Elijah Wright
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);
+ }
}
static bool dd_has_work_for_prio(struct dd_per_prio *per_prio)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block: mq-deadline: check if elevator is attached to queue in dd_finish_request
2025-06-17 20:56 [PATCH] block: mq-deadline: check if elevator is attached to queue in dd_finish_request Elijah Wright
@ 2025-06-17 22:25 ` Bart Van Assche
2025-06-17 22:52 ` Elijah Wright
0 siblings, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2025-06-17 22:25 UTC (permalink / raw)
To: Elijah Wright, Jens Axboe, linux-block, linux-kernel
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: mq-deadline: check if elevator is attached to queue in dd_finish_request
2025-06-17 22:25 ` Bart Van Assche
@ 2025-06-17 22:52 ` Elijah Wright
2025-06-18 0:19 ` Bart Van Assche
0 siblings, 1 reply; 4+ messages in thread
From: Elijah Wright @ 2025-06-17 22:52 UTC (permalink / raw)
To: Bart Van Assche; +Cc: axboe, linux-block, linux-kernel
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: mq-deadline: check if elevator is attached to queue in dd_finish_request
2025-06-17 22:52 ` Elijah Wright
@ 2025-06-18 0:19 ` Bart Van Assche
0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2025-06-18 0:19 UTC (permalink / raw)
To: Elijah Wright; +Cc: axboe, linux-block, linux-kernel
On 6/17/25 3:52 PM, Elijah Wright wrote:
> I see. would it be possible to detach the elevator from the queue in
> elevator_exit instead?
elevator_switch() is called with the request queue frozen.
q_usage_counter is dropped after the blk_mq_finish_request() call
returned. So what you described in your patch description can't happen.
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-18 0:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 20:56 [PATCH] block: mq-deadline: check if elevator is attached to queue in dd_finish_request Elijah Wright
2025-06-17 22:25 ` Bart Van Assche
2025-06-17 22:52 ` Elijah Wright
2025-06-18 0:19 ` Bart Van Assche
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).