From: Joel Fernandes <joelagnelf@nvidia.com>
To: linux-kernel@vger.kernel.org
Cc: "Paul E . McKenney" <paulmck@kernel.org>,
Boqun Feng <boqun.feng@gmail.com>,
rcu@vger.kernel.org, Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
Uladzislau Rezki <urezki@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>,
Joel Fernandes <joelagnelf@nvidia.com>
Subject: [PATCH -next v2 2/4] rcu/nocb: Add warning if no rcuog wake up attempt happened during overload
Date: Wed, 14 Jan 2026 12:31:52 -0500 [thread overview]
Message-ID: <20260114173154.1701056-3-joelagnelf@nvidia.com> (raw)
In-Reply-To: <20260114173154.1701056-1-joelagnelf@nvidia.com>
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]
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
kernel/rcu/tree.c | 4 ++++
kernel/rcu/tree.h | 1 +
kernel/rcu/tree_nocb.h | 11 ++++++++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 2921ffb19939..958b61be87ea 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -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);
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
index 7dfc57e9adb1..af1d065e3215 100644
--- a/kernel/rcu/tree.h
+++ b/kernel/rcu/tree.h
@@ -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,
diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index f525e4f7985b..acca24670a8c 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -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
next prev parent reply other threads:[~2026-01-14 17:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 17:31 [PATCH -next v2 0/4] rcu/nocb: Cleanup patches for next merge window Joel Fernandes
2026-01-14 17:31 ` [PATCH -next v2 1/4] rcu/nocb: Remove unnecessary WakeOvfIsDeferred wake path Joel Fernandes
2026-01-14 17:31 ` Joel Fernandes [this message]
2026-01-16 14:42 ` [PATCH -next v2 2/4] rcu/nocb: Add warning if no rcuog wake up attempt happened during overload joelagnelf
2026-01-16 21:56 ` Frederic Weisbecker
2026-01-19 22:04 ` Joel Fernandes
2026-01-14 17:31 ` [PATCH -next v2 3/4] rcu/nocb: Add warning to detect if overload advancement is ever useful Joel Fernandes
2026-01-16 22:42 ` Frederic Weisbecker
2026-01-19 21:34 ` Joel Fernandes
2026-01-14 17:31 ` [PATCH -next v2 4/4] rcu/nocb: Extract nocb_defer_wakeup_cancel() helper Joel Fernandes
2026-01-16 22:49 ` Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260114173154.1701056-3-joelagnelf@nvidia.com \
--to=joelagnelf@nvidia.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox