]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: fix potential deadlock while running nr_hw_queue update
authorNilay Shroff <nilay@linux.ibm.com>
Wed, 30 Jul 2025 07:46:09 +0000 (13:16 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:50 +0000 (16:34 +0200)
commite01facfb54a9b2e1ad7bbb00601a42b16d276d81
tree89b0320417f0a1f5bbca550c7fc337741bc66a00
parent58567d8e95c096ad234963df90a2ca518901f4b6
block: fix potential deadlock while running nr_hw_queue update

[ Upstream commit 04225d13aef11b2a539014def5e47d8c21fd74a5 ]

Move scheduler tags (sched_tags) allocation and deallocation outside
both the ->elevator_lock and ->freeze_lock when updating nr_hw_queues.
This change breaks the dependency chain from the percpu allocator lock
to the elevator lock, helping to prevent potential deadlocks, as
observed in the reported lockdep splat[1].

This commit introduces batch allocation and deallocation helpers for
sched_tags, which are now used from within __blk_mq_update_nr_hw_queues
routine while iterating through the tagset.

With this change, all sched_tags memory management is handled entirely
outside the ->elevator_lock and the ->freeze_lock context, thereby
eliminating the lock dependency that could otherwise manifest during
nr_hw_queues updates.

[1] https://lore.kernel.org/all/0659ea8d-a463-47c8-9180-43c719e106eb@linux.ibm.com/

Reported-by: Stefan Haberland <sth@linux.ibm.com>
Closes: https://lore.kernel.org/all/0659ea8d-a463-47c8-9180-43c719e106eb@linux.ibm.com/
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Link: https://lore.kernel.org/r/20250730074614.2537382-4-nilay@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 2d82f3bd8910 ("blk-mq: fix lockdep warning in __blk_mq_update_nr_hw_queues")
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-mq-sched.c
block/blk-mq-sched.h
block/blk-mq.c
block/blk.h
block/elevator.c