diff mbox series

[v2,1/1] RDMA/rtrs: Require holding rcu_read_lock explicitly

Message ID 20230919073727.540207-1-yanjun.zhu@intel.com (mailing list archive)
State Accepted
Headers show
Series [v2,1/1] RDMA/rtrs: Require holding rcu_read_lock explicitly | expand

Commit Message

Zhu Yanjun Sept. 19, 2023, 7:37 a.m. UTC
From: Zhu Yanjun <yanjun.zhu@linux.dev>

No functional change. The function get_next_path_rr needs to hold
rcu_read_lock. As such, if no rcu read lock, warnings will pop out.

Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
---
V1->V2: Replace WARN_ON_ONCE with RCU_LOCKDEP_WARN
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky Sept. 19, 2023, 8:23 a.m. UTC | #1
On Tue, 19 Sep 2023 15:37:27 +0800, Zhu Yanjun wrote:
> No functional change. The function get_next_path_rr needs to hold
> rcu_read_lock. As such, if no rcu read lock, warnings will pop out.
> 
> 

Applied, thanks!

[1/1] RDMA/rtrs: Require holding rcu_read_lock explicitly
      https://git.kernel.org/rdma/rdma/c/20a02837fb5e16

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index b6ee801fd0ff..07261523c554 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -775,7 +775,7 @@  rtrs_clt_get_next_path_or_null(struct list_head *head, struct rtrs_clt_path *clt
  * Related to @MP_POLICY_RR
  *
  * Locks:
- *    rcu_read_lock() must be hold.
+ *    rcu_read_lock() must be held.
  */
 static struct rtrs_clt_path *get_next_path_rr(struct path_it *it)
 {
@@ -783,6 +783,11 @@  static struct rtrs_clt_path *get_next_path_rr(struct path_it *it)
 	struct rtrs_clt_path *path;
 	struct rtrs_clt_sess *clt;
 
+	/*
+	 * Assert that rcu lock must be held
+	 */
+	RCU_LOCKDEP_WARN(!rcu_read_lock_held(), "no rcu read lock held");
+
 	clt = it->clt;
 
 	/*