Linux block layer
 help / color / mirror / Atom feed
* [PATCH] blk-cgroup: fix rcu lockdep warning in blkg_lookup()
@ 2023-12-19  1:28 Ming Lei
  2024-01-02  7:38 ` Ming Lei
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ming Lei @ 2023-12-19  1:28 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Changhui Zhong

blkg_lookup() is called with either queue_lock or rcu read lock, so
use rcu_dereference_check(lockdep_is_held(&q->queue_lock)) for
retrieving 'blkg', which way models the check exactly for covering
queue lock or rcu read lock.

Fix lockdep warning of "block/blk-cgroup.h:254 suspicious rcu_dereference_check() usage!"
from blkg_lookup().

Tested-by: Changhui Zhong <czhong@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-cgroup.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index fd482439afbc..b927a4a0ad03 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -252,7 +252,8 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg,
 	if (blkcg == &blkcg_root)
 		return q->root_blkg;
 
-	blkg = rcu_dereference(blkcg->blkg_hint);
+	blkg = rcu_dereference_check(blkcg->blkg_hint,
+			lockdep_is_held(&q->queue_lock));
 	if (blkg && blkg->q == q)
 		return blkg;
 
-- 
2.42.0


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

end of thread, other threads:[~2024-01-04 23:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19  1:28 [PATCH] blk-cgroup: fix rcu lockdep warning in blkg_lookup() Ming Lei
2024-01-02  7:38 ` Ming Lei
2024-01-04 22:04   ` Tejun Heo
2024-01-02 10:32 ` Yu Kuai
2024-01-02 11:27   ` Ming Lei
2024-01-03  1:05     ` Yu Kuai
2024-01-04 23:10 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox