Skip to contentSkip to conversation

RDMA/rtrs: Require holding rcu_read_lock explicitly

PATCH Superseded Zhu Yanjun 4 participants 4 messages Sep 18, 2023 – Sep 19, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH 1/1 RDMA/rtrs: Require holding rcu_read_lock explicitly

From: Zhu Yanjun <[email protected]>

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.

---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +6 -1
index b6ee801fd0ff..bc4b70318bf4 100644
@@ -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
+	 */
+	WARN_ON_ONCE(!rcu_read_lock_held());
+
 	clt = it->clt;
 
 	/*
Signature · 1 line
2.40.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

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.

Thx!

Quoted 32 lines
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +6 -2
index b6ee801fd0ff..bc4b70318bf4 100644
@@ -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
+        */
+       WARN_ON_ONCE(!rcu_read_lock_held());
+
        clt = it->clt;
 
        /*
--

2.40.1

#2 lore raw
In reply to Zhu Yanjun
Quoted 24 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

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.

---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +1 -1
index b6ee801fd0ff..bc4b70318bf4 100644
@@ -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)
 {

drivers/infiniband/ulp/rtrs/rtrs-clt.c static struct rtrs_clt_path *get_next_path_rr(struct path_it *it) · line 789

Quoted 7 lines
drivers/infiniband/ulp/rtrs/rtrs-clt.c +4 -0
@@ -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
+	 */
+	WARN_ON_ONCE(!rcu_read_lock_held());

Let's use RCU_LOCKDEP_WARN(..) macro.

Thanks

Quoted 7 lines
drivers/infiniband/ulp/rtrs/rtrs-clt.c +1 -0
+
 	clt = it->clt;
 
 	/*
Signature · 1 line
2.40.1
#3 lore raw
Quoted 28 lines · Leon Romanovsky
Quoted 27 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

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.

---
  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +1 -1
index b6ee801fd0ff..bc4b70318bf4 100644
@@ -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;
 
Quoted 5 lines

drivers/infiniband/ulp/rtrs/rtrs-clt.c static struct rtrs_clt_path *get_next_path_rr(struct path_it *it) · line 789

Quoted 4 lines
drivers/infiniband/ulp/rtrs/rtrs-clt.c +4 -0
+	/*
+	 * Assert that rcu lock must be held
+	 */
+	WARN_ON_ONCE(!rcu_read_lock_held());

Let's use RCU_LOCKDEP_WARN(..) macro.

Got it. Will send v2 very soon.

Zhu Yanjun

Quoted 10 lines

Thanks

Quoted 7 lines
drivers/infiniband/ulp/rtrs/rtrs-clt.c +1 -0
+
  	clt = it->clt;
 
  	/*
Signature · 1 line
2.40.1