Skip to contentSkip to conversation

rcu/nocb: Cleanup patches for next merge window

PATCH Superseded Joel Fernandes 2 participants 11 messages Jan 14 – Jan 19 RCU

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Joel Fernandes

author maintainer
#0 lore raw

v2 cover rcu/nocb: Cleanup patches for next merge window

These are few nocb related cleanup patches for the next merge window that I am resending. The fourth patch is trivial extraction of duplicate code for canceling deferred wakeups.

I did not hear back about opinions on "Add warning to detect if overload advancement is ever useful" [1] so I will hold off on deleting that code path till the next merge window (for now the patch is just adding a warning).

Changes from v1:
- Added patch 4 to extract nocb_defer_wakeup_cancel() helper
- Add Frederic's review talk to "Remove unnecessary WakeOvfIsDeferred wake path"

nocb rcutorture scenarios passed overnight testing on my system.

The git tree with all patches can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git (tag: rcu-nocb-v2-20260114)

Link to v1: https://lore.kernel.org/all/[email protected]/

[1] https://lore.kernel.org/all/[email protected]/#t

Joel Fernandes (4):
rcu/nocb: Remove unnecessary WakeOvfIsDeferred wake path rcu/nocb: Add warning if no rcuog wake up attempt happened during
overload
rcu/nocb: Add warning to detect if overload advancement is ever useful rcu/nocb: Extract nocb_defer_wakeup_cancel() helper

 kernel/rcu/tree.c      |  6 ++-
 kernel/rcu/tree.h      |  4 +-
 kernel/rcu/tree_nocb.h | 91 +++++++++++++++++++++++-------------------
 3 files changed, 56 insertions(+), 45 deletions(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v2 1/4 rcu/nocb: Remove unnecessary WakeOvfIsDeferred wake path

The WakeOvfIsDeferred code path in __call_rcu_nocb_wake() attempts to wake rcuog when the callback count exceeds qhimark and callbacks aren't done with their GP (newly queued or awaiting GP). However, a lot of testing proves this wake is always redundant or useless.

In the flooding case, rcuog is always waiting for a GP to finish. So waking up the rcuog thread is pointless. The timer wakeup adds overhead, rcuog simply wakes up and goes back to sleep achieving nothing.

This path also adds a full memory barrier, and additional timer expiry modifications unnecessarily.

The root cause is that WakeOvfIsDeferred fires when !rcu_segcblist_ready_cbs() (GP not complete), but waking rcuog cannot accelerate GP completion.

This commit therefore removes this path.

Tested with rcutorture scenarios: TREE01, TREE05, TREE08 (all NOCB configurations) - all pass. Also stress tested using a kernel module that floods call_rcu() to trigger the overload conditions and made the observations confirming the findings.

---
 kernel/rcu/tree.c      |  2 +-
 kernel/rcu/tree.h      |  3 +--
 kernel/rcu/tree_nocb.h | 49 ++++++++++++++----------------------------
 3 files changed, 18 insertions(+), 36 deletions(-)
kernel/rcu/tree.c +1 -1
index 293bbd9ac3f4..2921ffb19939 100644
@@ -3769,7 +3769,7 @@ static void rcu_barrier_entrain(struct rcu_data *rdp)
 	}
 	rcu_nocb_unlock(rdp);
 	if (wake_nocb)
-		wake_nocb_gp(rdp, false);
+		wake_nocb_gp(rdp);
 	smp_store_release(&rdp->barrier_seq_snap, gseq);
 }
 
kernel/rcu/tree.h +1 -2
index 2265b9c2906e..7dfc57e9adb1 100644
@@ -301,7 +301,6 @@ struct rcu_data {
 #define RCU_NOCB_WAKE_BYPASS	1
 #define RCU_NOCB_WAKE_LAZY	2
 #define RCU_NOCB_WAKE		3
-#define RCU_NOCB_WAKE_FORCE	4
 
 #define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500))
 					/* For jiffies_till_first_fqs and */
@@ -500,7 +499,7 @@ static void zero_cpu_stall_ticks(struct rcu_data *rdp);
 static struct swait_queue_head *rcu_nocb_gp_get(struct rcu_node *rnp);
 static void rcu_nocb_gp_cleanup(struct swait_queue_head *sq);
 static void rcu_init_one_nocb(struct rcu_node *rnp);
-static bool wake_nocb_gp(struct rcu_data *rdp, bool force);
+static bool wake_nocb_gp(struct rcu_data *rdp);
 static bool rcu_nocb_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
 				  unsigned long j, bool lazy);
 static void call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *head,
kernel/rcu/tree_nocb.h +16 -33

139 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v2 2/4 rcu/nocb: Add warning if no rcuog wake up attempt happened during overload

In reply to Joel Fernandes

To be sure we have no rcog wake ups that were lost, add a warning to cover the case where the rdp is overloaded with callbacks but no wake up was attempted.

[applied Frederic's adjustment to clearing of nocb_gp_handling flag]

---
 kernel/rcu/tree.c      |  4 ++++
 kernel/rcu/tree.h      |  1 +
 kernel/rcu/tree_nocb.h | 11 ++++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +4 -0
index 2921ffb19939..958b61be87ea 100644
@@ -3767,6 +3767,10 @@ static void rcu_barrier_entrain(struct rcu_data *rdp)
 		debug_rcu_head_unqueue(&rdp->barrier_head);
 		rcu_barrier_trace(TPS("IRQNQ"), -1, rcu_state.barrier_sequence);
 	}
+#ifdef CONFIG_RCU_NOCB_CPU
+	/* wake_nocb implies all CBs queued before were bypass/lazy. */
+	WARN_ON_ONCE(wake_nocb && !rdp->nocb_gp_handling);
+#endif
 	rcu_nocb_unlock(rdp);
 	if (wake_nocb)
 		wake_nocb_gp(rdp);
kernel/rcu/tree.h +1 -0
index 7dfc57e9adb1..af1d065e3215 100644
@@ -257,6 +257,7 @@ struct rcu_data {
 	unsigned long nocb_gp_loops;	/* # passes through wait code. */
 	struct swait_queue_head nocb_gp_wq; /* For nocb kthreads to sleep on. */
 	bool nocb_cb_sleep;		/* Is the nocb CB thread asleep? */
+	bool nocb_gp_handling;		/* Is rcuog handling this rdp? */
 	struct task_struct *nocb_cb_kthread;
 	struct list_head nocb_head_rdp; /*
 					 * Head of rcu_data list in wakeup chain,
kernel/rcu/tree_nocb.h +10 -1
index f525e4f7985b..acca24670a8c 100644
@@ -546,6 +546,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 	lazy_len = READ_ONCE(rdp->lazy_len);
 	if (was_alldone) {
 		rdp->qlen_last_fqs_check = len;
+		rdp->nocb_gp_handling = true;
 		rcu_nocb_unlock(rdp);
 		// Only lazy CBs in bypass list
 		if (lazy_len && bypass_len == lazy_len) {
@@ -563,7 +564,8 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 
 		return;
 	} else if (len > rdp->qlen_last_fqs_check + qhimark) {
-		/* ... or if many callbacks queued. */
+		/* Callback overload condition. */
+		WARN_ON_ONCE(!rdp->nocb_gp_handling);
 		rdp->qlen_last_fqs_check = len;
 		j = jiffies;
 		if (j != rdp->nocb_gp_adv_time &&
@@ -732,6 +734,12 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
 			needwait_gp = true;
 			trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,
 					    TPS("NeedWaitGP"));
+		} else if (!rcu_cblist_n_cbs(&rdp->nocb_bypass)) {
+			/*
+			 * No pending callbacks and no bypass callbacks.
+			 * The rcuog kthread is done handling this rdp.
+			 */
+			rdp->nocb_gp_handling = false;
 		}
 		if (rcu_segcblist_ready_cbs(&rdp->cblist)) {
 			needwake = rdp->nocb_cb_sleep;
@@ -1254,6 +1262,7 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 			continue;
 		}
 		rcu_nocb_try_flush_bypass(rdp, jiffies);
+		rdp->nocb_gp_handling = true;
 		rcu_nocb_unlock_irqrestore(rdp, flags);
 		wake_nocb_gp(rdp);
 		sc->nr_to_scan -= _count;
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

Re: [PATCH -next v2 2/4] rcu/nocb: Add warning if no rcuog wake up attempt happened during overload

Quoted 6 lines · Joel Fernandes

To be sure we have no rcog wake ups that were lost, add a warning to cover the case where the rdp is overloaded with callbacks but no wake up was attempted.

[applied Frederic's adjustment to clearing of nocb_gp_handling flag]

Frederic,

Is it possible for you to do a quick review of these last few? They're mostly simple. It would be great if we can pick it for this upcoming merge window.

Thanks!

- Joel

Quoted 80 lines

---

kernel/rcu/tree.c      |  4 ++++
kernel/rcu/tree.h      |  1 +
kernel/rcu/tree_nocb.h | 11 ++++++++++-
3 files changed, 15 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +4 -0
index 2921ffb19939..958b61be87ea 100644
@@ -3767,6 +3767,10 @@ static void rcu_barrier_entrain(struct rcu_data *rdp)
       debug_rcu_head_unqueue(&rdp->barrier_head);
       rcu_barrier_trace(TPS("IRQNQ"), -1, rcu_state.barrier_sequence);
   }
+#ifdef CONFIG_RCU_NOCB_CPU
+    /* wake_nocb implies all CBs queued before were bypass/lazy. */
+    WARN_ON_ONCE(wake_nocb && !rdp->nocb_gp_handling);
+#endif
   rcu_nocb_unlock(rdp);
   if (wake_nocb)
       wake_nocb_gp(rdp);
kernel/rcu/tree.h +1 -0
index 7dfc57e9adb1..af1d065e3215 100644
@@ -257,6 +257,7 @@ struct rcu_data {
   unsigned long nocb_gp_loops;    /* # passes through wait code. */
   struct swait_queue_head nocb_gp_wq; /* For nocb kthreads to sleep on. */
   bool nocb_cb_sleep;        /* Is the nocb CB thread asleep? */
+    bool nocb_gp_handling;        /* Is rcuog handling this rdp? */
   struct task_struct *nocb_cb_kthread;
   struct list_head nocb_head_rdp; /*
                    * Head of rcu_data list in wakeup chain,
kernel/rcu/tree_nocb.h +10 -2
index f525e4f7985b..acca24670a8c 100644
@@ -546,6 +546,7 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
   lazy_len = READ_ONCE(rdp->lazy_len);
   if (was_alldone) {
       rdp->qlen_last_fqs_check = len;
+        rdp->nocb_gp_handling = true;
       rcu_nocb_unlock(rdp);
       // Only lazy CBs in bypass list
       if (lazy_len && bypass_len == lazy_len) {
@@ -563,7 +564,8 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 
       return;
   } else if (len > rdp->qlen_last_fqs_check + qhimark) {
-        /* ... or if many callbacks queued. */
+        /* Callback overload condition. */
+        WARN_ON_ONCE(!rdp->nocb_gp_handling);
       rdp->qlen_last_fqs_check = len;
       j = jiffies;
       if (j != rdp->nocb_gp_adv_time &&
@@ -732,6 +734,12 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
           needwait_gp = true;
           trace_rcu_nocb_wake(rcu_state.name, rdp->cpu,
                       TPS("NeedWaitGP"));
+        } else if (!rcu_cblist_n_cbs(&rdp->nocb_bypass)) {
+            /*
+             * No pending callbacks and no bypass callbacks.
+             * The rcuog kthread is done handling this rdp.
+             */
+            rdp->nocb_gp_handling = false;
       }
       if (rcu_segcblist_ready_cbs(&rdp->cblist)) {
           needwake = rdp->nocb_cb_sleep;
@@ -1254,6 +1262,7 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
           continue;
       }
       rcu_nocb_try_flush_bypass(rdp, jiffies);
+        rdp->nocb_gp_handling = true;
       rcu_nocb_unlock_irqrestore(rdp, flags);
       wake_nocb_gp(rdp);
       sc->nr_to_scan -= _count;
--

2.34.1

#4 lore raw

Re: [PATCH -next v2 2/4] rcu/nocb: Add warning if no rcuog wake up attempt happened during overload

In reply to Joel Fernandes

kernel/rcu/tree_nocb.h lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 1265

Quoted 5 lines · Joel Fernandes
kernel/rcu/tree_nocb.h +1 -0
@@ -1254,6 +1262,7 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 			continue;
 		}
 		rcu_nocb_try_flush_bypass(rdp, jiffies);
+		rdp->nocb_gp_handling = true;

It should be true already, right?

kernel/rcu/tree_nocb.h lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 1268

Quoted 3 lines
kernel/rcu/tree_nocb.h +0 -0
 		rcu_nocb_unlock_irqrestore(rdp, flags);
 		wake_nocb_gp(rdp);
 		sc->nr_to_scan -= _count;

Thanks.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs
author maintainer
#5 lore raw

Re: [PATCH -next v2 2/4] rcu/nocb: Add warning if no rcuog wake up attempt happened during overload

Quoted 9 lines · Frederic Weisbecker

kernel/rcu/tree_nocb.h lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · line 1265

Quoted 5 lines · Joel Fernandes
kernel/rcu/tree_nocb.h +1 -0
@@ -1254,6 +1262,7 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
  			continue;
  		}
  		rcu_nocb_try_flush_bypass(rdp, jiffies);
+		rdp->nocb_gp_handling = true;

It should be true already, right?

Yes! I will drop this hunk on respin, thanks.

- Joel

author maintainer
#6 lore raw

PATCH v2 3/4 rcu/nocb: Add warning to detect if overload advancement is ever useful

In reply to Joel Fernandes

During callback overload, the NOCB code attempts an opportunistic advancement via rcu_advance_cbs_nowake().

Analysis via tracing with 300,000 callbacks flooded shows this optimization is likely dead code:
- 30 overload conditions triggered
- 0 advancements actually occurred
- 100% of time no advancement due to current GP not done.

I also ran TREE05 and TREE08 for 2 hours and cannot trigger it.

When callbacks overflow (exceed qhimark), they are waiting for a grace period that hasn't completed yet. The optimization requires the GP to be complete to advance callbacks, but the overload condition itself is caused by callbacks piling up faster than GPs can complete. This creates a logical contradiction where the advancement cannot happen.

In *theory* this might be possible, the GP completed just in the nick of time as we hit the overload, but this is just so rare that it can be considered impossible when we cannot even hit it with synthetic callback flooding even, it is a waste of cycles to even try to advance, let alone be useful and is a maintenance burden complexity we don't need.

I suggest deletion. However, add a WARN_ON_ONCE for a merge window or 2 and delete it after out of extreme caution.

---
 kernel/rcu/tree_nocb.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
kernel/rcu/tree_nocb.h +12 -0
index acca24670a8c..702ede003dce 100644
@@ -571,8 +571,20 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_alldone,
 		if (j != rdp->nocb_gp_adv_time &&
 		    rcu_segcblist_nextgp(&rdp->cblist, &cur_gp_seq) &&
 		    rcu_seq_done(&rdp->mynode->gp_seq, cur_gp_seq)) {
+			long done_before = rcu_segcblist_get_seglen(&rdp->cblist, RCU_DONE_TAIL);
+
 			rcu_advance_cbs_nowake(rdp->mynode, rdp);
 			rdp->nocb_gp_adv_time = j;
+
+			/*
+			 * The advance_cbs call above is not useful. Under an
+			 * overload condition, nocb_gp_wait() is always waiting
+			 * for GP completion, due to this nothing can be moved
+			 * from WAIT to DONE, in the list. WARN if an
+			 * advancement happened (next step is deletion of advance).
+			 */
+			WARN_ON_ONCE(rcu_segcblist_get_seglen(&rdp->cblist,
+				     RCU_DONE_TAIL) > done_before);
 		}
 	}
 
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH -next v2 3/4] rcu/nocb: Add warning to detect if overload advancement is ever useful

Quoted 17 lines · Joel Fernandes

During callback overload, the NOCB code attempts an opportunistic advancement via rcu_advance_cbs_nowake().

Analysis via tracing with 300,000 callbacks flooded shows this optimization is likely dead code:
- 30 overload conditions triggered
- 0 advancements actually occurred
- 100% of time no advancement due to current GP not done.

I also ran TREE05 and TREE08 for 2 hours and cannot trigger it.

When callbacks overflow (exceed qhimark), they are waiting for a grace period that hasn't completed yet. The optimization requires the GP to be complete to advance callbacks, but the overload condition itself is caused by callbacks piling up faster than GPs can complete. This creates a logical contradiction where the advancement cannot happen.

Quoted 5 lines

In *theory* this might be possible, the GP completed just in the nick of time as we hit the overload, but this is just so rare that it can be considered impossible when we cannot even hit it with synthetic callback flooding even, it is a waste of cycles to even try to advance, let alone be useful and is a maintenance burden complexity we don't need.

Rare is far from impossible with billions of android devices living out there.

I can imagine the warning to just hit if the flooding callback enqueuer happen to hit the qhimark right after the GP has completed but before nocb_gp_wait() managed yet to advance the callbacks.

But what would that prove then?

Quoted 3 lines

I suggest deletion. However, add a WARN_ON_ONCE for a merge window or 2 and delete it after out of extreme caution.

2 merge windows is the least of time for that warning to ever land on the billions machines. My phone still runs a v5.4 kernel :-)

And the patch doesn't quite qualify for a stable backport.

Anyway, consider an unpleasant case where nocb_gp_wait() is starving for example. How would just advancing the callbacks help? We still need nocb_gp_wait() to run its round to eventually wake up nocb_cb_wait() so that the done callbacks are executed. And before doing that, it needs to advance the callbacks anyway...

I'm personally in favour of removing this right away instead, unless Paul has a good reason that I missed?

Thanks.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs
author maintainer
#8 lore raw

Re: [PATCH -next v2 3/4] rcu/nocb: Add warning to detect if overload advancement is ever useful

Quoted 24 lines · Frederic Weisbecker
Quoted 17 lines · Joel Fernandes

During callback overload, the NOCB code attempts an opportunistic advancement via rcu_advance_cbs_nowake().

Analysis via tracing with 300,000 callbacks flooded shows this optimization is likely dead code:
- 30 overload conditions triggered
- 0 advancements actually occurred
- 100% of time no advancement due to current GP not done.

I also ran TREE05 and TREE08 for 2 hours and cannot trigger it.

When callbacks overflow (exceed qhimark), they are waiting for a grace period that hasn't completed yet. The optimization requires the GP to be complete to advance callbacks, but the overload condition itself is caused by callbacks piling up faster than GPs can complete. This creates a logical contradiction where the advancement cannot happen.

Quoted 5 lines

In *theory* this might be possible, the GP completed just in the nick of time as we hit the overload, but this is just so rare that it can be considered impossible when we cannot even hit it with synthetic callback flooding even, it is a waste of cycles to even try to advance, let alone be useful and is a maintenance burden complexity we don't need.

Quoted 7 lines

Rare is far from impossible with billions of android devices living out there.

I can imagine the warning to just hit if the flooding callback enqueuer happen to hit the qhimark right after the GP has completed but before nocb_gp_wait() managed yet to advance the callbacks.

But what would that prove then?

I agree with you. I think the original goal of this code path was to help nocb_gp_wait() by doing some of the advancement work early when we already know we're in an overload situation. But in all my testing, the cblist is already advanced by the time we get here - making this path pointless as you noted.

