linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] block: restructure elevator switch path and fix a lockdep splat
@ 2025-10-16  5:30 Nilay Shroff
  2025-10-16  5:30 ` [PATCH 1/3] block: unify elevator tags and type xarrays into struct elv_change_ctx Nilay Shroff
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Nilay Shroff @ 2025-10-16  5:30 UTC (permalink / raw)
  To: linux-block; +Cc: ming.lei, hch, yukuai1, axboe, yi.zhang, czhong, gjoyce

Hi,

This patchset reorganizes the elevator switch path used during both
nr_hw_queues update and elv_iosched_store() operations to address a
recently reported lockdep splat [1].

The warning highlights a locking dependency between ->freeze_lock and
->elevator_lock on pcpu_alloc_mutex, triggered when the Kyber scheduler
dynamically allocates its private scheduling data. The fix is to ensure
that such allocations occur outside the locked sections, thus eliminating
the dependency chain.

While working on this, it also became evident that the nr_hw_queue update
code maintains two disjoint xarrays—one for elevator tags and another
for elevator type—both serving the same purpose. Unifying these into a
single elv_change_ctx structure improves clarity and maintainability.

This series therefore implements three patches:
The first perparatory patch unifies elevator tags and type xarrays. It
combines both xarrays into a single struct elv_change_ctx, simplifying
per-queue elevator state management.

The second patch introduce ->alloc_sched_data and ->free_sched_data 
elevator ops to safely allocate and free scheduler data before acquiring
->freeze_lock and ->elevator_lock, preventing the dependency on pcpu_
alloc_mutex.

The third patch converts Kyber scheduler to use the new methods inroduced
in the previous patch. It hooks Kyber’s scheduler data allocation and 
teardown logic from ->init_sched and ->exit_sched into the new methods, 
ensuring memory operations are performed outside locked sections.

Together, these changes simplify the elevator switch logic and prevent
the reported lockdep splat.

As always, feedback and suggestions are very welcome!

[1] https://lore.kernel.org/all/CAGVVp+VNW4M-5DZMNoADp6o2VKFhi7KxWpTDkcnVyjO0=-D5+A@mail.gmail.com/

Thanks,
--Nilay

Nilay Shroff (3):
  block: unify elevator tags and type xarrays into struct elv_change_ctx
  block: introduce alloc_sched_data and free_sched_data elevator methods
  block: define alloc_sched_data and free_sched_data methods for kyber

 block/blk-mq-sched.c  | 104 ++++++++++++++++++++++++++++++++++++++----
 block/blk-mq-sched.h  |  35 +++++++++++++-
 block/blk-mq.c        |  56 ++++++++++++++---------
 block/blk.h           |   7 ++-
 block/elevator.c      |  76 ++++++++++++++++--------------
 block/elevator.h      |  23 +++++++++-
 block/kyber-iosched.c |  30 ++++++++----
 7 files changed, 252 insertions(+), 79 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-10-28  4:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16  5:30 [PATCH 0/3] block: restructure elevator switch path and fix a lockdep splat Nilay Shroff
2025-10-16  5:30 ` [PATCH 1/3] block: unify elevator tags and type xarrays into struct elv_change_ctx Nilay Shroff
2025-10-22  4:11   ` Ming Lei
2025-10-23  5:53     ` Nilay Shroff
2025-10-16  5:30 ` [PATCH 2/3] block: introduce alloc_sched_data and free_sched_data elevator methods Nilay Shroff
2025-10-22  4:39   ` Ming Lei
2025-10-23  5:57     ` Nilay Shroff
2025-10-23  7:48       ` Ming Lei
2025-10-23  8:28         ` Nilay Shroff
2025-10-27 17:38     ` Nilay Shroff
2025-10-28  2:43       ` Ming Lei
2025-10-28  4:51         ` Nilay Shroff
2025-10-16  5:30 ` [PATCH 3/3] block: define alloc_sched_data and free_sched_data methods for kyber Nilay Shroff

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).