Skip to contentSkip to conversation

rcu: tree_stall: Correctly unlock root node in rcu_check_gp_start_stall

PATCH Applied Neeraj Upadhyay 3 participants 6 messages Mar 29, 2019 – Apr 4, 2019 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: tree_stall: Correctly unlock root node in rcu_check_gp_start_stall

Only unlock the root node, if current node (rnp) is not root node.

---
 kernel/rcu/tree_stall.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/rcu/tree_stall.h +3 -1
index f65a73a..0651833 100644
@@ -630,7 +630,9 @@ static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp,
 	    time_before(j, rcu_state.gp_req_activity + gpssdelay) ||
 	    time_before(j, rcu_state.gp_activity + gpssdelay) ||
 	    atomic_xchg(&warned, 1)) {
-		raw_spin_unlock_rcu_node(rnp_root); /* irqs remain disabled. */
+		if (rnp_root != rnp)
+			/* irqs remain disabled. */
+			raw_spin_unlock_rcu_node(rnp_root);
 		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
 		return;
 	}
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
Reviewed-by on v1 1/1
#1 lore raw

kernel/rcu/tree_stall.h

Quoted 15 lines · Neeraj Upadhyay

Only unlock the root node, if current node (rnp) is not root node.

---
  kernel/rcu/tree_stall.h | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
kernel/rcu/tree_stall.h +0 -0
index f65a73a..0651833 100644

why this is showing as under tree_stall.h while it is under "kernel/rcu/tree.c"

kernel/rcu/tree_stall.h static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp, · line 635

Quoted 8 lines
kernel/rcu/tree_stall.h +3 -1
@@ -630,7 +630,9 @@ static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp,
  	    time_before(j, rcu_state.gp_req_activity + gpssdelay) ||
  	    time_before(j, rcu_state.gp_activity + gpssdelay) ||
  	    atomic_xchg(&warned, 1)) {
-		raw_spin_unlock_rcu_node(rnp_root); /* irqs remain disabled. */
+		if (rnp_root != rnp)
+			/* irqs remain disabled. */
+			raw_spin_unlock_rcu_node(rnp_root);

Looks good as it will balance the lock .if it is the root_node, which was not there earlier, and unlock was happening without any lock on root.

Cheers,
-Mukesh

Quoted 3 lines
kernel/rcu/tree_stall.h +0 -0
  		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
  		return;
  	}
#2 lore raw
Quoted 13 lines · Mukesh Ojha
Quoted 11 lines · Neeraj Upadhyay

Only unlock the root node, if current node (rnp) is not root node.

---
  kernel/rcu/tree_stall.h | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 7 lines

kernel/rcu/tree_stall.h

Quoted 4 lines
kernel/rcu/tree_stall.h +0 -0
index f65a73a..0651833 100644

why this is showing as under tree_stall.h while it is under "kernel/rcu/tree.c"

It's moved in https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev&id=10462d6f58fb6dbde7563e9343505d98d5bfba3d

Please see linux-rcu dev tree for other changes, which moves code to this file.

Thanks
Neeraj

Quoted 21 lines
Quoted 10 lines
kernel/rcu/tree_stall.h +0 -0
@@ -630,7 +630,9 @@ static void rcu_check_gp_start_stall(struct 
 rcu_node *rnp, struct rcu_data *rdp,

          time_before(j, rcu_state.gp_req_activity + gpssdelay) || time_before(j, rcu_state.gp_activity + gpssdelay) || atomic_xchg(&warned, 1)) {
-        raw_spin_unlock_rcu_node(rnp_root); /* irqs remain disabled. */ +        if (rnp_root != rnp)
+            /* irqs remain disabled. */
+            raw_spin_unlock_rcu_node(rnp_root);

Looks good as it will balance the lock .if it is the root_node, which was not there earlier, and unlock was happening without any lock on root.

Cheers,
-Mukesh

Quoted 3 lines

          raw_spin_unlock_irqrestore_rcu_node(rnp, flags); return;
      }

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw
Quoted 25 lines · Neeraj Upadhyay
Quoted 13 lines · Mukesh Ojha
Quoted 11 lines · Neeraj Upadhyay

Only unlock the root node, if current node (rnp) is not root node.

---
  kernel/rcu/tree_stall.h | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 8 lines

kernel/rcu/tree_stall.h

Quoted 4 lines
kernel/rcu/tree_stall.h +0 -0
index f65a73a..0651833 100644

why this is showing as under tree_stall.h while it is under "kernel/rcu/tree.c"

Quoted 25 lines

It's moved in https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev&id=10462d6f58fb6dbde7563e9343505d98d5bfba3d

Please see linux-rcu dev tree for other changes, which moves code to this file.

Thanks
Neeraj

