Skip to contentSkip to conversation

rcu/nocb: Check rdp_gp->nocb_timer in __call_rcu_nocb_wake()

PATCH In review Zqiang 3 participants 12 messages Jan 17, 2024 – Jan 24, 2024 RCU

lore
Share & tools
lore

Zqiang

author
#0 lore raw

PATCH 1/1 rcu/nocb: Check rdp_gp->nocb_timer in __call_rcu_nocb_wake()

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +2 -1
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {
 			rcu_nocb_unlock(rdp);
 			wake_nocb_gp_defer(rdp, RCU_NOCB_WAKE_FORCE,
 					   TPS("WakeOvfIsDeferred"));
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

In the meantime:

maintainer
#2 lore raw
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03. (In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Thanx, Paul

Quoted 3 lines

In the meantime:

maintainer
#3 lore raw
Quoted 50 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Quoted 6 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03. (In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Oh, and queued for further review and testing, thank you both!

Thanx, Paul

Quoted 3 lines
Quoted 3 lines

In the meantime:

#4 lore raw
In reply to Paul E. McKenney
Quoted 41 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Quoted 8 lines

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Quoted 8 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Interesting, are those recent? Bisectable?

Thanks!

maintainer
#5 lore raw
Quoted 57 lines · Frederic Weisbecker
Quoted 41 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Quoted 8 lines

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Quoted 3 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

Quoted 6 lines
Quoted 4 lines

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Interesting, are those recent? Bisectable?

Bisection in progress, got it down to 10 commits. Yet again about ten hours per step on 20 systems...

Though maybe I should have put more time into making it happen faster. Except that I was on travel, so I doubt that I would have made all that much progress. ;-)

Thanx, Paul

Thanx, Paul

maintainer
#6 lore raw
Quoted 63 lines · Paul E. McKenney
Quoted 62 lines · Frederic Weisbecker
Quoted 41 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Quoted 8 lines

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Quoted 7 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Quoted 8 lines
Quoted 1 line

Interesting, are those recent? Bisectable?

Bisection in progress, got it down to 10 commits. Yet again about ten hours per step on 20 systems...

Though maybe I should have put more time into making it happen faster. Except that I was on travel, so I doubt that I would have made all that much progress. ;-)

And it hit this one, which you encountered earlier:

5c0930ccaad5 ("hrtimers: Push pending hrtimers away from outgoing CPU earlier")

Which you fixed with this guy:

600310bd7ea8 ("rcu: Defer RCU kthreads wakeup when CPU is dying")

Which is not yet in -next. Which means I have spent an embarrassing amount of time bisecting a bug that you already fixed. C'est la vie!

Given that v6.8-rc1 is now out, it is time to get a bunch of RCU commits into -next, including that one! ;-)

Thanx, Paul

maintainer
#7 lore raw
Quoted 79 lines · Paul E. McKenney
Quoted 63 lines · Paul E. McKenney
Quoted 62 lines · Frederic Weisbecker
Quoted 41 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Quoted 8 lines

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Quoted 7 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Quoted 8 lines
Quoted 1 line

Interesting, are those recent? Bisectable?

Bisection in progress, got it down to 10 commits. Yet again about ten hours per step on 20 systems...

Though maybe I should have put more time into making it happen faster. Except that I was on travel, so I doubt that I would have made all that much progress. ;-)

And it hit this one, which you encountered earlier:

5c0930ccaad5 ("hrtimers: Push pending hrtimers away from outgoing CPU earlier")

Which you fixed with this guy:

Quoted 7 lines

600310bd7ea8 ("rcu: Defer RCU kthreads wakeup when CPU is dying")

Which is not yet in -next. Which means I have spent an embarrassing amount of time bisecting a bug that you already fixed. C'est la vie!

Given that v6.8-rc1 is now out, it is time to get a bunch of RCU commits into -next, including that one! ;-)

Now to test your fix on top of the bad commit, and also on top of next-20240110. Just in case...

Thanx, Paul

#8 lore raw
Quoted 82 lines · Paul E. McKenney
Quoted 81 lines · Paul E. McKenney
Quoted 63 lines · Paul E. McKenney
Quoted 62 lines · Frederic Weisbecker
Quoted 41 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Quoted 8 lines

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Quoted 7 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Quoted 8 lines
Quoted 1 line

Interesting, are those recent? Bisectable?

Bisection in progress, got it down to 10 commits. Yet again about ten hours per step on 20 systems...

Though maybe I should have put more time into making it happen faster. Except that I was on travel, so I doubt that I would have made all that much progress. ;-)

And it hit this one, which you encountered earlier:

5c0930ccaad5 ("hrtimers: Push pending hrtimers away from outgoing CPU earlier")

Which you fixed with this guy:

600310bd7ea8 ("rcu: Defer RCU kthreads wakeup when CPU is dying")

Quoted 8 lines
Quoted 5 lines

Which is not yet in -next. Which means I have spent an embarrassing amount of time bisecting a bug that you already fixed. C'est la vie!

Given that v6.8-rc1 is now out, it is time to get a bunch of RCU commits into -next, including that one! ;-)

Now to test your fix on top of the bad commit, and also on top of next-20240110. Just in case...

Thanks!

I may send a v2 at some point within next week. No big change, just a comment and also expand the swake_up_one_online() logic to nocb kthreads as well.

Quoted 2 lines

Thanx, Paul

maintainer
#9 lore raw
Quoted 89 lines · Frederic Weisbecker
Quoted 88 lines · Paul E. McKenney
Quoted 86 lines · Paul E. McKenney
Quoted 63 lines · Paul E. McKenney
Quoted 62 lines · Frederic Weisbecker
Quoted 41 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Quoted 8 lines

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Quoted 7 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Quoted 8 lines
Quoted 1 line

Interesting, are those recent? Bisectable?

Bisection in progress, got it down to 10 commits. Yet again about ten hours per step on 20 systems...

Though maybe I should have put more time into making it happen faster. Except that I was on travel, so I doubt that I would have made all that much progress. ;-)

And it hit this one, which you encountered earlier:

5c0930ccaad5 ("hrtimers: Push pending hrtimers away from outgoing CPU earlier")

Which you fixed with this guy:

600310bd7ea8 ("rcu: Defer RCU kthreads wakeup when CPU is dying")

Which is not yet in -next. Which means I have spent an embarrassing amount of time bisecting a bug that you already fixed. C'est la vie!

Given that v6.8-rc1 is now out, it is time to get a bunch of RCU commits into -next, including that one! ;-)

Quoted 7 lines
Quoted 2 lines

Now to test your fix on top of the bad commit, and also on top of next-20240110. Just in case...

Thanks!

I may send a v2 at some point within next week. No big change, just a comment and also expand the swake_up_one_online() logic to nocb kthreads as well.

Looking forward to it!

Thanx, Paul

maintainer
#10 lore raw
Quoted 93 lines · Paul E. McKenney
Quoted 92 lines · Frederic Weisbecker
Quoted 90 lines · Paul E. McKenney
Quoted 79 lines · Paul E. McKenney
Quoted 63 lines · Paul E. McKenney
Quoted 62 lines · Frederic Weisbecker
Quoted 41 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 23 lines · Zqiang

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	long lazy_len;
 	long len;
 	struct task_struct *t;
