public inbox for rcu@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC v1 0/4] rcu/nocb: Clean ups and rcutorture test configs
@ 2026-02-24 23:04 Joel Fernandes
  2026-02-24 23:04 ` [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions Joel Fernandes
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Joel Fernandes @ 2026-02-24 23:04 UTC (permalink / raw)
  To: Paul E . McKenney, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu,
	linux-kernel

This series contains clean ups for the RCU NOCB code and adds new
rcutorture test configurations for v7.1.

The first two patches consolidate duplicated code in the NOCB
implementation. The last two patches add new rcutorture configs:
- NOCB01 exercises CONFIG_RCU_LAZY combined with CONFIG_RCU_NOCB_CPU.
- NOCB02 exercises the rcu_nocb_poll polling mode code paths.
These configs are not added to CFLIST to avoid increasing default test
duration. The series passes overnight rcutorture testing.

Joel Fernandes (4):
  rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions
  rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication
  rcutorture: Add NOCB01 config for RCU_LAZY torture testing
  rcutorture: Add NOCB02 config for nocb poll mode testing

 kernel/rcu/tree_nocb.h                        | 140 +++++++++++-------
 .../selftests/rcutorture/configs/rcu/NOCB01   |  21 +++
 .../rcutorture/configs/rcu/NOCB01.boot        |   2 +
 .../selftests/rcutorture/configs/rcu/NOCB02   |  20 +++
 .../rcutorture/configs/rcu/NOCB02.boot        |   3 +
 5 files changed, 129 insertions(+), 57 deletions(-)
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB01
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB01.boot
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions
  2026-02-24 23:04 [PATCH RFC v1 0/4] rcu/nocb: Clean ups and rcutorture test configs Joel Fernandes
@ 2026-02-24 23:04 ` Joel Fernandes
  2026-03-04 15:32   ` Frederic Weisbecker
  2026-02-24 23:04 ` [PATCH RFC v1 2/4] rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication Joel Fernandes
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Joel Fernandes @ 2026-02-24 23:04 UTC (permalink / raw)
  To: Paul E . McKenney, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu,
	linux-kernel

The rcu_nocb_cpu_offload() and rcu_nocb_cpu_deoffload() functions are
nearly duplicates.

Therefore, extract the common logic into rcu_nocb_cpu_toggle_offload()
which takes an 'offload' boolean, and make both exported functions
simple wrappers.

This eliminates a bunch of duplicate code at the call sites, namely
mutex locking, CPU hotplug locking and CPU online checks.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 kernel/rcu/tree_nocb.h | 89 ++++++++++++++++++++++--------------------
 1 file changed, 46 insertions(+), 43 deletions(-)

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index b3337c7231cc..5b041134d6bb 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1081,30 +1081,6 @@ static int rcu_nocb_rdp_deoffload(struct rcu_data *rdp)
 	return 0;
 }
 
-int rcu_nocb_cpu_deoffload(int cpu)
-{
-	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
-	int ret = 0;
-
-	cpus_read_lock();
-	mutex_lock(&rcu_state.nocb_mutex);
-	if (rcu_rdp_is_offloaded(rdp)) {
-		if (!cpu_online(cpu)) {
-			ret = rcu_nocb_rdp_deoffload(rdp);
-			if (!ret)
-				cpumask_clear_cpu(cpu, rcu_nocb_mask);
-		} else {
-			pr_info("NOCB: Cannot CB-deoffload online CPU %d\n", rdp->cpu);
-			ret = -EINVAL;
-		}
-	}
-	mutex_unlock(&rcu_state.nocb_mutex);
-	cpus_read_unlock();
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(rcu_nocb_cpu_deoffload);
-
 static bool rcu_nocb_rdp_offload_wait_cond(struct rcu_data *rdp)
 {
 	unsigned long flags;
@@ -1149,27 +1125,54 @@ static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
 	return 0;
 }
 
+/* Common helper for CPU offload/deoffload operations. */
+static int rcu_nocb_cpu_toggle_offload(int cpu, bool offload)
+{
+	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
+	bool currently_offloaded;
+	int ret = 0;
+
+	cpus_read_lock();
+	mutex_lock(&rcu_state.nocb_mutex);
+
+	currently_offloaded = rcu_rdp_is_offloaded(rdp);
+
+	/* Already in desired state, nothing to do. */
+	if (currently_offloaded == offload)
+		goto out_unlock;
+
+	if (cpu_online(cpu)) {
+		pr_info("NOCB: Cannot CB-%soffload online CPU %d\n",
+			offload ? "" : "de", rdp->cpu);
+		ret = -EINVAL;
+		goto out_unlock;
+	}
+
+	if (offload) {
+		ret = rcu_nocb_rdp_offload(rdp);
+		if (!ret)
+			cpumask_set_cpu(cpu, rcu_nocb_mask);
+	} else {
+		ret = rcu_nocb_rdp_deoffload(rdp);
+		if (!ret)
+			cpumask_clear_cpu(cpu, rcu_nocb_mask);
+	}
+
+out_unlock:
+	mutex_unlock(&rcu_state.nocb_mutex);
+	cpus_read_unlock();
+	return ret;
+}
+
+int rcu_nocb_cpu_deoffload(int cpu)
+{
+	return rcu_nocb_cpu_toggle_offload(cpu, false /* de-offload */);
+}
+EXPORT_SYMBOL_GPL(rcu_nocb_cpu_deoffload);
+
 int rcu_nocb_cpu_offload(int cpu)
 {
-	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
-	int ret = 0;
-
-	cpus_read_lock();
-	mutex_lock(&rcu_state.nocb_mutex);
-	if (!rcu_rdp_is_offloaded(rdp)) {
-		if (!cpu_online(cpu)) {
-			ret = rcu_nocb_rdp_offload(rdp);
-			if (!ret)
-				cpumask_set_cpu(cpu, rcu_nocb_mask);
-		} else {
-			pr_info("NOCB: Cannot CB-offload online CPU %d\n", rdp->cpu);
-			ret = -EINVAL;
-		}
-	}
-	mutex_unlock(&rcu_state.nocb_mutex);
-	cpus_read_unlock();
-
-	return ret;
+	return rcu_nocb_cpu_toggle_offload(cpu, true /* offload */);
 }
 EXPORT_SYMBOL_GPL(rcu_nocb_cpu_offload);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC v1 2/4] rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication
  2026-02-24 23:04 [PATCH RFC v1 0/4] rcu/nocb: Clean ups and rcutorture test configs Joel Fernandes
  2026-02-24 23:04 ` [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions Joel Fernandes
@ 2026-02-24 23:04 ` Joel Fernandes
  2026-03-11 12:58   ` Frederic Weisbecker
  2026-02-24 23:04 ` [PATCH RFC v1 3/4] rcutorture: Add NOCB01 config for RCU_LAZY torture testing Joel Fernandes
  2026-02-24 23:04 ` [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing Joel Fernandes
  3 siblings, 1 reply; 12+ messages in thread
From: Joel Fernandes @ 2026-02-24 23:04 UTC (permalink / raw)
  To: Paul E . McKenney, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu,
	linux-kernel

The bypass flush decision logic is duplicated in rcu_nocb_try_bypass()
and nocb_gp_wait() with similar conditions.

This commit therefore extracts the functionality into a common helper
function nocb_bypass_needs_flush() improving the code readability.

A flush_faster parameter is added to controlling the flushing thresholds
and timeouts. This design was in the original commit d1b222c6be1f
("rcu/nocb: Add bypass callback queueing") to avoid having the GP
kthread aggressively flush the bypass queue.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 kernel/rcu/tree_nocb.h | 51 ++++++++++++++++++++++++++++++------------
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index 5b041134d6bb..57183b60501b 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -378,6 +378,38 @@ static void rcu_nocb_try_flush_bypass(struct rcu_data *rdp, unsigned long j)
 	WARN_ON_ONCE(!rcu_nocb_do_flush_bypass(rdp, NULL, j, false));
 }
 
+/*
+ * Determine if the bypass queue needs to be flushed based on time and size.
+ * For lazy-only bypass queues, use the lazy flush timeout; otherwise flush
+ * based on jiffy advancement. The flush_faster controls flush aggressiveness.
+ */
+static bool nocb_bypass_needs_flush(struct rcu_data *rdp, long bypass_ncbs,
+				    long lazy_ncbs, unsigned long j,
+				    bool flush_faster)
+{
+	bool bypass_is_lazy;
+	unsigned long bypass_first;
+	unsigned long flush_timeout;
+	long qhimark_thresh;
+
+	if (!bypass_ncbs)
+		return false;
+
+	qhimark_thresh = flush_faster ? qhimark : 2 * qhimark;
+	if (bypass_ncbs >= qhimark_thresh)
+		return true;
+
+	bypass_first = READ_ONCE(rdp->nocb_bypass_first);
+	bypass_is_lazy = (bypass_ncbs == lazy_ncbs);
+
+	if (bypass_is_lazy)
+		flush_timeout = rcu_get_jiffies_lazy_flush();
+	else
+		flush_timeout = flush_faster ? 0 : 1;
+
+	return time_after(j, bypass_first + flush_timeout);
+}
+
 /*
  * See whether it is appropriate to use the ->nocb_bypass list in order
  * to control contention on ->nocb_lock.  A limited number of direct
@@ -404,7 +436,8 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
 	unsigned long cur_gp_seq;
 	unsigned long j = jiffies;
 	long ncbs = rcu_cblist_n_cbs(&rdp->nocb_bypass);
-	bool bypass_is_lazy = (ncbs == READ_ONCE(rdp->lazy_len));
+	long lazy_len = READ_ONCE(rdp->lazy_len);
+	bool bypass_is_lazy = (ncbs == lazy_len);
 
 	lockdep_assert_irqs_disabled();
 
@@ -456,10 +489,7 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
 
 	// If ->nocb_bypass has been used too long or is too full,
 	// flush ->nocb_bypass to ->cblist.
-	if ((ncbs && !bypass_is_lazy && j != READ_ONCE(rdp->nocb_bypass_first)) ||
-	    (ncbs &&  bypass_is_lazy &&
-	     (time_after(j, READ_ONCE(rdp->nocb_bypass_first) + rcu_get_jiffies_lazy_flush()))) ||
-	    ncbs >= qhimark) {
+	if (nocb_bypass_needs_flush(rdp, ncbs, lazy_len, j, true)) {
 		rcu_nocb_lock(rdp);
 		*was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
 
@@ -673,15 +703,8 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
 		bypass_ncbs = rcu_cblist_n_cbs(&rdp->nocb_bypass);
 		lazy_ncbs = READ_ONCE(rdp->lazy_len);
 
-		if (bypass_ncbs && (lazy_ncbs == bypass_ncbs) &&
-		    (time_after(j, READ_ONCE(rdp->nocb_bypass_first) + rcu_get_jiffies_lazy_flush()) ||
-		     bypass_ncbs > 2 * qhimark)) {
-			flush_bypass = true;
-		} else if (bypass_ncbs && (lazy_ncbs != bypass_ncbs) &&
-		    (time_after(j, READ_ONCE(rdp->nocb_bypass_first) + 1) ||
-		     bypass_ncbs > 2 * qhimark)) {
-			flush_bypass = true;
-		} else if (!bypass_ncbs && rcu_segcblist_empty(&rdp->cblist)) {
+		flush_bypass = nocb_bypass_needs_flush(rdp, bypass_ncbs, lazy_ncbs, j, false);
+		if (!flush_bypass && !bypass_ncbs && rcu_segcblist_empty(&rdp->cblist)) {
 			rcu_nocb_unlock_irqrestore(rdp, flags);
 			continue; /* No callbacks here, try next. */
 		}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC v1 3/4] rcutorture: Add NOCB01 config for RCU_LAZY torture testing
  2026-02-24 23:04 [PATCH RFC v1 0/4] rcu/nocb: Clean ups and rcutorture test configs Joel Fernandes
  2026-02-24 23:04 ` [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions Joel Fernandes
  2026-02-24 23:04 ` [PATCH RFC v1 2/4] rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication Joel Fernandes
@ 2026-02-24 23:04 ` Joel Fernandes
  2026-03-11 13:02   ` Frederic Weisbecker
  2026-02-24 23:04 ` [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing Joel Fernandes
  3 siblings, 1 reply; 12+ messages in thread
From: Joel Fernandes @ 2026-02-24 23:04 UTC (permalink / raw)
  To: Paul E . McKenney, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu,
	linux-kernel

Add new rcutorture config NOCB01 that enables CONFIG_RCU_LAZY combined
with CONFIG_RCU_NOCB_CPU to exercise the lazy callback code paths in
the NOCB implementation.

This config exercises lazy callback paths not covered by other configs,
including lazy-only wake and lazy defer logic.

This config is not added to CFLIST to avoid increasing the default
test duration; it can be run explicitly when lazy callback testing
is needed.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 .../selftests/rcutorture/configs/rcu/NOCB01   | 21 +++++++++++++++++++
 .../rcutorture/configs/rcu/NOCB01.boot        |  2 ++
 2 files changed, 23 insertions(+)
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB01
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB01.boot

diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB01 b/tools/testing/selftests/rcutorture/configs/rcu/NOCB01
new file mode 100644
index 000000000000..bbe6d28210ab
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB01
@@ -0,0 +1,21 @@
+CONFIG_SMP=y
+CONFIG_NR_CPUS=8
+CONFIG_PREEMPT_NONE=n
+CONFIG_PREEMPT_VOLUNTARY=n
+CONFIG_PREEMPT=y
+#CHECK#CONFIG_PREEMPT_RCU=y
+CONFIG_HZ_PERIODIC=n
+CONFIG_NO_HZ_IDLE=y
+CONFIG_NO_HZ_FULL=n
+CONFIG_RCU_TRACE=y
+CONFIG_HOTPLUG_CPU=y
+CONFIG_RCU_FANOUT=3
+CONFIG_RCU_FANOUT_LEAF=2
+CONFIG_RCU_NOCB_CPU=y
+CONFIG_DEBUG_LOCK_ALLOC=n
+CONFIG_PROVE_LOCKING=n
+CONFIG_RCU_BOOST=n
+CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
+CONFIG_RCU_EXPERT=y
+CONFIG_RCU_EQS_DEBUG=y
+CONFIG_RCU_LAZY=y
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB01.boot b/tools/testing/selftests/rcutorture/configs/rcu/NOCB01.boot
new file mode 100644
index 000000000000..5130bc84c435
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB01.boot
@@ -0,0 +1,2 @@
+rcupdate.rcu_self_test=1
+rcu_nocbs=all
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing
  2026-02-24 23:04 [PATCH RFC v1 0/4] rcu/nocb: Clean ups and rcutorture test configs Joel Fernandes
                   ` (2 preceding siblings ...)
  2026-02-24 23:04 ` [PATCH RFC v1 3/4] rcutorture: Add NOCB01 config for RCU_LAZY torture testing Joel Fernandes
@ 2026-02-24 23:04 ` Joel Fernandes
  2026-02-25 21:47   ` Paul E. McKenney
  2026-03-11 13:03   ` Frederic Weisbecker
  3 siblings, 2 replies; 12+ messages in thread
From: Joel Fernandes @ 2026-02-24 23:04 UTC (permalink / raw)
  To: Paul E . McKenney, Frederic Weisbecker, Neeraj Upadhyay,
	Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu,
	linux-kernel

Add new rcutorture config NOCB02 that enables rcu_nocb_poll boot
parameter combined with CONFIG_RCU_NOCB_CPU to exercise the polling
mode code paths in the NOCB implementation.

This config exercises poll-mode paths not covered by other configs,
where callback invocation uses active polling instead of kthread
wakeups.

This config is not added to CFLIST to avoid increasing the default
test duration; it can be run explicitly when poll-mode testing
is needed.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 .../selftests/rcutorture/configs/rcu/NOCB02   | 20 +++++++++++++++++++
 .../rcutorture/configs/rcu/NOCB02.boot        |  3 +++
 2 files changed, 23 insertions(+)
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02
 create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot

diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB02 b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02
new file mode 100644
index 000000000000..4c2b8cd6d8fd
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02
@@ -0,0 +1,20 @@
+CONFIG_SMP=y
+CONFIG_NR_CPUS=8
+CONFIG_PREEMPT_NONE=n
+CONFIG_PREEMPT_VOLUNTARY=n
+CONFIG_PREEMPT=y
+#CHECK#CONFIG_PREEMPT_RCU=y
+CONFIG_HZ_PERIODIC=n
+CONFIG_NO_HZ_IDLE=y
+CONFIG_NO_HZ_FULL=n
+CONFIG_RCU_TRACE=y
+CONFIG_HOTPLUG_CPU=y
+CONFIG_RCU_FANOUT=3
+CONFIG_RCU_FANOUT_LEAF=2
+CONFIG_RCU_NOCB_CPU=y
+CONFIG_DEBUG_LOCK_ALLOC=n
+CONFIG_PROVE_LOCKING=n
+CONFIG_RCU_BOOST=n
+CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
+CONFIG_RCU_EXPERT=y
+CONFIG_RCU_EQS_DEBUG=y
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
new file mode 100644
index 000000000000..c212ae299b0b
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
@@ -0,0 +1,3 @@
+rcupdate.rcu_self_test=1
+rcu_nocbs=all
+rcu_nocb_poll
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing
  2026-02-24 23:04 ` [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing Joel Fernandes
@ 2026-02-25 21:47   ` Paul E. McKenney
  2026-02-26  0:14     ` Joel Fernandes
  2026-03-11 13:03   ` Frederic Weisbecker
  1 sibling, 1 reply; 12+ messages in thread
From: Paul E. McKenney @ 2026-02-25 21:47 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Frederic Weisbecker, Neeraj Upadhyay, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, rcu, linux-kernel

On Tue, Feb 24, 2026 at 06:04:35PM -0500, Joel Fernandes wrote:
> Add new rcutorture config NOCB02 that enables rcu_nocb_poll boot
> parameter combined with CONFIG_RCU_NOCB_CPU to exercise the polling
> mode code paths in the NOCB implementation.
> 
> This config exercises poll-mode paths not covered by other configs,
> where callback invocation uses active polling instead of kthread
> wakeups.
> 
> This config is not added to CFLIST to avoid increasing the default
> test duration; it can be run explicitly when poll-mode testing
> is needed.
> 
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>

For 3/4 and 4/4:

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Tested-by: Paul E. McKenney <paulmck@kernel.org>

> ---
>  .../selftests/rcutorture/configs/rcu/NOCB02   | 20 +++++++++++++++++++
>  .../rcutorture/configs/rcu/NOCB02.boot        |  3 +++
>  2 files changed, 23 insertions(+)
>  create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02
>  create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
> 
> diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB02 b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02
> new file mode 100644
> index 000000000000..4c2b8cd6d8fd
> --- /dev/null
> +++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02
> @@ -0,0 +1,20 @@
> +CONFIG_SMP=y
> +CONFIG_NR_CPUS=8
> +CONFIG_PREEMPT_NONE=n
> +CONFIG_PREEMPT_VOLUNTARY=n
> +CONFIG_PREEMPT=y
> +#CHECK#CONFIG_PREEMPT_RCU=y
> +CONFIG_HZ_PERIODIC=n
> +CONFIG_NO_HZ_IDLE=y
> +CONFIG_NO_HZ_FULL=n
> +CONFIG_RCU_TRACE=y
> +CONFIG_HOTPLUG_CPU=y
> +CONFIG_RCU_FANOUT=3
> +CONFIG_RCU_FANOUT_LEAF=2
> +CONFIG_RCU_NOCB_CPU=y
> +CONFIG_DEBUG_LOCK_ALLOC=n
> +CONFIG_PROVE_LOCKING=n
> +CONFIG_RCU_BOOST=n
> +CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
> +CONFIG_RCU_EXPERT=y
> +CONFIG_RCU_EQS_DEBUG=y
> diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
> new file mode 100644
> index 000000000000..c212ae299b0b
> --- /dev/null
> +++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
> @@ -0,0 +1,3 @@
> +rcupdate.rcu_self_test=1
> +rcu_nocbs=all
> +rcu_nocb_poll
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing
  2026-02-25 21:47   ` Paul E. McKenney
@ 2026-02-26  0:14     ` Joel Fernandes
  0 siblings, 0 replies; 12+ messages in thread
From: Joel Fernandes @ 2026-02-26  0:14 UTC (permalink / raw)
  To: paulmck@kernel.org
  Cc: Frederic Weisbecker, Neeraj Upadhyay, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, rcu@vger.kernel.org,
	linux-kernel@vger.kernel.org



> On Feb 25, 2026, at 4:47 PM, Paul E. McKenney <paulmck@kernel.org> wrote:
> 
> On Tue, Feb 24, 2026 at 06:04:35PM -0500, Joel Fernandes wrote:
>> Add new rcutorture config NOCB02 that enables rcu_nocb_poll boot
>> parameter combined with CONFIG_RCU_NOCB_CPU to exercise the polling
>> mode code paths in the NOCB implementation.
>> 
>> This config exercises poll-mode paths not covered by other configs,
>> where callback invocation uses active polling instead of kthread
>> wakeups.
>> 
>> This config is not added to CFLIST to avoid increasing the default
>> test duration; it can be run explicitly when poll-mode testing
>> is needed.
>> 
>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
> 
> For 3/4 and 4/4:
> 
> Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
> Tested-by: Paul E. McKenney <paulmck@kernel.org>

Thanks, will apply these 2 to 7.1 with the tag.

Joel




> 
>> ---
>> .../selftests/rcutorture/configs/rcu/NOCB02   | 20 +++++++++++++++++++
>> .../rcutorture/configs/rcu/NOCB02.boot        |  3 +++
>> 2 files changed, 23 insertions(+)
>> create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02
>> create mode 100644 tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
>> 
>> diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB02 b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02
>> new file mode 100644
>> index 000000000000..4c2b8cd6d8fd
>> --- /dev/null
>> +++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02
>> @@ -0,0 +1,20 @@
>> +CONFIG_SMP=y
>> +CONFIG_NR_CPUS=8
>> +CONFIG_PREEMPT_NONE=n
>> +CONFIG_PREEMPT_VOLUNTARY=n
>> +CONFIG_PREEMPT=y
>> +#CHECK#CONFIG_PREEMPT_RCU=y
>> +CONFIG_HZ_PERIODIC=n
>> +CONFIG_NO_HZ_IDLE=y
>> +CONFIG_NO_HZ_FULL=n
>> +CONFIG_RCU_TRACE=y
>> +CONFIG_HOTPLUG_CPU=y
>> +CONFIG_RCU_FANOUT=3
>> +CONFIG_RCU_FANOUT_LEAF=2
>> +CONFIG_RCU_NOCB_CPU=y
>> +CONFIG_DEBUG_LOCK_ALLOC=n
>> +CONFIG_PROVE_LOCKING=n
>> +CONFIG_RCU_BOOST=n
>> +CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
>> +CONFIG_RCU_EXPERT=y
>> +CONFIG_RCU_EQS_DEBUG=y
>> diff --git a/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
>> new file mode 100644
>> index 000000000000..c212ae299b0b
>> --- /dev/null
>> +++ b/tools/testing/selftests/rcutorture/configs/rcu/NOCB02.boot
>> @@ -0,0 +1,3 @@
>> +rcupdate.rcu_self_test=1
>> +rcu_nocbs=all
>> +rcu_nocb_poll
>> --
>> 2.34.1
>> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions
  2026-02-24 23:04 ` [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions Joel Fernandes
@ 2026-03-04 15:32   ` Frederic Weisbecker
  2026-03-04 17:05     ` Joel Fernandes
  0 siblings, 1 reply; 12+ messages in thread
From: Frederic Weisbecker @ 2026-03-04 15:32 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Paul E . McKenney, Neeraj Upadhyay, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, rcu, linux-kernel

Le Tue, Feb 24, 2026 at 06:04:32PM -0500, Joel Fernandes a écrit :
> The rcu_nocb_cpu_offload() and rcu_nocb_cpu_deoffload() functions are
> nearly duplicates.
> 
> Therefore, extract the common logic into rcu_nocb_cpu_toggle_offload()
> which takes an 'offload' boolean, and make both exported functions
> simple wrappers.
> 
> This eliminates a bunch of duplicate code at the call sites, namely
> mutex locking, CPU hotplug locking and CPU online checks.
> 
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
> ---
>  kernel/rcu/tree_nocb.h | 89 ++++++++++++++++++++++--------------------
>  1 file changed, 46 insertions(+), 43 deletions(-)
> 
> diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
> index b3337c7231cc..5b041134d6bb 100644
> --- a/kernel/rcu/tree_nocb.h
> +++ b/kernel/rcu/tree_nocb.h
> @@ -1081,30 +1081,6 @@ static int rcu_nocb_rdp_deoffload(struct rcu_data *rdp)
>  	return 0;
>  }
>  
> -int rcu_nocb_cpu_deoffload(int cpu)
> -{
> -	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
> -	int ret = 0;
> -
> -	cpus_read_lock();
> -	mutex_lock(&rcu_state.nocb_mutex);
> -	if (rcu_rdp_is_offloaded(rdp)) {
> -		if (!cpu_online(cpu)) {
> -			ret = rcu_nocb_rdp_deoffload(rdp);
> -			if (!ret)
> -				cpumask_clear_cpu(cpu, rcu_nocb_mask);
> -		} else {
> -			pr_info("NOCB: Cannot CB-deoffload online CPU %d\n", rdp->cpu);
> -			ret = -EINVAL;
> -		}
> -	}
> -	mutex_unlock(&rcu_state.nocb_mutex);
> -	cpus_read_unlock();
> -
> -	return ret;
> -}
> -EXPORT_SYMBOL_GPL(rcu_nocb_cpu_deoffload);
> -
>  static bool rcu_nocb_rdp_offload_wait_cond(struct rcu_data *rdp)
>  {
>  	unsigned long flags;
> @@ -1149,27 +1125,54 @@ static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
>  	return 0;
>  }
>  
> +/* Common helper for CPU offload/deoffload operations. */
> +static int rcu_nocb_cpu_toggle_offload(int cpu, bool offload)
> +{
> +	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
> +	bool currently_offloaded;
> +	int ret = 0;
> +
> +	cpus_read_lock();
> +	mutex_lock(&rcu_state.nocb_mutex);
> +
> +	currently_offloaded = rcu_rdp_is_offloaded(rdp);

Do we really need that extra variable?

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>

-- 
Frederic Weisbecker
SUSE Labs

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions
  2026-03-04 15:32   ` Frederic Weisbecker
@ 2026-03-04 17:05     ` Joel Fernandes
  0 siblings, 0 replies; 12+ messages in thread
From: Joel Fernandes @ 2026-03-04 17:05 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Paul E . McKenney, Neeraj Upadhyay, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, rcu, linux-kernel



On 3/4/2026 10:32 AM, Frederic Weisbecker wrote:
> Le Tue, Feb 24, 2026 at 06:04:32PM -0500, Joel Fernandes a écrit :
>> The rcu_nocb_cpu_offload() and rcu_nocb_cpu_deoffload() functions are
>> nearly duplicates.
>>
>> Therefore, extract the common logic into rcu_nocb_cpu_toggle_offload()
>> which takes an 'offload' boolean, and make both exported functions
>> simple wrappers.
>>
>> This eliminates a bunch of duplicate code at the call sites, namely
>> mutex locking, CPU hotplug locking and CPU online checks.
>>
>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
>> ---
>>  kernel/rcu/tree_nocb.h | 89 ++++++++++++++++++++++--------------------
>>  1 file changed, 46 insertions(+), 43 deletions(-)
>>
>> diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
>> index b3337c7231cc..5b041134d6bb 100644
>> --- a/kernel/rcu/tree_nocb.h
>> +++ b/kernel/rcu/tree_nocb.h
>> @@ -1081,30 +1081,6 @@ static int rcu_nocb_rdp_deoffload(struct rcu_data *rdp)
>>  	return 0;
>>  }
>>  
>> -int rcu_nocb_cpu_deoffload(int cpu)
>> -{
>> -	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
>> -	int ret = 0;
>> -
>> -	cpus_read_lock();
>> -	mutex_lock(&rcu_state.nocb_mutex);
>> -	if (rcu_rdp_is_offloaded(rdp)) {
>> -		if (!cpu_online(cpu)) {
>> -			ret = rcu_nocb_rdp_deoffload(rdp);
>> -			if (!ret)
>> -				cpumask_clear_cpu(cpu, rcu_nocb_mask);
>> -		} else {
>> -			pr_info("NOCB: Cannot CB-deoffload online CPU %d\n", rdp->cpu);
>> -			ret = -EINVAL;
>> -		}
>> -	}
>> -	mutex_unlock(&rcu_state.nocb_mutex);
>> -	cpus_read_unlock();
>> -
>> -	return ret;
>> -}
>> -EXPORT_SYMBOL_GPL(rcu_nocb_cpu_deoffload);
>> -
>>  static bool rcu_nocb_rdp_offload_wait_cond(struct rcu_data *rdp)
>>  {
>>  	unsigned long flags;
>> @@ -1149,27 +1125,54 @@ static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
>>  	return 0;
>>  }
>>  
>> +/* Common helper for CPU offload/deoffload operations. */
>> +static int rcu_nocb_cpu_toggle_offload(int cpu, bool offload)
>> +{
>> +	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
>> +	bool currently_offloaded;
>> +	int ret = 0;
>> +
>> +	cpus_read_lock();
>> +	mutex_lock(&rcu_state.nocb_mutex);
>> +
>> +	currently_offloaded = rcu_rdp_is_offloaded(rdp);
> 
> Do we really need that extra variable?

No we don't need it, fixed.

> Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
> 

Thanks!

-- 
Joel Fernandes


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC v1 2/4] rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication
  2026-02-24 23:04 ` [PATCH RFC v1 2/4] rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication Joel Fernandes
@ 2026-03-11 12:58   ` Frederic Weisbecker
  0 siblings, 0 replies; 12+ messages in thread
From: Frederic Weisbecker @ 2026-03-11 12:58 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Paul E . McKenney, Neeraj Upadhyay, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, rcu, linux-kernel

Le Tue, Feb 24, 2026 at 06:04:33PM -0500, Joel Fernandes a écrit :
> The bypass flush decision logic is duplicated in rcu_nocb_try_bypass()
> and nocb_gp_wait() with similar conditions.
> 
> This commit therefore extracts the functionality into a common helper
> function nocb_bypass_needs_flush() improving the code readability.
> 
> A flush_faster parameter is added to controlling the flushing thresholds
> and timeouts. This design was in the original commit d1b222c6be1f
> ("rcu/nocb: Add bypass callback queueing") to avoid having the GP
> kthread aggressively flush the bypass queue.
> 
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>

-- 
Frederic Weisbecker
SUSE Labs

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC v1 3/4] rcutorture: Add NOCB01 config for RCU_LAZY torture testing
  2026-02-24 23:04 ` [PATCH RFC v1 3/4] rcutorture: Add NOCB01 config for RCU_LAZY torture testing Joel Fernandes
@ 2026-03-11 13:02   ` Frederic Weisbecker
  0 siblings, 0 replies; 12+ messages in thread
From: Frederic Weisbecker @ 2026-03-11 13:02 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Paul E . McKenney, Neeraj Upadhyay, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, rcu, linux-kernel

Le Tue, Feb 24, 2026 at 06:04:34PM -0500, Joel Fernandes a écrit :
> Add new rcutorture config NOCB01 that enables CONFIG_RCU_LAZY combined
> with CONFIG_RCU_NOCB_CPU to exercise the lazy callback code paths in
> the NOCB implementation.
> 
> This config exercises lazy callback paths not covered by other configs,
> including lazy-only wake and lazy defer logic.
> 
> This config is not added to CFLIST to avoid increasing the default
> test duration; it can be run explicitly when lazy callback testing
> is needed.
> 
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>

Acked-by: Frederic Weisbecker <frederic@kernel.org>

-- 
Frederic Weisbecker
SUSE Labs

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing
  2026-02-24 23:04 ` [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing Joel Fernandes
  2026-02-25 21:47   ` Paul E. McKenney
@ 2026-03-11 13:03   ` Frederic Weisbecker
  1 sibling, 0 replies; 12+ messages in thread
From: Frederic Weisbecker @ 2026-03-11 13:03 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Paul E . McKenney, Neeraj Upadhyay, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, rcu, linux-kernel

Le Tue, Feb 24, 2026 at 06:04:35PM -0500, Joel Fernandes a écrit :
> Add new rcutorture config NOCB02 that enables rcu_nocb_poll boot
> parameter combined with CONFIG_RCU_NOCB_CPU to exercise the polling
> mode code paths in the NOCB implementation.
> 
> This config exercises poll-mode paths not covered by other configs,
> where callback invocation uses active polling instead of kthread
> wakeups.
> 
> This config is not added to CFLIST to avoid increasing the default
> test duration; it can be run explicitly when poll-mode testing
> is needed.
> 
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>

Acked-by: Frederic Weisbecker <frederic@kernel.org>

-- 
Frederic Weisbecker
SUSE Labs

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-11 13:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 23:04 [PATCH RFC v1 0/4] rcu/nocb: Clean ups and rcutorture test configs Joel Fernandes
2026-02-24 23:04 ` [PATCH RFC v1 1/4] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions Joel Fernandes
2026-03-04 15:32   ` Frederic Weisbecker
2026-03-04 17:05     ` Joel Fernandes
2026-02-24 23:04 ` [PATCH RFC v1 2/4] rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication Joel Fernandes
2026-03-11 12:58   ` Frederic Weisbecker
2026-02-24 23:04 ` [PATCH RFC v1 3/4] rcutorture: Add NOCB01 config for RCU_LAZY torture testing Joel Fernandes
2026-03-11 13:02   ` Frederic Weisbecker
2026-02-24 23:04 ` [PATCH RFC v1 4/4] rcutorture: Add NOCB02 config for nocb poll mode testing Joel Fernandes
2026-02-25 21:47   ` Paul E. McKenney
2026-02-26  0:14     ` Joel Fernandes
2026-03-11 13:03   ` Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox