Skip to contentSkip to conversation

block: fix elv_update_nr_hw_queues() to reattach elevator

PATCH Applied Nilay Shroff 3 participants 3 messages May 15, 2025 – May 16, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix elv_update_nr_hw_queues() to reattach elevator

When nr_hw_queues is updated, the elevator needs to be switched to ensure that we exit elevator and reattach it to ensure that hctx-> sched_tags is correctly allocated for the new hardware queues. However, elv_update_nr_hw_queues() currently only switches the elevator if the queue is not registered. This is incorrect, as it prevents reattaching the elevator after updating nr_hw_queues, which in turn inhibits allocation of sched_tags.

Fix this by allowing the elevator switch if the queue is registered, ensuring proper reattachment and resource allocation.

Fixes 596dce110b7d ("block: simplify elevator reattachment for updating nr_hw_queues")
---
 block/elevator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/elevator.c +1 -1
index f8d72bd20610..ab22542e6cf0 100644
@@ -697,7 +697,7 @@ void elv_update_nr_hw_queues(struct request_queue *q)
 	WARN_ON_ONCE(q->mq_freeze_depth == 0);
 
 	mutex_lock(&q->elevator_lock);
-	if (q->elevator && !blk_queue_dying(q) && !blk_queue_registered(q)) {
+	if (q->elevator && !blk_queue_dying(q) && blk_queue_registered(q)) {
 		ctx.name = q->elevator->type->elevator_name;
 
 		/* force to reattach elevator after nr_hw_queue is updated */
Signature · 1 line
2.49.0
maintainer Applied
#1 lore raw
Quoted 9 lines · Nilay Shroff

When nr_hw_queues is updated, the elevator needs to be switched to ensure that we exit elevator and reattach it to ensure that hctx-> sched_tags is correctly allocated for the new hardware queues. However, elv_update_nr_hw_queues() currently only switches the elevator if the queue is not registered. This is incorrect, as it prevents reattaching the elevator after updating nr_hw_queues, which in turn inhibits allocation of sched_tags.

[...]

Applied, thanks!

[1/1] block: fix elv_update_nr_hw_queues() to reattach elevator

      commit: 532b9e11b8540eb543ebec9cba851c5691e10b5b

Best regards,

Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#2 lore raw
In reply to Nilay Shroff
Quoted 9 lines · Nilay Shroff

When nr_hw_queues is updated, the elevator needs to be switched to ensure that we exit elevator and reattach it to ensure that hctx-> sched_tags is correctly allocated for the new hardware queues. However, elv_update_nr_hw_queues() currently only switches the elevator if the queue is not registered. This is incorrect, as it prevents reattaching the elevator after updating nr_hw_queues, which in turn inhibits allocation of sched_tags.

Quoted 5 lines

Fix this by allowing the elevator switch if the queue is registered, ensuring proper reattachment and resource allocation.

Fixes 596dce110b7d ("block: simplify elevator reattachment for updating nr_hw_queues")

Thanks,