Skip to content

Conversation

@blktests-ci
Copy link

@blktests-ci blktests-ci bot commented Nov 15, 2025

Pull request for series with
subject: block: restructure elevator switch path and fix a lockdep splat
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1022861

@blktests-ci
Copy link
Author

blktests-ci bot commented Nov 15, 2025

Upstream branch: 6da43bb
series: https://patchwork.kernel.org/project/linux-block/list/?series=1022861
version: 1

@blktests-ci
Copy link
Author

blktests-ci bot commented Nov 16, 2025

Upstream branch: f824272
series: https://patchwork.kernel.org/project/linux-block/list/?series=1022861
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1016389=>linus-master branch from 6f726eb to a4cedd2 Compare November 16, 2025 07:38
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 00d5e5c to d782508 Compare November 17, 2025 00:45
@blktests-ci
Copy link
Author

blktests-ci bot commented Nov 17, 2025

Upstream branch: f824272
series: https://patchwork.kernel.org/project/linux-block/list/?series=1022861
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1016389=>linus-master branch from a4cedd2 to dabdf0f Compare November 17, 2025 00:47
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from d782508 to 6099a4d Compare November 17, 2025 23:44
@blktests-ci
Copy link
Author

blktests-ci bot commented Nov 17, 2025

Upstream branch: e7c375b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1022861
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1016389=>linus-master branch from dabdf0f to d61cceb Compare November 17, 2025 23:48
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 6099a4d to 5121c4d Compare November 18, 2025 02:19
@blktests-ci
Copy link
Author

blktests-ci bot commented Nov 18, 2025

Upstream branch: e7c375b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1022861
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1016389=>linus-master branch from d61cceb to 665bfe5 Compare November 18, 2025 02:21
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 5121c4d to 4458758 Compare November 19, 2025 00:24
@blktests-ci
Copy link
Author

blktests-ci bot commented Nov 19, 2025

Upstream branch: 8b69055
series: https://patchwork.kernel.org/project/linux-block/list/?series=1022861
version: 1

@blktests-ci blktests-ci bot force-pushed the series/1016389=>linus-master branch from 665bfe5 to bbef9b6 Compare November 19, 2025 00:26
@blktests-ci blktests-ci bot force-pushed the linus-master_base branch from 4458758 to 6f43942 Compare November 21, 2025 09:45
@blktests-ci
Copy link
Author

blktests-ci bot commented Nov 21, 2025

Upstream branch: fd95357
series: https://patchwork.kernel.org/project/linux-block/list/?series=1022861
version: 1

Currently, the nr_hw_queues update path manages two disjoint xarrays —
one for elevator tags and another for elevator type — both used during
elevator switching. Maintaining these two parallel structures for the
same purpose adds unnecessary complexity and potential for mismatched
state.

This patch unifies both xarrays into a single structure, struct
elv_change_ctx, which holds all per-queue elevator change context. A
single xarray, named elv_tbl, now maps each queue (q->id) in a tagset
to its corresponding elv_change_ctx entry, encapsulating the elevator
tags, type and name references.

This unification simplifies the code, improves maintainability, and
clarifies ownership of per-queue elevator state.

Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Signed-off-by: Nilay Shroff <[email protected]>
This patch introduces a new structure, struct elevator_resources, to
group together all elevator-related resources that share the same
lifetime. As a first step, this change moves the elevator tag pointer
from struct elv_change_ctx into the new struct elevator_resources.

Additionally, rename blk_mq_alloc_sched_tags_batch() and
blk_mq_free_sched_tags_batch() to blk_mq_alloc_sched_res_batch() and
blk_mq_free_sched_res_batch(), respectively. Introduce two new wrapper
helpers, blk_mq_alloc_sched_res() and blk_mq_free_sched_res(), around
blk_mq_alloc_sched_tags() and blk_mq_free_sched_tags().

These changes pave the way for consolidating the allocation and freeing
of elevator-specific resources into common helper functions. This
refactoring improves encapsulation and prepares the code for future
extensions, allowing additional elevator-specific data to be added to
struct elevator_resources without cluttering struct elv_change_ctx.

Subsequent patches will extend struct elevator_resources to include
other elevator-related data.

Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Signed-off-by: Nilay Shroff <[email protected]>
The recent lockdep splat [1] highlights a potential deadlock risk
involving ->elevator_lock and ->freeze_lock dependencies on -pcpu_alloc_
mutex. The trace shows that the issue occurs when the Kyber scheduler
allocates dynamic memory for its elevator data during initialization.

To address this, introduce two new elevator operation callbacks:
->alloc_sched_data and ->free_sched_data. The subsequent patch would
build upon these newly introduced methods to suppress lockdep splat[1].

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

Signed-off-by: Nilay Shroff <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
The previous patch introduced ->alloc_sched_data and
->free_sched_data methods. This patch builds upon that
by now using these methods during elevator switch and
nr_hw_queue update.

It's also ensured that scheduler-specific data is
allocated and freed through the new callbacks outside
of the ->freeze_lock and ->elevator_lock locking contexts,
thereby preventing any dependency on pcpu_alloc_mutex.

Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Signed-off-by: Nilay Shroff <[email protected]>
Currently, the Kyber elevator allocates its private data dynamically in
->init_sched and frees it in ->exit_sched. However, since ->init_sched
is invoked during elevator switch after acquiring both ->freeze_lock and
->elevator_lock, it may trigger the lockdep splat [1] due to dependency
on pcpu_alloc_mutex.

To resolve this, move the elevator data allocation and deallocation
logic from ->init_sched and ->exit_sched into the newly introduced
->alloc_sched_data and ->free_sched_data methods. These callbacks are
invoked before acquiring ->freeze_lock and ->elevator_lock, ensuring
that memory allocation happens safely without introducing additional
locking dependencies.

This change breaks the dependency chain involving pcpu_alloc_mutex and
prevents the reported lockdep warning.

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

Reported-by: Changhui Zhong <[email protected]>
Reported-by: Yi Zhang <[email protected]>
Closes: https://lore.kernel.org/all/CAGVVp+VNW4M-5DZMNoADp6o2VKFhi7KxWpTDkcnVyjO0=-D5+A@mail.gmail.com/
Tested-by: Yi Zhang <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Signed-off-by: Nilay Shroff <[email protected]>
@blktests-ci blktests-ci bot force-pushed the series/1016389=>linus-master branch from bbef9b6 to 1bd01da Compare November 21, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants