Skip to content

Commit 1d289fc

Browse files
committed
Merge branch 'torture.2025.08.14a' into HEAD
Torture-test updates: * rcutorture: Fix jitter.sh spin time * torture: Add --do-normal parameter to torture.sh help text * torture: Announce kernel boot status at torture-test startup * rcutorture: Suppress "Writer stall state" reports during boot * rcutorture: Delay rcutorture readers and writers until boot completes * torture: Delay CPU-hotplug operations until boot completes * rcutorture: Delay forward-progress testing until boot completes * rcutorture,refscale: Use kcalloc() instead of kzalloc() * refperf: Remove redundant kfree() after torture_stop_kthread() * refperf: Set reader_tasks to NULL after kfree()
2 parents a590b67 + 1441edd commit 1d289fc

5 files changed

Lines changed: 52 additions & 14 deletions

File tree

kernel/rcu/rcutorture.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))
15281528
static int
15291529
rcu_torture_writer(void *arg)
15301530
{
1531-
bool boot_ended;
1531+
bool booting_still = false;
15321532
bool can_expedite = !rcu_gp_is_expedited() && !rcu_gp_is_normal();
15331533
unsigned long cookie;
15341534
struct rcu_gp_oldstate cookie_full;
@@ -1539,6 +1539,7 @@ rcu_torture_writer(void *arg)
15391539
struct rcu_gp_oldstate gp_snap1_full;
15401540
int i;
15411541
int idx;
1542+
unsigned long j;
15421543
int oldnice = task_nice(current);
15431544
struct rcu_gp_oldstate *rgo = NULL;
15441545
int rgo_size = 0;
@@ -1571,16 +1572,26 @@ rcu_torture_writer(void *arg)
15711572
return 0;
15721573
}
15731574
if (cur_ops->poll_active > 0) {
1574-
ulo = kzalloc(cur_ops->poll_active * sizeof(ulo[0]), GFP_KERNEL);
1575+
ulo = kcalloc(cur_ops->poll_active, sizeof(*ulo), GFP_KERNEL);
15751576
if (!WARN_ON(!ulo))
15761577
ulo_size = cur_ops->poll_active;
15771578
}
15781579
if (cur_ops->poll_active_full > 0) {
1579-
rgo = kzalloc(cur_ops->poll_active_full * sizeof(rgo[0]), GFP_KERNEL);
1580+
rgo = kcalloc(cur_ops->poll_active_full, sizeof(*rgo), GFP_KERNEL);
15801581
if (!WARN_ON(!rgo))
15811582
rgo_size = cur_ops->poll_active_full;
15821583
}
15831584

1585+
// If the system is still booting, let it finish.
1586+
j = jiffies;
1587+
while (!torture_must_stop() && !rcu_inkernel_boot_has_ended()) {
1588+
booting_still = true;
1589+
schedule_timeout_interruptible(HZ);
1590+
}
1591+
if (booting_still)
1592+
pr_alert("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n",
1593+
torture_type, jiffies - j);
1594+
15841595
do {
15851596
rcu_torture_writer_state = RTWS_FIXED_DELAY;
15861597
torture_hrtimeout_us(500, 1000, &rand);
@@ -1769,13 +1780,11 @@ rcu_torture_writer(void *arg)
17691780
!rcu_gp_is_normal();
17701781
}
17711782
rcu_torture_writer_state = RTWS_STUTTER;
1772-
boot_ended = rcu_inkernel_boot_has_ended();
17731783
stutter_waited = stutter_wait("rcu_torture_writer");
17741784
if (stutter_waited &&
17751785
!atomic_read(&rcu_fwd_cb_nodelay) &&
17761786
!cur_ops->slow_gps &&
17771787
!torture_must_stop() &&
1778-
boot_ended &&
17791788
time_after(jiffies, stallsdone))
17801789
for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
17811790
if (list_empty(&rcu_tortures[i].rtort_free) &&
@@ -2437,7 +2446,8 @@ rcu_torture_reader(void *arg)
24372446
torture_hrtimeout_us(500, 1000, &rand);
24382447
lastsleep = jiffies + 10;
24392448
}
2440-
while (torture_num_online_cpus() < mynumonline && !torture_must_stop())
2449+
while (!torture_must_stop() &&
2450+
(torture_num_online_cpus() < mynumonline || !rcu_inkernel_boot_has_ended()))
24412451
schedule_timeout_interruptible(HZ / 5);
24422452
stutter_wait("rcu_torture_reader");
24432453
} while (!torture_must_stop());
@@ -2756,7 +2766,8 @@ rcu_torture_stats_print(void)
27562766
cur_ops->stats();
27572767
if (rtcv_snap == rcu_torture_current_version &&
27582768
rcu_access_pointer(rcu_torture_current) &&
2759-
!rcu_stall_is_suppressed()) {
2769+
!rcu_stall_is_suppressed() &&
2770+
rcu_inkernel_boot_has_ended()) {
27602771
int __maybe_unused flags = 0;
27612772
unsigned long __maybe_unused gp_seq = 0;
27622773

@@ -3446,6 +3457,8 @@ static int rcu_torture_fwd_prog(void *args)
34463457
int tested_tries = 0;
34473458

34483459
VERBOSE_TOROUT_STRING("rcu_torture_fwd_progress task started");
3460+
while (!rcu_inkernel_boot_has_ended())
3461+
schedule_timeout_interruptible(HZ / 10);
34493462
rcu_bind_current_to_nocb();
34503463
if (!IS_ENABLED(CONFIG_SMP) || !IS_ENABLED(CONFIG_RCU_BOOST))
34513464
set_user_nice(current, MAX_NICE);

kernel/rcu/refscale.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ static int main_func(void *arg)
10211021
set_user_nice(current, MAX_NICE);
10221022

10231023
VERBOSE_SCALEOUT("main_func task started");
1024-
result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
1024+
result_avg = kcalloc(nruns, sizeof(*result_avg), GFP_KERNEL);
10251025
buf = kzalloc(800 + 64, GFP_KERNEL);
10261026
if (!result_avg || !buf) {
10271027
SCALEOUT_ERRSTRING("out of memory");
@@ -1133,9 +1133,9 @@ ref_scale_cleanup(void)
11331133
reader_tasks[i].task);
11341134
}
11351135
kfree(reader_tasks);
1136+
reader_tasks = NULL;
11361137

11371138
torture_stop_kthread("main_task", main_task);
1138-
kfree(main_task);
11391139

11401140
// Do scale-type-specific cleanup operations.
11411141
if (cur_ops->cleanup != NULL)

kernel/torture.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ torture_onoff(void *arg)
359359
torture_hrtimeout_jiffies(onoff_holdoff, &rand);
360360
VERBOSE_TOROUT_STRING("torture_onoff end holdoff");
361361
}
362+
while (!rcu_inkernel_boot_has_ended())
363+
schedule_timeout_interruptible(HZ / 10);
362364
while (!torture_must_stop()) {
363365
if (disable_onoff_at_boot && !rcu_inkernel_boot_has_ended()) {
364366
torture_hrtimeout_jiffies(HZ / 10, &rand);
@@ -797,8 +799,9 @@ static unsigned long torture_init_jiffies;
797799
static void
798800
torture_print_module_parms(void)
799801
{
800-
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",
801-
torture_type, disable_onoff_at_boot, ftrace_dump_at_shutdown, verbose_sleep_frequency, verbose_sleep_duration, random_shuffle);
802+
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",
803+
torture_type, disable_onoff_at_boot, ftrace_dump_at_shutdown, verbose_sleep_frequency, verbose_sleep_duration, random_shuffle,
804+
rcu_inkernel_boot_has_ended() ? "" : " still booting");
802805
}
803806

804807
/*

tools/testing/selftests/rcutorture/bin/jitter.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ do
3939
fi
4040
done
4141

42+
# Uses global variables startsecs, startns, endsecs, endns, and limit.
43+
# Exit code is success for time not yet elapsed and failure otherwise.
44+
function timecheck {
45+
local done=`awk -v limit=$limit \
46+
-v startsecs=$startsecs \
47+
-v startns=$startns \
48+
-v endsecs=$endsecs \
49+
-v endns=$endns < /dev/null '
50+
BEGIN {
51+
delta = (endsecs - startsecs) * 1000 * 1000;
52+
delta += int((endns - startns) / 1000);
53+
print delta >= limit;
54+
}'`
55+
return $done
56+
}
57+
4258
while :
4359
do
4460
# Check for done.
@@ -85,15 +101,20 @@ do
85101
n=$(($n+1))
86102
sleep .$sleeptime
87103

88-
# Spin a random duration
104+
# Spin a random duration, but with rather coarse granularity.
89105
limit=`awk -v me=$me -v n=$n -v spinmax=$spinmax 'BEGIN {
90106
srand(n + me + systime());
91107
printf("%06d", int(rand() * spinmax));
92108
}' < /dev/null`
93109
n=$(($n+1))
94-
for i in {1..$limit}
110+
startsecs=`date +%s`
111+
startns=`date +%N`
112+
endsecs=$startns
113+
endns=$endns
114+
while timecheck
95115
do
96-
echo > /dev/null
116+
endsecs=`date +%s`
117+
endns=`date +%N`
97118
done
98119
done
99120

tools/testing/selftests/rcutorture/bin/torture.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ usage () {
9494
echo " --do-kvfree / --do-no-kvfree / --no-kvfree"
9595
echo " --do-locktorture / --do-no-locktorture / --no-locktorture"
9696
echo " --do-none"
97+
echo " --do-normal / --do-no-normal / --no-normal"
9798
echo " --do-rcuscale / --do-no-rcuscale / --no-rcuscale"
9899
echo " --do-rcutasksflavors / --do-no-rcutasksflavors / --no-rcutasksflavors"
99100
echo " --do-rcutorture / --do-no-rcutorture / --no-rcutorture"

0 commit comments

Comments
 (0)