Linux RCU subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/11] RCU torture-test updates for v6.18
@ 2025-09-18 10:29 Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 01/11] rcutorture: Fix jitter.sh spin time Paul E. McKenney
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt

Hello!

This series contains torture-test updates for v6.18:

1.	Fix jitter.sh spin time.

2.	Add --do-normal parameter to torture.sh help text.

3.	Announce kernel boot status at torture-test startup.

4.	Suppress "Writer stall state" reports during boot.

5.	Delay rcutorture readers and writers until boot completes.

6.	Delay CPU-hotplug operations until boot completes.

7.	Delay forward-progress testing until boot completes.

8.	Use kcalloc() instead of kzalloc(), courtesy of Qianfeng Rong.

9.	Use kcalloc() instead of kzalloc(), courtesy of Qianfeng Rong.

10.	Remove redundant kfree() after torture_stop_kthread(), courtesy
	of Kaushlendra Kumar.

11.	Set reader_tasks to NULL after kfree(), courtesy of Kaushlendra
	Kumar.

Changes since v1:

o	Add patches 8-11.

						Thanx, Paul

------------------------------------------------------------------------

 b/kernel/rcu/rcutorture.c                           |    3 +-
 b/kernel/rcu/refscale.c                             |    2 -
 b/kernel/torture.c                                  |    5 ++-
 b/tools/testing/selftests/rcutorture/bin/jitter.sh  |   27 +++++++++++++++++---
 b/tools/testing/selftests/rcutorture/bin/torture.sh |    1 
 kernel/rcu/rcutorture.c                             |   24 +++++++++++++----
 kernel/rcu/refscale.c                               |    2 -
 kernel/torture.c                                    |    2 +
 8 files changed, 52 insertions(+), 14 deletions(-)

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

* [PATCH v2 01/11] rcutorture: Fix jitter.sh spin time
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 02/11] torture: Add --do-normal parameter to torture.sh help text Paul E. McKenney
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

An embarrassing syntax error in jitter.sh makes for fixed spin time.
This commit therefore makes it be variable, as intended, albeit with
very coarse-grained adjustment.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 .../selftests/rcutorture/bin/jitter.sh        | 27 ++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/rcutorture/bin/jitter.sh b/tools/testing/selftests/rcutorture/bin/jitter.sh
index fd1ffaa5a1358e..3c1e5d3f88058c 100755
--- a/tools/testing/selftests/rcutorture/bin/jitter.sh
+++ b/tools/testing/selftests/rcutorture/bin/jitter.sh
@@ -39,6 +39,22 @@ do
 	fi
 done
 
+# Uses global variables startsecs, startns, endsecs, endns, and limit.
+# Exit code is success for time not yet elapsed and failure otherwise.
+function timecheck {
+	local done=`awk -v limit=$limit \
+			-v startsecs=$startsecs \
+			-v startns=$startns \
+			-v endsecs=$endsecs \
+			-v endns=$endns < /dev/null '
+		BEGIN {
+			delta = (endsecs - startsecs) * 1000 * 1000;
+			delta += int((endns - startns) / 1000);
+			print delta >= limit;
+		}'`
+	return $done
+}
+
 while :
 do
 	# Check for done.
@@ -85,15 +101,20 @@ do
 	n=$(($n+1))
 	sleep .$sleeptime
 
-	# Spin a random duration
+	# Spin a random duration, but with rather coarse granularity.
 	limit=`awk -v me=$me -v n=$n -v spinmax=$spinmax 'BEGIN {
 		srand(n + me + systime());
 		printf("%06d", int(rand() * spinmax));
 	}' < /dev/null`
 	n=$(($n+1))
-	for i in {1..$limit}
+	startsecs=`date +%s`
+	startns=`date +%N`
+	endsecs=$startns
+	endns=$endns
+	while timecheck
 	do
-		echo > /dev/null
+		endsecs=`date +%s`
+		endns=`date +%N`
 	done
 done
 
-- 
2.40.1


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

* [PATCH v2 02/11] torture: Add --do-normal parameter to torture.sh help text
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 01/11] rcutorture: Fix jitter.sh spin time Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 03/11] torture: Announce kernel boot status at torture-test startup Paul E. McKenney
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

The --do-normal parameter was missing from the torture.sh script's help
text, so this commit adds it.  Hopefully better late than never!

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 tools/testing/selftests/rcutorture/bin/torture.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/testing/selftests/rcutorture/bin/torture.sh
index 611bc03a8dc705..a33ba109ef0b7f 100755
--- a/tools/testing/selftests/rcutorture/bin/torture.sh
+++ b/tools/testing/selftests/rcutorture/bin/torture.sh
@@ -94,6 +94,7 @@ usage () {
 	echo "       --do-kvfree / --do-no-kvfree / --no-kvfree"
 	echo "       --do-locktorture / --do-no-locktorture / --no-locktorture"
 	echo "       --do-none"
+	echo "       --do-normal / --do-no-normal / --no-normal"
 	echo "       --do-rcuscale / --do-no-rcuscale / --no-rcuscale"
 	echo "       --do-rcutasksflavors / --do-no-rcutasksflavors / --no-rcutasksflavors"
 	echo "       --do-rcutorture / --do-no-rcutorture / --no-rcutorture"
-- 
2.40.1


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

* [PATCH v2 03/11] torture: Announce kernel boot status at torture-test startup
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 01/11] rcutorture: Fix jitter.sh spin time Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 02/11] torture: Add --do-normal parameter to torture.sh help text Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 04/11] rcutorture: Suppress "Writer stall state" reports during boot Paul E. McKenney
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

Sometimes a given system takes surprisingly long to boot, for example,
in one recent case, 70 seconds instead of three seconds.  It would
be good to fix these slow-boot issues, but it would also be good for
the torture tests to announce that the system was still booting at the
start of the test.  Especially for tests that have a greater probability
of false positives when run in the single-CPU boot-time environment.
Yes, those tests should defend themselves, but we should also make this
situation easier to diagnose.

This commit therefore causes torture_print_module_parms() to print
"still booting" at the end of its printk() that dumps out the values of
its module parameters.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/torture.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/torture.c b/kernel/torture.c
index 3a0a8cc604010a..5abb4b25d971cc 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -797,8 +797,9 @@ static unsigned long torture_init_jiffies;
 static void
 torture_print_module_parms(void)
 {
-	pr_alert("torture module --- %s:  disable_onoff_at_boot=%d ftrace_dump_at_shutdown=%d verbose_sleep_frequency=%d verbose_sleep_duration=%d random_shuffle=%d\n",
-		 torture_type, disable_onoff_at_boot, ftrace_dump_at_shutdown, verbose_sleep_frequency, verbose_sleep_duration, random_shuffle);
+	pr_alert("torture module --- %s:  disable_onoff_at_boot=%d ftrace_dump_at_shutdown=%d verbose_sleep_frequency=%d verbose_sleep_duration=%d random_shuffle=%d%s\n",
+		 torture_type, disable_onoff_at_boot, ftrace_dump_at_shutdown, verbose_sleep_frequency, verbose_sleep_duration, random_shuffle,
+		 rcu_inkernel_boot_has_ended() ? "" : " still booting");
 }
 
 /*
-- 
2.40.1


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

* [PATCH v2 04/11] rcutorture: Suppress "Writer stall state" reports during boot
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (2 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 03/11] torture: Announce kernel boot status at torture-test startup Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 05/11] rcutorture: Delay rcutorture readers and writers until boot completes Paul E. McKenney
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

When rcutorture is running on only the one boot-time CPU while that CPU
is busy invoking initcall() functions, the added load is quite likely to
unduly delay the RCU grace-period kthread, rcutorture readers, and much
else besides.  This can result in rcu_torture_stats_print() reporting
rcutorture writer stalls, which are not really a bug in that environment.
After all, one CPU can only do so much.

This commit therefore suppresses rcutorture writer stalls while the
kernel is booting, that is, while rcu_inkernel_boot_has_ended() continues
returning false.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 7a893d51d02b6a..49e048da4f6810 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -2756,7 +2756,8 @@ rcu_torture_stats_print(void)
 		cur_ops->stats();
 	if (rtcv_snap == rcu_torture_current_version &&
 	    rcu_access_pointer(rcu_torture_current) &&
-	    !rcu_stall_is_suppressed()) {
+	    !rcu_stall_is_suppressed() &&
+	    rcu_inkernel_boot_has_ended()) {
 		int __maybe_unused flags = 0;
 		unsigned long __maybe_unused gp_seq = 0;
 
-- 
2.40.1


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

* [PATCH v2 05/11] rcutorture: Delay rcutorture readers and writers until boot completes
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (3 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 04/11] rcutorture: Suppress "Writer stall state" reports during boot Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 06/11] torture: Delay CPU-hotplug operations " Paul E. McKenney
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

The rcutorture writers and (especially) readers are the biggest CPU
hogs of the bunch, so this commit therefore makes them wait until boot
has completed.

This makes the current setting of the boot_ended local variable dead code,
so while in the area, this commit removes that as well.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 49e048da4f6810..1578d330565752 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1528,7 +1528,7 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))
 static int
 rcu_torture_writer(void *arg)
 {
-	bool boot_ended;
+	bool booting_still = false;
 	bool can_expedite = !rcu_gp_is_expedited() && !rcu_gp_is_normal();
 	unsigned long cookie;
 	struct rcu_gp_oldstate cookie_full;
@@ -1539,6 +1539,7 @@ rcu_torture_writer(void *arg)
 	struct rcu_gp_oldstate gp_snap1_full;
 	int i;
 	int idx;
+	unsigned long j;
 	int oldnice = task_nice(current);
 	struct rcu_gp_oldstate *rgo = NULL;
 	int rgo_size = 0;
@@ -1581,6 +1582,16 @@ rcu_torture_writer(void *arg)
 			rgo_size = cur_ops->poll_active_full;
 	}
 
+	// If the system is still booting, let it finish.
+	j = jiffies;
+	while (!torture_must_stop() && !rcu_inkernel_boot_has_ended()) {
+		booting_still = true;
+		schedule_timeout_interruptible(HZ);
+	}
+	if (booting_still)
+		pr_alert("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n",
+			 torture_type, jiffies - j);
+
 	do {
 		rcu_torture_writer_state = RTWS_FIXED_DELAY;
 		torture_hrtimeout_us(500, 1000, &rand);
@@ -1769,13 +1780,11 @@ rcu_torture_writer(void *arg)
 				       !rcu_gp_is_normal();
 		}
 		rcu_torture_writer_state = RTWS_STUTTER;
-		boot_ended = rcu_inkernel_boot_has_ended();
 		stutter_waited = stutter_wait("rcu_torture_writer");
 		if (stutter_waited &&
 		    !atomic_read(&rcu_fwd_cb_nodelay) &&
 		    !cur_ops->slow_gps &&
 		    !torture_must_stop() &&
-		    boot_ended &&
 		    time_after(jiffies, stallsdone))
 			for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
 				if (list_empty(&rcu_tortures[i].rtort_free) &&
@@ -2437,7 +2446,8 @@ rcu_torture_reader(void *arg)
 			torture_hrtimeout_us(500, 1000, &rand);
 			lastsleep = jiffies + 10;
 		}
-		while (torture_num_online_cpus() < mynumonline && !torture_must_stop())
+		while (!torture_must_stop() &&
+		       (torture_num_online_cpus() < mynumonline || !rcu_inkernel_boot_has_ended()))
 			schedule_timeout_interruptible(HZ / 5);
 		stutter_wait("rcu_torture_reader");
 	} while (!torture_must_stop());
-- 
2.40.1


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

* [PATCH v2 06/11] torture: Delay CPU-hotplug operations until boot completes
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (4 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 05/11] rcutorture: Delay rcutorture readers and writers until boot completes Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 07/11] rcutorture: Delay forward-progress testing " Paul E. McKenney
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

CPU-hotplug operations invoke stop-machine, which can hog CPUs, which is
not a great thing to do before boot has completed.  This commit therefore
makes the CPU-hotplug operations hold off until boot has completed.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/torture.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/torture.c b/kernel/torture.c
index 5abb4b25d971cc..1ea9f67953a766 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -359,6 +359,8 @@ torture_onoff(void *arg)
 		torture_hrtimeout_jiffies(onoff_holdoff, &rand);
 		VERBOSE_TOROUT_STRING("torture_onoff end holdoff");
 	}
+	while (!rcu_inkernel_boot_has_ended())
+		schedule_timeout_interruptible(HZ / 10);
 	while (!torture_must_stop()) {
 		if (disable_onoff_at_boot && !rcu_inkernel_boot_has_ended()) {
 			torture_hrtimeout_jiffies(HZ / 10, &rand);
-- 
2.40.1


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

* [PATCH v2 07/11] rcutorture: Delay forward-progress testing until boot completes
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (5 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 06/11] torture: Delay CPU-hotplug operations " Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 08/11] rcutorture: Use kcalloc() instead of kzalloc() Paul E. McKenney
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney

Forward-progress testing can hog CPUs, which is not a great thing to do
before boot has completed.  This commit therefore makes the CPU-hotplug
operations hold off until boot has completed.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 1578d330565752..b8a684459381f2 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -3457,6 +3457,8 @@ static int rcu_torture_fwd_prog(void *args)
 	int tested_tries = 0;
 
 	VERBOSE_TOROUT_STRING("rcu_torture_fwd_progress task started");
+	while (!rcu_inkernel_boot_has_ended())
+		schedule_timeout_interruptible(HZ / 10);
 	rcu_bind_current_to_nocb();
 	if (!IS_ENABLED(CONFIG_SMP) || !IS_ENABLED(CONFIG_RCU_BOOST))
 		set_user_nice(current, MAX_NICE);
-- 
2.40.1


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

* [PATCH v2 08/11] rcutorture: Use kcalloc() instead of kzalloc()
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (6 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 07/11] rcutorture: Delay forward-progress testing " Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 09/11] refscale: " Paul E. McKenney
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Qianfeng Rong,
	Paul E . McKenney

From: Qianfeng Rong <rongqianfeng@vivo.com>

Use kcalloc() in rcu_torture_writer() to gain built-in overflow protection,
making memory allocation safer when calculating allocation size compared to
explicit multiplication.

Change sizeof(ulo[0]) and sizeof(rgo[0]) to sizeof(*ulo) and sizeof(*rgo),
as this is more consistent with coding conventions.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/rcutorture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index b8a684459381f2..29fe3c01312f60 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1572,12 +1572,12 @@ rcu_torture_writer(void *arg)
 		return 0;
 	}
 	if (cur_ops->poll_active > 0) {
-		ulo = kzalloc(cur_ops->poll_active * sizeof(ulo[0]), GFP_KERNEL);
+		ulo = kcalloc(cur_ops->poll_active, sizeof(*ulo), GFP_KERNEL);
 		if (!WARN_ON(!ulo))
 			ulo_size = cur_ops->poll_active;
 	}
 	if (cur_ops->poll_active_full > 0) {
-		rgo = kzalloc(cur_ops->poll_active_full * sizeof(rgo[0]), GFP_KERNEL);
+		rgo = kcalloc(cur_ops->poll_active_full, sizeof(*rgo), GFP_KERNEL);
 		if (!WARN_ON(!rgo))
 			rgo_size = cur_ops->poll_active_full;
 	}
-- 
2.40.1


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

* [PATCH v2 09/11] refscale: Use kcalloc() instead of kzalloc()
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (7 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 08/11] rcutorture: Use kcalloc() instead of kzalloc() Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 10/11] refperf: Remove redundant kfree() after torture_stop_kthread() Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 11/11] refperf: Set reader_tasks to NULL after kfree() Paul E. McKenney
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Qianfeng Rong,
	Paul E . McKenney

From: Qianfeng Rong <rongqianfeng@vivo.com>

Use kcalloc() in main_func() to gain built-in overflow protection, making
memory allocation safer when calculating allocation size compared to
explicit multiplication.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/refscale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index df646e0694a8cc..5840fac06feb7d 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -1021,7 +1021,7 @@ static int main_func(void *arg)
 	set_user_nice(current, MAX_NICE);
 
 	VERBOSE_SCALEOUT("main_func task started");
-	result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
+	result_avg = kcalloc(nruns, sizeof(*result_avg), GFP_KERNEL);
 	buf = kzalloc(800 + 64, GFP_KERNEL);
 	if (!result_avg || !buf) {
 		SCALEOUT_ERRSTRING("out of memory");
-- 
2.40.1


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

* [PATCH v2 10/11] refperf: Remove redundant kfree() after torture_stop_kthread()
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (8 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 09/11] refscale: " Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  2025-09-18 10:29 ` [PATCH v2 11/11] refperf: Set reader_tasks to NULL after kfree() Paul E. McKenney
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, rostedt, Kaushlendra Kumar,
	Paul E . McKenney

From: Kaushlendra Kumar <kaushlendra.kumar@intel.com>

Remove unnecessary kfree(main_task) call in ref_scale_cleanup() as
torture_stop_kthread() already handles the memory cleanup for the
task structure internally.

The additional kfree(main_task) call after torture_stop_kthread()
is redundant and confusing since torture_stop_kthread() sets the
pointer to NULL, making this a no-op.

This pattern is consistent with other torture test modules where
torture_stop_kthread() is called without explicit kfree() of the
task pointer, as the torture framework manages the task lifecycle
internally.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/refscale.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index 5840fac06feb7d..7f3d23762ef7c7 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -1135,7 +1135,6 @@ ref_scale_cleanup(void)
 	kfree(reader_tasks);
 
 	torture_stop_kthread("main_task", main_task);
-	kfree(main_task);
 
 	// Do scale-type-specific cleanup operations.
 	if (cur_ops->cleanup != NULL)
-- 
2.40.1


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

* [PATCH v2 11/11] refperf: Set reader_tasks to NULL after kfree()
  2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
                   ` (9 preceding siblings ...)
  2025-09-18 10:29 ` [PATCH v2 10/11] refperf: Remove redundant kfree() after torture_stop_kthread() Paul E. McKenney
@ 2025-09-18 10:29 ` Paul E. McKenney
  10 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-09-18 10:29 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, rostedt, Kaushlendra Kumar,
	Paul E . McKenney

From: Kaushlendra Kumar <kaushlendra.kumar@intel.com>

Set reader_tasks to NULL after kfree() in ref_scale_cleanup() to
improve debugging experience with kernel debugging tools. This
follows the common pattern of NULLing pointers after freeing to
avoid dangling pointer issues during debugging sessions.

Setting pointers to NULL after freeing helps debugging tools like
kdgb,drgn, and other kernel debuggers by providing clear indication
that the memory has been freed and the pointer is no longer valid.

Suggested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/refscale.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index 7f3d23762ef7c7..19841704d8f579 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -1133,6 +1133,7 @@ ref_scale_cleanup(void)
 					     reader_tasks[i].task);
 	}
 	kfree(reader_tasks);
+	reader_tasks = NULL;
 
 	torture_stop_kthread("main_task", main_task);
 
-- 
2.40.1


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

end of thread, other threads:[~2025-09-18 10:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 10:29 [PATCH v2 0/11] RCU torture-test updates for v6.18 Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 01/11] rcutorture: Fix jitter.sh spin time Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 02/11] torture: Add --do-normal parameter to torture.sh help text Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 03/11] torture: Announce kernel boot status at torture-test startup Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 04/11] rcutorture: Suppress "Writer stall state" reports during boot Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 05/11] rcutorture: Delay rcutorture readers and writers until boot completes Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 06/11] torture: Delay CPU-hotplug operations " Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 07/11] rcutorture: Delay forward-progress testing " Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 08/11] rcutorture: Use kcalloc() instead of kzalloc() Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 09/11] refscale: " Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 10/11] refperf: Remove redundant kfree() after torture_stop_kthread() Paul E. McKenney
2025-09-18 10:29 ` [PATCH v2 11/11] refperf: Set reader_tasks to NULL after kfree() Paul E. McKenney

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