Quoted 16 lines
Quoted 10 lines
kernel/rcu/tree_stall.h +0 -0
@@ -630,7 +630,9 @@ static void rcu_check_gp_start_stall(struct
 rcu_node *rnp, struct rcu_data *rdp,

          time_before(j, rcu_state.gp_req_activity + gpssdelay) || time_before(j, rcu_state.gp_activity + gpssdelay) || atomic_xchg(&warned, 1)) {
-        raw_spin_unlock_rcu_node(rnp_root); /* irqs remain disabled. */ +        if (rnp_root != rnp)
+            /* irqs remain disabled. */
+            raw_spin_unlock_rcu_node(rnp_root);

Looks good as it will balance the lock .if it is the root_node, which was not there earlier, and unlock was happening without any lock on root.

Applied, again thank you both!

In both cases, I updated the commit log, so please check to make sure that I didn't mess anything up.

Thanx, Paul

Quoted 11 lines
Quoted 6 lines

Cheers,
-Mukesh

Quoted 3 lines

          raw_spin_unlock_irqrestore_rcu_node(rnp, flags); return;
      }

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw
Quoted 50 lines · Paul E. McKenney
Quoted 49 lines · Neeraj Upadhyay
Quoted 13 lines · Mukesh Ojha
Quoted 11 lines · Neeraj Upadhyay

Only unlock the root node, if current node (rnp) is not root node.

---
   kernel/rcu/tree_stall.h | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 8 lines

kernel/rcu/tree_stall.h

Quoted 4 lines
kernel/rcu/tree_stall.h +0 -0
index f65a73a..0651833 100644

why this is showing as under tree_stall.h while it is under "kernel/rcu/tree.c"

It's moved in https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev&id=10462d6f58fb6dbde7563e9343505d98d5bfba3d

Please see linux-rcu dev tree for other changes, which moves code to this file.

Thanks
Neeraj

Quoted 15 lines

kernel/rcu/tree_stall.h static void rcu_check_gp_start_stall(struct · line 636

Quoted 10 lines
kernel/rcu/tree_stall.h +3 -1
@@ -630,7 +630,9 @@ static void rcu_check_gp_start_stall(struct
 rcu_node *rnp, struct rcu_data *rdp,
           time_before(j, rcu_state.gp_req_activity + gpssdelay) ||
           time_before(j, rcu_state.gp_activity + gpssdelay) ||
           atomic_xchg(&warned, 1)) {
-        raw_spin_unlock_rcu_node(rnp_root); /* irqs remain disabled. */
+        if (rnp_root != rnp)
+            /* irqs remain disabled. */
+            raw_spin_unlock_rcu_node(rnp_root);

Looks good as it will balance the lock .if it is the root_node, which was not there earlier, and unlock was happening without any lock on root.

Quoted 9 lines
Quoted 1 line
Quoted 1 line

Applied, again thank you both!

In both cases, I updated the commit log, so please check to make sure that I didn't mess anything up.

Thanx, Paul

Thanks Paul. One minor comment on https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev&id=ec6530e763046b6bb1f4c2c2aed49ebc68aae2a0

"it clearly does not make sense to release
both rnp->lock and rnp->lock"

should be rnp->lock and rnp_root->lock

Thanks
Neeraj

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

Cheers,
-Mukesh

Quoted 3 lines
kernel/rcu/tree_stall.h +0 -0
           raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
           return;

      }

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
#5 lore raw
Quoted 61 lines · Neeraj Upadhyay
Quoted 50 lines · Paul E. McKenney
Quoted 49 lines · Neeraj Upadhyay
Quoted 13 lines · Mukesh Ojha
Quoted 11 lines · Neeraj Upadhyay

Only unlock the root node, if current node (rnp) is not root node.

---
  kernel/rcu/tree_stall.h | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 8 lines

kernel/rcu/tree_stall.h

Quoted 4 lines
kernel/rcu/tree_stall.h +0 -0
index f65a73a..0651833 100644

why this is showing as under tree_stall.h while it is under "kernel/rcu/tree.c"

It's moved in https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev&id=10462d6f58fb6dbde7563e9343505d98d5bfba3d

Please see linux-rcu dev tree for other changes, which moves code to this file.

Thanks
Neeraj

Quoted 15 lines
Quoted 10 lines
kernel/rcu/tree_stall.h +0 -0
@@ -630,7 +630,9 @@ static void rcu_check_gp_start_stall(struct
 rcu_node *rnp, struct rcu_data *rdp,

          time_before(j, rcu_state.gp_req_activity + gpssdelay) || time_before(j, rcu_state.gp_activity + gpssdelay) || atomic_xchg(&warned, 1)) {
-        raw_spin_unlock_rcu_node(rnp_root); /* irqs remain disabled. */ +        if (rnp_root != rnp)
+            /* irqs remain disabled. */
+            raw_spin_unlock_rcu_node(rnp_root);

Looks good as it will balance the lock .if it is the root_node, which was not there earlier, and unlock was happening without any lock on root.

Quoted 9 lines
Quoted 1 line
Quoted 1 line

Applied, again thank you both!

In both cases, I updated the commit log, so please check to make sure that I didn't mess anything up.

Thanx, Paul

Quoted 7 lines

Thanks Paul. One minor comment on https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev&id=ec6530e763046b6bb1f4c2c2aed49ebc68aae2a0

"it clearly does not make sense to release
both rnp->lock and rnp->lock"

should be rnp->lock and rnp_root->lock

Good eyes, fixed, thank you!

Thanx, Paul

Quoted 20 lines

Thanks
Neeraj

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

Cheers,
-Mukesh

Quoted 3 lines

          raw_spin_unlock_irqrestore_rcu_node(rnp, flags); return;
      }

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation