mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] My torture test related fixes for v7.5
@ 2026-11-09  0:02 Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 1/5] rcu-tasks: Track barrier callbacks in debugobjects Joel Fernandes
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Joel Fernandes @ 2026-11-09  0:02 UTC (permalink / raw)
  To: linux-kernel, Paul E . McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang
  Cc: rcu

Some test related fixes for v7.5 from me. Sending a v2 as I had to add a
MAINTAINERS entry to fix git send-email.

Joel Fernandes (5):
  rcu-tasks: Track barrier callbacks in debugobjects
  scftorture: Reject empty workloads before starting helpers
  scftorture: Protect the initial affinity check from hotplug
  kasan: Avoid an unrelated RCU warning in the callback test
  MAINTAINERS: Add scftorture to TORTURE-TEST MODULES

 MAINTAINERS             |  2 ++
 kernel/rcu/tasks.h      |  3 +++
 kernel/scftorture.c     | 30 +++++++++++++++++++++++-------
 mm/kasan/kasan_test_c.c |  3 ++-
 4 files changed, 30 insertions(+), 8 deletions(-)

-- 
2.54.0


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

* [PATCH v2 1/5] rcu-tasks: Track barrier callbacks in debugobjects
  2026-11-09  0:02 [PATCH v2 0/5] My torture test related fixes for v7.5 Joel Fernandes
@ 2026-11-09  0:02 ` Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 2/5] scftorture: Reject empty workloads before starting helpers Joel Fernandes
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Joel Fernandes @ 2026-11-09  0:02 UTC (permalink / raw)
  To: linux-kernel, Paul E . McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang
  Cc: rcu, Kunwu Chan

rcu_tasks_invoke_cbs() now unqueues each callback from debugobjects.
However, rcu_barrier_tasks_generic() inserts its per-CPU barrier heads
directly with rcu_segcblist_entrain(), bypassing the queue hook in
call_rcu_tasks_generic(). This produces active_state and deactivate
warnings for untracked objects when a barrier callback runs.

Activate each barrier head before entrainment and undo that activation
when there are no callbacks to entrain behind. Successful entrainment
is balanced by the invocation path, as for ordinary callbacks.

The existing n_barrier_cbs=2 torture test reproduces the warnings before
this change and completes without them afterwards.

This fixes patch "rcu-tasks: Detect duplicate callback enqueue".

Cc: Kunwu Chan <kunwu.chan@gmail.com>
Cc: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 kernel/rcu/tasks.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index d5d060a5c4b6..a20db323612b 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -470,9 +470,12 @@ static void __maybe_unused rcu_barrier_tasks_generic(struct rcu_tasks *rtp)
 			break;
 		rtpcp = per_cpu_ptr(rtp->rtpcpu, cpu);
 		rtpcp->barrier_q_head.func = rcu_barrier_tasks_generic_cb;
+		debug_rcu_head_queue(&rtpcp->barrier_q_head);
 		raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
 		if (rcu_segcblist_entrain(&rtpcp->cblist, &rtpcp->barrier_q_head))
 			atomic_inc(&rtp->barrier_q_count);
+		else
+			debug_rcu_head_unqueue(&rtpcp->barrier_q_head);
 		raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
 	}
 	if (atomic_sub_and_test(2, &rtp->barrier_q_count))
-- 
2.54.0


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

* [PATCH v2 2/5] scftorture: Reject empty workloads before starting helpers
  2026-11-09  0:02 [PATCH v2 0/5] My torture test related fixes for v7.5 Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 1/5] rcu-tasks: Track barrier callbacks in debugobjects Joel Fernandes
@ 2026-11-09  0:02 ` Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 3/5] scftorture: Protect the initial affinity check from hotplug Joel Fernandes
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Joel Fernandes @ 2026-11-09  0:02 UTC (permalink / raw)
  To: linux-kernel, Paul E . McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, Davidlohr Bueso
  Cc: rcu

A module loaded with nthreads=0 starts its statistics task, but cleanup
skips stopping that task. Unloading the module then leaves it executing
freed module text. Reject a zero thread count before starting helpers;
negative counts still select the online CPU count.

Also, when built as a module with reschedule-only, this leaves the
selector empty because resched_cpu() is unavailable to modules. It warns
while selecting an operation, invokes no callbacks, and can nevertheless
report SUCCESS.  Reject an empty effective selector after filtering
unsupported operations.

Both failures were reproduced in a guest without the patches.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 kernel/scftorture.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/scftorture.c b/kernel/scftorture.c
index 603b2dba1536..ff9a8271a464 100644
--- a/kernel/scftorture.c
+++ b/kernel/scftorture.c
@@ -588,6 +588,12 @@ static int __init scf_torture_init(void)
 
 	scftorture_print_module_parms("Start of test");
 
+	if (!nthreads) {
+		SCFTORTOUT_ERRSTRING("nthreads must be nonzero");
+		firsterr = -EINVAL;
+		goto unwind;
+	}
+
 	if (weight_resched <= 0 &&
 	    weight_single <= 0 && weight_single_rpc <= 0 && weight_single_wait <= 0 &&
 	    weight_many <= 0 && weight_many_wait <= 0 &&
@@ -636,6 +642,11 @@ static int __init scf_torture_init(void)
 	scf_sel_add(weight_many_wait1, SCF_PRIM_MANY, true);
 	scf_sel_add(weight_all1, SCF_PRIM_ALL, false);
 	scf_sel_add(weight_all_wait1, SCF_PRIM_ALL, true);
+	if (!scf_sel_array_len) {
+		SCFTORTOUT_ERRSTRING("no supported operations selected");
+		firsterr = -EINVAL;
+		goto unwind;
+	}
 	scf_sel_dump();
 
 	if (onoff_interval > 0) {
-- 
2.54.0


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

* [PATCH v2 3/5] scftorture: Protect the initial affinity check from hotplug
  2026-11-09  0:02 [PATCH v2 0/5] My torture test related fixes for v7.5 Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 1/5] rcu-tasks: Track barrier callbacks in debugobjects Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 2/5] scftorture: Reject empty workloads before starting helpers Joel Fernandes
@ 2026-11-09  0:02 ` Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 4/5] kasan: Avoid an unrelated RCU warning in the callback test Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 5/5] MAINTAINERS: Add scftorture to TORTURE-TEST MODULES Joel Fernandes
  4 siblings, 0 replies; 6+ messages in thread
From: Joel Fernandes @ 2026-11-09  0:02 UTC (permalink / raw)
  To: linux-kernel, Paul E . McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, Davidlohr Bueso
  Cc: rcu

An invoker binds to its target CPU, sleeps for the holdoff interval, and
then warns if it is running elsewhere. CPU hotplug can offline the target
during that sleep and legitimately move the invoker. A built-in test with
matching worker and hotplug holdoffs reproduces this warning.

Check the initial binding while holding cpus_read_lock(), before sleeping.
If the target is already offline, let the existing offline/rebind path
handle it instead of warning about an impossible initial binding. Release
the read lock before the holdoff and test loop so hotplug remains tested.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 kernel/scftorture.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/kernel/scftorture.c b/kernel/scftorture.c
index ff9a8271a464..64ee2c5cf51c 100644
--- a/kernel/scftorture.c
+++ b/kernel/scftorture.c
@@ -479,19 +479,24 @@ static int scftorture_invoker(void *arg)
 
 	VERBOSE_SCFTORTOUT("scftorture_invoker %d: task started", scfp->cpu);
 	cpu = scfp->cpu % nr_cpu_ids;
-	WARN_ON_ONCE(set_cpus_allowed_ptr(current, cpumask_of(cpu)));
+	cpus_read_lock();
+	if (cpu_online(cpu)) {
+		WARN_ON_ONCE(set_cpus_allowed_ptr(current, cpumask_of(cpu)));
+		/* Check affinity before hotplug can move this task away. */
+		curcpu = raw_smp_processor_id();
+		WARN_ONCE(curcpu != cpu,
+			  "%s: Wanted CPU %d, running on %d, nr_cpu_ids = %d\n",
+			  __func__, scfp->cpu, curcpu, nr_cpu_ids);
+	} else {
+		was_offline = true;
+	}
+	cpus_read_unlock();
 	set_user_nice(current, MAX_NICE);
 	if (holdoff)
 		schedule_timeout_interruptible(holdoff * HZ);
 
 	VERBOSE_SCFTORTOUT("scftorture_invoker %d: Waiting for all SCF torturers from cpu %d", scfp->cpu, raw_smp_processor_id());
 
-	// Make sure that the CPU is affinitized appropriately during testing.
-	curcpu = raw_smp_processor_id();
-	WARN_ONCE(curcpu != cpu,
-		  "%s: Wanted CPU %d, running on %d, nr_cpu_ids = %d\n",
-		  __func__, scfp->cpu, curcpu, nr_cpu_ids);
-
 	if (atomic_dec_return(&n_started))
 		while (atomic_read_acquire(&n_started)) {
 			if (torture_must_stop()) {
-- 
2.54.0


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

* [PATCH v2 4/5] kasan: Avoid an unrelated RCU warning in the callback test
  2026-11-09  0:02 [PATCH v2 0/5] My torture test related fixes for v7.5 Joel Fernandes
                   ` (2 preceding siblings ...)
  2026-11-09  0:02 ` [PATCH v2 3/5] scftorture: Protect the initial affinity check from hotplug Joel Fernandes
@ 2026-11-09  0:02 ` Joel Fernandes
  2026-11-09  0:02 ` [PATCH v2 5/5] MAINTAINERS: Add scftorture to TORTURE-TEST MODULES Joel Fernandes
  4 siblings, 0 replies; 6+ messages in thread
From: Joel Fernandes @ 2026-11-09  0:02 UTC (permalink / raw)
  To: linux-kernel, Paul E . McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang, Andrey Ryabinin, Alexander Potapenko,
	Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino,
	Andrew Morton
  Cc: rcu, kasan-dev, linux-mm

rcu_uaf() passes a false protection condition to
rcu_dereference_protected(), which produces a suspicious-RCU-usage
warning before the intended KASAN failure occurs.

The pointer refers to a fresh allocation that has not been published to
readers. State that protection condition explicitly, leaving the intended
tests intact.

Test:
Built with CONFIG_KASAN_KUNIT_TEST=m
Booted Qemu guest (8 CPUs), ran modprobe kasan_test filtered to kasan.*rcu_uaf*

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 mm/kasan/kasan_test_c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c
index b9e167ed5be3..4e23765d722c 100644
--- a/mm/kasan/kasan_test_c.c
+++ b/mm/kasan/kasan_test_c.c
@@ -967,8 +967,9 @@ static void rcu_uaf(struct kunit *test)
 	ptr = kmalloc_obj(struct kasan_rcu_info);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
 
+	/* The freshly allocated object has not been published to readers. */
 	global_rcu_ptr = rcu_dereference_protected(
-				(struct kasan_rcu_info __rcu *)ptr, NULL);
+				(struct kasan_rcu_info __rcu *)ptr, true);
 
 	KUNIT_EXPECT_KASAN_FAIL_READ(test,
 			call_rcu(&global_rcu_ptr->rcu, rcu_uaf_reclaim);
-- 
2.54.0


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

* [PATCH v2 5/5] MAINTAINERS: Add scftorture to TORTURE-TEST MODULES
  2026-11-09  0:02 [PATCH v2 0/5] My torture test related fixes for v7.5 Joel Fernandes
                   ` (3 preceding siblings ...)
  2026-11-09  0:02 ` [PATCH v2 4/5] kasan: Avoid an unrelated RCU warning in the callback test Joel Fernandes
@ 2026-11-09  0:02 ` Joel Fernandes
  4 siblings, 0 replies; 6+ messages in thread
From: Joel Fernandes @ 2026-11-09  0:02 UTC (permalink / raw)
  To: linux-kernel, Paul E . McKenney, Frederic Weisbecker,
	Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang
  Cc: rcu

kernel/scftorture.c has no MAINTAINERS entry, so get_maintainer.pl
reports only the linux-kernel list for it. It is one of the torture-test
modules alongside rcutorture, locktorture and refscale, so list it in
the TORTURE-TEST MODULES entry.

While add it, add me as M: to torture modules as well as I have
contributed patches/fixes to it over the years and use it for RCU.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315065..5c068224048a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28282,6 +28282,7 @@ TORTURE-TEST MODULES
 M:	Davidlohr Bueso <dave@stgolabs.net>
 M:	"Paul E. McKenney" <paulmck@kernel.org>
 M:	Josh Triplett <josh@joshtriplett.org>
+M:	Joel Fernandes <joelagnelf@nvidia.com>
 L:	linux-kernel@vger.kernel.org
 S:	Supported
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
@@ -28290,6 +28291,7 @@ F:	kernel/locking/locktorture.c
 F:	kernel/rcu/rcuscale.c
 F:	kernel/rcu/rcutorture.c
 F:	kernel/rcu/refscale.c
+F:	kernel/scftorture.c
 F:	kernel/torture.c
 
 TOSHIBA ACPI EXTRAS DRIVER
-- 
2.54.0


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09  0:02 [PATCH v2 0/5] My torture test related fixes for v7.5 Joel Fernandes
2026-11-09  0:02 ` [PATCH v2 1/5] rcu-tasks: Track barrier callbacks in debugobjects Joel Fernandes
2026-11-09  0:02 ` [PATCH v2 2/5] scftorture: Reject empty workloads before starting helpers Joel Fernandes
2026-11-09  0:02 ` [PATCH v2 3/5] scftorture: Protect the initial affinity check from hotplug Joel Fernandes
2026-11-09  0:02 ` [PATCH v2 4/5] kasan: Avoid an unrelated RCU warning in the callback test Joel Fernandes
2026-11-09  0:02 ` [PATCH v2 5/5] MAINTAINERS: Add scftorture to TORTURE-TEST MODULES Joel Fernandes

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

all inboxes | Powered by JetHome®