Quoted 8 lines
Quoted 2 lines

I suggest deletion. However, add a WARN_ON_ONCE for a merge window or 2 and delete it after out of extreme caution.

2 merge windows is the least of time for that warning to ever land on the billions machines. My phone still runs a v5.4 kernel :-)

And the patch doesn't quite qualify for a stable backport.

Quoted 8 lines

Anyway, consider an unpleasant case where nocb_gp_wait() is starving for example. How would just advancing the callbacks help? We still need nocb_gp_wait() to run its round to eventually wake up nocb_cb_wait() so that the done callbacks are executed. And before doing that, it needs to advance the callbacks anyway...

I'm personally in favour of removing this right away instead, unless Paul has a good reason that I missed?

Agreed. Unless I hear otherwise from others, I will delete it in my respin. I also agree that it is better to delete it sooner rather than later - waiting for a merge window or two buys us very little given the latency of kernel release ending in product.

Thanks,

- Joel

author maintainer
#9 lore raw

PATCH v2 4/4 rcu/nocb: Extract nocb_defer_wakeup_cancel() helper

In reply to Joel Fernandes

The pattern of checking nocb_defer_wakeup and deleting the timer is duplicated in __wake_nocb_gp() and nocb_gp_wait(). Extract this into a common helper function nocb_defer_wakeup_cancel().

This removes code duplication and makes it easier to maintain.

---
 kernel/rcu/tree_nocb.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
kernel/rcu/tree_nocb.h +11 -8
index 702ede003dce..df49c2fa79c5 100644
@@ -190,6 +190,15 @@ static void rcu_init_one_nocb(struct rcu_node *rnp)
 	init_swait_queue_head(&rnp->nocb_gp_wq[1]);
 }
 
+/* Clear any pending deferred wakeup timer (nocb_gp_lock must be held). */
+static void nocb_defer_wakeup_cancel(struct rcu_data *rdp_gp)
+{
+	if (rdp_gp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
+		WRITE_ONCE(rdp_gp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
+		timer_delete(&rdp_gp->nocb_timer);
+	}
+}
+
 static bool __wake_nocb_gp(struct rcu_data *rdp_gp,
 			   struct rcu_data *rdp,
 			   unsigned long flags)
@@ -204,10 +213,7 @@ static bool __wake_nocb_gp(struct rcu_data *rdp_gp,
 		return false;
 	}
 
-	if (rdp_gp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
-		WRITE_ONCE(rdp_gp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
-		timer_delete(&rdp_gp->nocb_timer);
-	}
+	nocb_defer_wakeup_cancel(rdp_gp);
 
 	if (READ_ONCE(rdp_gp->nocb_gp_sleep)) {
 		WRITE_ONCE(rdp_gp->nocb_gp_sleep, false);
@@ -820,10 +826,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
 		if (rdp_toggling)
 			my_rdp->nocb_toggling_rdp = NULL;
 
-		if (my_rdp->nocb_defer_wakeup > RCU_NOCB_WAKE_NOT) {
-			WRITE_ONCE(my_rdp->nocb_defer_wakeup, RCU_NOCB_WAKE_NOT);
-			timer_delete(&my_rdp->nocb_timer);
-		}
+		nocb_defer_wakeup_cancel(my_rdp);
 		WRITE_ONCE(my_rdp->nocb_gp_sleep, true);
 		raw_spin_unlock_irqrestore(&my_rdp->nocb_gp_lock, flags);
 	} else {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 4/4
#10 lore raw

Re: [PATCH -next v2 4/4] rcu/nocb: Extract nocb_defer_wakeup_cancel() helper

Quoted 7 lines · Joel Fernandes

The pattern of checking nocb_defer_wakeup and deleting the timer is duplicated in __wake_nocb_gp() and nocb_gp_wait(). Extract this into a common helper function nocb_defer_wakeup_cancel().

This removes code duplication and makes it easier to maintain.

Signature · 2 lines
Frederic Weisbecker
SUSE Labs