+	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	// If we are being polled or there is no kthread, just leave.
 	t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		smp_mb(); /* Enqueue before timer_pending(). */
 		if ((rdp->nocb_cb_sleep ||
 		     !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-		    !timer_pending(&rdp->nocb_timer)) {
+		    !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Quoted 8 lines

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Quoted 7 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Quoted 8 lines
Quoted 1 line

Interesting, are those recent? Bisectable?

Bisection in progress, got it down to 10 commits. Yet again about ten hours per step on 20 systems...

Though maybe I should have put more time into making it happen faster. Except that I was on travel, so I doubt that I would have made all that much progress. ;-)

And it hit this one, which you encountered earlier:

5c0930ccaad5 ("hrtimers: Push pending hrtimers away from outgoing CPU earlier")

Which you fixed with this guy:

Quoted 7 lines

600310bd7ea8 ("rcu: Defer RCU kthreads wakeup when CPU is dying")

Which is not yet in -next. Which means I have spent an embarrassing amount of time bisecting a bug that you already fixed. C'est la vie!

Given that v6.8-rc1 is now out, it is time to get a bunch of RCU commits into -next, including that one! ;-)

Now to test your fix on top of the bad commit, and also on top of next-20240110. Just in case...

Quoted 6 lines
Quoted 4 lines

Thanks!

I may send a v2 at some point within next week. No big change, just a comment and also expand the swake_up_one_online() logic to nocb kthreads as well.

Looking forward to it!

And your fix on top of next-20240110 did the trick. Whew!!! ;-)

Thanx, Paul

author
#11 lore raw
In reply to Frederic Weisbecker
Quoted 46 lines · Paul E. McKenney
Quoted 44 lines · Frederic Weisbecker
Quoted 32 lines · Zqiang
Quoted 23 lines

Currently, only rdp_gp->nocb_timer is used, for nocb_timer of no-rdp_gp structure, the timer_pending() is always return false, this commit therefore need to check rdp_gp->nocb_timer in __call_rcu_nocb_wake().

---
 kernel/rcu/tree_nocb.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +1 -0
index 54971afc3a9b..3f85577bddd4 100644
@@ -564,6 +564,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
  long lazy_len;
  long len;
  struct task_struct *t;
+ struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
  // If we are being polled or there is no kthread, just leave.
  t = READ_ONCE(rdp->nocb_gp_kthread);

kernel/rcu/tree_nocb.h static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone, · line 612

Quoted 5 lines
kernel/rcu/tree_nocb.h +1 -1
@@ -608,7 +609,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
          smp_mb(); /* Enqueue before timer_pending(). */
          if ((rdp->nocb_cb_sleep ||
               !rcu_segcblist_ready_cbs(&rdp->cblist)) &&
-             !timer_pending(&rdp->nocb_timer)) {
+             !timer_pending(&rdp_gp->nocb_timer)) {

Hehe, good eyes ;-)

Quoted 7 lines

I had that change in mind but while checking that area further I actually wondered what is the actual purpose of this RCU_NOCB_WAKE_FORCE thing. If we reach that place, it means that the nocb_gp kthread should be awaken already (or the timer pending), so what does a force wake up solve in that case?

Paul, any recollection of that?

Huh. We never actually do RCU_NOCB_WAKE_FORCE in v6.7, if I followed all the code paths correctly.

Quoted 8 lines
Quoted 5 lines

Historically, I have been worried about lost wakeups. Also, there used to be code paths in which a wakeup was not needed, for example, because we knew that the ending of the current grace period would take care of things. Unless there was some huge pile of callbacks, in which case an immediate wakeup could avoid falling behind a callback flood.

Ok then looks like it's time for me to add RCU_NOCB_WAKE_FORCE removal in my TODO list...unless Zqiang would like to give it a try? :-)

Thank you Frederic, apologies for the delayed reply. I'm currently traveling, after my vacation is over, I would like to try it if it hasn't been done yet :-) .

Thanks
Zqiang

Quoted 13 lines
Quoted 9 lines

Given that rcutorture does test callback flooding, we appear to be OK, but maybe it is time to crank up the flooding more.

On the other hand, I have started seeing the (very) occasional OOM on TREE03.
(In addition to those that show up from time to time on the single-CPU TREE09 scenario.)

Interesting, are those recent? Bisectable?

Thanks!