* [PATCH 1/3] block: remove RCU protection for tag_set_list
2026-12-03 15:22 [PATCH 0/3] block: remove RCU protection and add context annotation Nilay Shroff
@ 2026-12-03 15:22 ` Nilay Shroff
2026-12-03 16:41 ` Bart Van Assche
2026-12-03 15:22 ` [PATCH 2/3] block: remove unused blk_mq_free_sched_res_batch() Nilay Shroff
2026-12-03 15:22 ` [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock Nilay Shroff
2 siblings, 1 reply; 9+ messages in thread
From: Nilay Shroff @ 2026-12-03 15:22 UTC (permalink / raw)
To: axboe, mt4022, hch, mkhalfella, bvanassche, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block, Nilay Shroff
Commit 495f22c5a99a ("blk-mq: take quiesce_lock when removing a queue
from the tag set") ensures that set->quiesce_lock serialize both
traversals of set->tag_list in blk_mq_[un]quiesce_tagset() and
modifications to the list in blk_mq_[add|del]_queue_tag_set().
With both list traversal and modification now serialized by
set->quiesce_lock, RCU protection is no longer necessary for these
operations.
Replace the RCU-protected list APIs with their non-RCU counterparts
and remove the unnecessary RCU read-side critical sections from
blk_mq_[un]quiesce_tagset().
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
block/blk-mq.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 54ccfc43c27c..b3d26f0ec1a7 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -338,12 +338,10 @@ void blk_mq_quiesce_tagset(struct blk_mq_tag_set *set)
spin_lock(&set->quiesce_lock);
set->quiesce_depth++;
- rcu_read_lock();
- list_for_each_entry_rcu(q, &set->tag_list, tag_set_list) {
+ list_for_each_entry(q, &set->tag_list, tag_set_list) {
if (!blk_queue_skip_tagset_quiesce(q))
blk_mq_quiesce_queue_nowait(q);
}
- rcu_read_unlock();
spin_unlock(&set->quiesce_lock);
blk_mq_wait_quiesce_done(set);
@@ -357,12 +355,10 @@ void blk_mq_unquiesce_tagset(struct blk_mq_tag_set *set)
spin_lock(&set->quiesce_lock);
if (set->quiesce_depth)
set->quiesce_depth--;
- rcu_read_lock();
- list_for_each_entry_rcu(q, &set->tag_list, tag_set_list) {
+ list_for_each_entry(q, &set->tag_list, tag_set_list) {
if (!blk_queue_skip_tagset_quiesce(q))
blk_mq_unquiesce_queue(q);
}
- rcu_read_unlock();
spin_unlock(&set->quiesce_lock);
}
EXPORT_SYMBOL_GPL(blk_mq_unquiesce_tagset);
@@ -4354,9 +4350,8 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)
lockdep_assert_held(&set->tag_list_lock);
- /* blk_mq_unquiesce_tagset() runs the hctxs, which are not RCU freed */
spin_lock(&set->quiesce_lock);
- list_del_rcu(&q->tag_set_list);
+ list_del(&q->tag_set_list);
spin_unlock(&set->quiesce_lock);
if (list_is_singular(&set->tag_list)) {
/* just transitioned to unshared */
@@ -4390,7 +4385,7 @@ static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
* and blk_mq_unquiesce_tagset() finds what it is going to undo.
*/
spin_lock(&set->quiesce_lock);
- list_add_tail_rcu(&q->tag_set_list, &set->tag_list);
+ list_add_tail(&q->tag_set_list, &set->tag_list);
if (!blk_queue_skip_tagset_quiesce(q)) {
for (i = 0; i < set->quiesce_depth; i++)
blk_mq_quiesce_queue_nowait(q);
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 1/3] block: remove RCU protection for tag_set_list
2026-12-03 15:22 ` [PATCH 1/3] block: remove RCU protection for tag_set_list Nilay Shroff
@ 2026-12-03 16:41 ` Bart Van Assche
0 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2026-12-03 16:41 UTC (permalink / raw)
To: Nilay Shroff, axboe, mt4022, hch, mkhalfella, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block
On 12/3/26 7:22 AM, Nilay Shroff wrote:
> Subject: [PATCH 1/3] block: remove RCU protection for tag_set_list
The list head is called set->tag_list. tag_set_list is the name of the
list entry in struct request_queue. Please consider changing the
subject into "block: remove RCU protection for set->tag_list".
> Commit 495f22c5a99a ("blk-mq: take quiesce_lock when removing a queue
> from the tag set") ensures that set->quiesce_lock serialize both
serialize -> serializes
> - /* blk_mq_unquiesce_tagset() runs the hctxs, which are not RCU freed */
> spin_lock(&set->quiesce_lock);
> - list_del_rcu(&q->tag_set_list);
> + list_del(&q->tag_set_list);
> spin_unlock(&set->quiesce_lock);
All set->tag_list modifications happen with both tag_list_lock and
quiesce_lock held and all code that iterates over that list holds one
of these two locks. Nothing uses q->tag_set_list after the queue has
been removed from the list, so switching from list_del_rcu() to
list_del() is fine. Hence, with the above nits addressed:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] block: remove unused blk_mq_free_sched_res_batch()
2026-12-03 15:22 [PATCH 0/3] block: remove RCU protection and add context annotation Nilay Shroff
2026-12-03 15:22 ` [PATCH 1/3] block: remove RCU protection for tag_set_list Nilay Shroff
@ 2026-12-03 15:22 ` Nilay Shroff
2026-12-03 16:42 ` Bart Van Assche
2026-12-03 15:22 ` [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock Nilay Shroff
2 siblings, 1 reply; 9+ messages in thread
From: Nilay Shroff @ 2026-12-03 15:22 UTC (permalink / raw)
To: axboe, mt4022, hch, mkhalfella, bvanassche, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block, Nilay Shroff
blk_mq_free_sched_res_batch() is not used by any code path.
Remove its implementation and declaration.
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
block/blk-mq-sched.c | 27 ---------------------------
block/blk-mq-sched.h | 2 --
2 files changed, 29 deletions(-)
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index d7b45778732b..bf501f772f9c 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -446,33 +446,6 @@ void blk_mq_free_sched_res(struct elevator_resources *res,
}
}
-void blk_mq_free_sched_res_batch(struct xarray *elv_tbl,
- struct blk_mq_tag_set *set)
-{
- struct request_queue *q;
- struct elv_change_ctx *ctx;
-
- lockdep_assert_held_write(&set->update_nr_hwq_lock);
-
- list_for_each_entry(q, &set->tag_list, tag_set_list) {
- /*
- * Accessing q->elevator without holding q->elevator_lock is
- * safe because we're holding here set->update_nr_hwq_lock in
- * the writer context. So, scheduler update/switch code (which
- * acquires the same lock but in the reader context) can't run
- * concurrently.
- */
- if (q->elevator) {
- ctx = xa_load(elv_tbl, q->id);
- if (!ctx) {
- WARN_ON_ONCE(1);
- continue;
- }
- blk_mq_free_sched_res(&ctx->res, ctx->type, set);
- }
- }
-}
-
void blk_mq_free_sched_ctx_batch(struct xarray *elv_tbl)
{
unsigned long i;
diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h
index 5678e15bd33c..50e19f5ca90a 100644
--- a/block/blk-mq-sched.h
+++ b/block/blk-mq-sched.h
@@ -39,8 +39,6 @@ void blk_mq_free_sched_tags(struct elevator_tags *et,
void blk_mq_free_sched_res(struct elevator_resources *res,
struct elevator_type *type,
struct blk_mq_tag_set *set);
-void blk_mq_free_sched_res_batch(struct xarray *et_table,
- struct blk_mq_tag_set *set);
/*
* blk_mq_alloc_sched_data() - Allocates scheduler specific data
* Returns:
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 2/3] block: remove unused blk_mq_free_sched_res_batch()
2026-12-03 15:22 ` [PATCH 2/3] block: remove unused blk_mq_free_sched_res_batch() Nilay Shroff
@ 2026-12-03 16:42 ` Bart Van Assche
0 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2026-12-03 16:42 UTC (permalink / raw)
To: Nilay Shroff, axboe, mt4022, hch, mkhalfella, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block
On 12/3/26 7:22 AM, Nilay Shroff wrote:
> blk_mq_free_sched_res_batch() is not used by any code path.
> Remove its implementation and declaration.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock
2026-12-03 15:22 [PATCH 0/3] block: remove RCU protection and add context annotation Nilay Shroff
2026-12-03 15:22 ` [PATCH 1/3] block: remove RCU protection for tag_set_list Nilay Shroff
2026-12-03 15:22 ` [PATCH 2/3] block: remove unused blk_mq_free_sched_res_batch() Nilay Shroff
@ 2026-12-03 15:22 ` Nilay Shroff
2026-12-03 16:43 ` Bart Van Assche
2 siblings, 1 reply; 9+ messages in thread
From: Nilay Shroff @ 2026-12-03 15:22 UTC (permalink / raw)
To: axboe, mt4022, hch, mkhalfella, bvanassche, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block, Nilay Shroff
Access to ->tag_list is protected by either tag_list_lock or
quiesce_lock for reads, and by both locks for writes. Annotate
->tag_list using __guarded_by(&tag_list_lock, &quiesce_lock)
to document this locking requirement.
Similarly, all accesses to ->quiesce_depth are protected by
quiesce_lock, so annotate it using __guarded_by(&quiesce_lock).
Additionally, annotate blk_mq_alloc_sched_ctx_batch(),
blk_mq_alloc_sched_res_batch(), blk_mq_update_tag_set_shared(),
blk_mq_del_queue_tag_set(), blk_mq_add_queue_tag_set(), and
__blk_mq_update_nr_hw_queues() with __must_hold(&tag_list_lock)
to document that tag_list_lock must be held when these functions
are called.
Finally, mark blk_mq_alloc_tag_set() with __context_unsafe()
because it initializes lock-guarded variables before they are
published and accessed by other contexts. This avoids false
positive warnings from the context analyzer during initialization.
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
block/blk-mq-sched.h | 6 ++++--
block/blk-mq.c | 4 ++++
include/linux/blk-mq.h | 9 ++++++---
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h
index 50e19f5ca90a..5f3583fdfd47 100644
--- a/block/blk-mq-sched.h
+++ b/block/blk-mq-sched.h
@@ -30,9 +30,11 @@ int blk_mq_alloc_sched_res(struct request_queue *q,
struct elevator_resources *res,
unsigned int nr_hw_queues);
int blk_mq_alloc_sched_res_batch(struct xarray *elv_tbl,
- struct blk_mq_tag_set *set, unsigned int nr_hw_queues);
+ struct blk_mq_tag_set *set, unsigned int nr_hw_queues)
+ __must_hold(&set->tag_list_lock);
int blk_mq_alloc_sched_ctx_batch(struct xarray *elv_tbl,
- struct blk_mq_tag_set *set);
+ struct blk_mq_tag_set *set)
+ __must_hold(&set->tag_list_lock);
void blk_mq_free_sched_ctx_batch(struct xarray *elv_tbl);
void blk_mq_free_sched_tags(struct elevator_tags *et,
struct blk_mq_tag_set *set);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index b3d26f0ec1a7..cd4fb994cfda 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4331,6 +4331,7 @@ static void queue_set_hctx_shared(struct request_queue *q, bool shared)
static void blk_mq_update_tag_set_shared(struct blk_mq_tag_set *set,
bool shared)
+ __must_hold(&set->tag_list_lock)
{
struct request_queue *q;
unsigned int memflags;
@@ -4345,6 +4346,7 @@ static void blk_mq_update_tag_set_shared(struct blk_mq_tag_set *set,
}
static void blk_mq_del_queue_tag_set(struct request_queue *q)
+ __must_hold(&q->tag_set->tag_list_lock)
{
struct blk_mq_tag_set *set = q->tag_set;
@@ -4363,6 +4365,7 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)
static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
struct request_queue *q)
+ __must_hold(&set->tag_list_lock)
{
unsigned int i;
@@ -5170,6 +5173,7 @@ static int blk_mq_elv_switch_none(struct request_queue *q,
static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
int nr_hw_queues)
+ __must_hold(&set->tag_list_lock)
{
struct request_queue *q;
int prev_nr_hw_queues = set->nr_hw_queues;
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 3c9667854c46..b085328cbc73 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -552,9 +552,11 @@ struct blk_mq_tag_set {
struct blk_mq_tags *shared_tags;
struct mutex tag_list_lock;
- struct list_head tag_list;
+ struct list_head tag_list
+ __guarded_by(&tag_list_lock, &quiesce_lock);
spinlock_t quiesce_lock;
- unsigned int quiesce_depth;
+ unsigned int quiesce_depth
+ __guarded_by(&quiesce_lock);
struct srcu_struct *srcu;
struct rw_semaphore update_nr_hwq_lock;
@@ -745,7 +747,8 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
struct request_queue *q);
void blk_mq_destroy_queue(struct request_queue *);
-int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
+int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
+ __context_unsafe("/* initialize unpublished/lock-guarded variables */");
int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
const struct blk_mq_ops *ops, unsigned int queue_depth,
unsigned int set_flags);
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock
2026-12-03 15:22 ` [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock Nilay Shroff
@ 2026-12-03 16:43 ` Bart Van Assche
2026-12-04 9:36 ` Nilay Shroff
0 siblings, 1 reply; 9+ messages in thread
From: Bart Van Assche @ 2026-12-03 16:43 UTC (permalink / raw)
To: Nilay Shroff, axboe, mt4022, hch, mkhalfella, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block
On 12/3/26 7:22 AM, Nilay Shroff wrote:
> Access to ->tag_list is protected by either tag_list_lock or
> quiesce_lock for reads, and by both locks for writes. Annotate
> ->tag_list using __guarded_by(&tag_list_lock, &quiesce_lock)
> to document this locking requirement.
Please mention that the compiler does not verify the "both locks for
writes" requirement for this list. Passing &set->tag_list to
list_add_tail() is treated as a read access, and list_del() does not
reference set->tag_list at all. If I remove the quiesce_lock
lock/unlock calls from blk_mq_add_queue_tag_set() and
blk_mq_del_queue_tag_set(), Clang does not complain.
> Finally, mark blk_mq_alloc_tag_set() with __context_unsafe()
> because it initializes lock-guarded variables before they are
> published and accessed by other contexts. This avoids false
> positive warnings from the context analyzer during initialization.
[ ... ]
> -int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
> +int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
> + __context_unsafe("/* initialize unpublished/lock-guarded variables
*/");
I see three issues with this change:
- This disables context analysis for all of blk_mq_alloc_tag_set().
That is a large function with several error paths.
Please use the *_init guards.
- Disabling context analysis is not part of the interface of a
function. Hence, such an attribute should occur in the function
definition instead of in the declaration in the header file.
- All other __context_unsafe() users pass a comment as argument instead
of a string literal, e.g. __context_unsafe(/* conditional locking */).
Please consider leaving the blk_mq_alloc_tag_set() declaration
unmodified and making the following change instead:
- mutex_init(&set->tag_list_lock);
- INIT_LIST_HEAD(&set->tag_list);
- spin_lock_init(&set->quiesce_lock);
- set->quiesce_depth = 0;
+ scoped_guard(mutex_init, &set->tag_list_lock)
+ INIT_LIST_HEAD(&set->tag_list);
+ scoped_guard(spinlock_init, &set->quiesce_lock)
+ set->quiesce_depth = 0;
With this change block/ builds without context analysis warnings on
my setup (Clang, CONFIG_WARN_CONTEXT_ANALYSIS=y).
> struct mutex tag_list_lock;
> - struct list_head tag_list;
> + struct list_head tag_list
> + __guarded_by(&tag_list_lock, &quiesce_lock);
The kernel-doc comment above this struct still says "@tag_list_lock:
Serializes tag_list accesses." Please update that comment such that it
matches the above annotation or remove it.
> int blk_mq_alloc_sched_res_batch(struct xarray *elv_tbl,
> - struct blk_mq_tag_set *set, unsigned int nr_hw_queues);
> + struct blk_mq_tag_set *set, unsigned int nr_hw_queues)
> + __must_hold(&set->tag_list_lock);
> int blk_mq_alloc_sched_ctx_batch(struct xarray *elv_tbl,
> - struct blk_mq_tag_set *set);
> + struct blk_mq_tag_set *set)
> + __must_hold(&set->tag_list_lock);
Both functions have a lockdep_assert_held_write() call for
set->update_nr_hwq_lock. Has it been considered to add
__must_hold(&set->update_nr_hwq_lock) to these declarations too?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock
2026-12-03 16:43 ` Bart Van Assche
@ 2026-12-04 9:36 ` Nilay Shroff
2026-12-04 16:27 ` Bart Van Assche
0 siblings, 1 reply; 9+ messages in thread
From: Nilay Shroff @ 2026-12-04 9:36 UTC (permalink / raw)
To: Bart Van Assche, axboe, mt4022, hch, mkhalfella, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block
On 12/3/26 10:13 PM, Bart Van Assche wrote:
> On 12/3/26 7:22 AM, Nilay Shroff wrote:
> > Access to ->tag_list is protected by either tag_list_lock or
> > quiesce_lock for reads, and by both locks for writes. Annotate
> > ->tag_list using __guarded_by(&tag_list_lock, &quiesce_lock)
> > to document this locking requirement.
>
> Please mention that the compiler does not verify the "both locks for
> writes" requirement for this list. Passing &set->tag_list to
> list_add_tail() is treated as a read access, and list_del() does not
> reference set->tag_list at all. If I remove the quiesce_lock
> lock/unlock calls from blk_mq_add_queue_tag_set() and
> blk_mq_del_queue_tag_set(), Clang does not complain.
>
Yes agreed and that's the reason commit message only mentions that
__guarded_by(&tag_list_lock, &quiesce_lock) just documents this
locking requirement. But yes I should be more explicit here. I will
update the description accordingly in the next revision of the patch.
> > Finally, mark blk_mq_alloc_tag_set() with __context_unsafe()
> > because it initializes lock-guarded variables before they are
> > published and accessed by other contexts. This avoids false
> > positive warnings from the context analyzer during initialization.
>
> [ ... ]
>
> > -int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
> > +int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
> > + __context_unsafe("/* initialize unpublished/lock-guarded variables */");
>
> I see three issues with this change:
> - This disables context analysis for all of blk_mq_alloc_tag_set().
> That is a large function with several error paths.
> Please use the *_init guards.
> - Disabling context analysis is not part of the interface of a
> function. Hence, such an attribute should occur in the function
> definition instead of in the declaration in the header file.
> - All other __context_unsafe() users pass a comment as argument instead
> of a string literal, e.g. __context_unsafe(/* conditional locking */).
>
Yes noted all points. Regarding last point, I think that was typo and
not intention to add comment as literal string.
> Please consider leaving the blk_mq_alloc_tag_set() declaration
> unmodified and making the following change instead:
>
> - mutex_init(&set->tag_list_lock);
> - INIT_LIST_HEAD(&set->tag_list);
> - spin_lock_init(&set->quiesce_lock);
> - set->quiesce_depth = 0;
> + scoped_guard(mutex_init, &set->tag_list_lock)
> + INIT_LIST_HEAD(&set->tag_list);
> + scoped_guard(spinlock_init, &set->quiesce_lock)
> + set->quiesce_depth = 0;
>
> With this change block/ builds without context analysis warnings on
> my setup (Clang, CONFIG_WARN_CONTEXT_ANALYSIS=y).
>
I did consider using scoped_guard(_init, ...) helper here, but
then realized that doing so would make lockdep class name and key
for these locks registered as "_T->lock" instead of &set->tag_list_lock
or &set->quiesce_lock respectively. And that then might make the
lockdep splat involving these locks difficult to trace, isn't it?
Does this unintentionally degrade lockdep class identity or diagnostics?
grepping through kernel source, I found only handful of mutex_init/
spinlock_init guard users. Still if you think scoped_guard(_init, ...)
is the only alternative here, I'd do this but other preference would
be to create inline helper involving initialization of set->tag_list
and set->quiesce_depth and marking the helper with __context_unsafe.
Alternatively, I could also directly make use of context_unsafe(...)
as a statement expression and add both initialization under it, like
shown below:
context_unsafe(
INIT_LIST_HEAD(&set->tag_list);
set->quiesce_depth = 0;
);
> > struct mutex tag_list_lock;
> > - struct list_head tag_list;
> > + struct list_head tag_list
> > + __guarded_by(&tag_list_lock, &quiesce_lock);
>
> The kernel-doc comment above this struct still says "@tag_list_lock:
> Serializes tag_list accesses." Please update that comment such that it
> matches the above annotation or remove it.
>
Yes okay will update comment.
> > int blk_mq_alloc_sched_res_batch(struct xarray *elv_tbl,
> > - struct blk_mq_tag_set *set, unsigned int nr_hw_queues);
> > + struct blk_mq_tag_set *set, unsigned int nr_hw_queues)
> > + __must_hold(&set->tag_list_lock);
> > int blk_mq_alloc_sched_ctx_batch(struct xarray *elv_tbl,
> > - struct blk_mq_tag_set *set);
> > + struct blk_mq_tag_set *set)
> > + __must_hold(&set->tag_list_lock);
>
> Both functions have a lockdep_assert_held_write() call for
> set->update_nr_hwq_lock. Has it been considered to add
> __must_hold(&set->update_nr_hwq_lock) to these declarations too?
>
Yes I considered doing that but then realized the scope of
annotating set->update_nr_hwq_lock is much bigger then only
annotating these two functions and so thought I'd address it
in a different patch covering all relevant annotation needed
for set->update_nr_hwq_lock instead of adding it in this series.
That said, if you prefer, I could add one more patch in the same
series to address locking requirement of set->update_nr_hwq_lock.
Thanks,
--Nilay
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock
2026-12-04 9:36 ` Nilay Shroff
@ 2026-12-04 16:27 ` Bart Van Assche
0 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2026-12-04 16:27 UTC (permalink / raw)
To: Nilay Shroff, axboe, mt4022, hch, mkhalfella, kbusch, josef,
tom.leiming, tz2294, gjoyce
Cc: linux-block
On 12/4/26 1:36 AM, Nilay Shroff wrote:
> Alternatively, I could also directly make use of context_unsafe(...)
> as a statement expression and add both initialization under it, like
> shown below:
>
> context_unsafe(
> INIT_LIST_HEAD(&set->tag_list);
> set->quiesce_depth = 0;
> );
This sounds good to me.
>> > int blk_mq_alloc_sched_res_batch(struct xarray *elv_tbl,
>> > - struct blk_mq_tag_set *set, unsigned int nr_hw_queues);
>> > + struct blk_mq_tag_set *set, unsigned int nr_hw_queues)
>> > + __must_hold(&set->tag_list_lock);
>> > int blk_mq_alloc_sched_ctx_batch(struct xarray *elv_tbl,
>> > - struct blk_mq_tag_set *set);
>> > + struct blk_mq_tag_set *set)
>> > + __must_hold(&set->tag_list_lock);
>>
>> Both functions have a lockdep_assert_held_write() call for
>> set->update_nr_hwq_lock. Has it been considered to add
>> __must_hold(&set->update_nr_hwq_lock) to these declarations too?
>>
> Yes I considered doing that but then realized the scope of
> annotating set->update_nr_hwq_lock is much bigger then only
> annotating these two functions and so thought I'd address it
> in a different patch covering all relevant annotation needed
> for set->update_nr_hwq_lock instead of adding it in this series.
>
> That said, if you prefer, I could add one more patch in the same
> series to address locking requirement of set->update_nr_hwq_lock.
An additional patch is fine with me. Leaving this for later is also
fine with me.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 9+ messages in thread