Torture-test updates for v5.6
Subsystems (4)
Paul E. McKenney
maintainercover Torture-test updates for v5.6
Hello!
This series provides torture-test updates.
1. Use gawk instead of awk for systime() function.
2. Dispense with Dracut for initrd creation.
3. Handle jitter for CPUs that cannot be offlined.
4. Handle systems lacking the mpstat command.
5. Add worst-case call_rcu() forward-progress results.
6. Pull callback forward-progress data into rcu_fwd struct.
7. Thread rcu_fwd pointer through forward-progress functions.
8. Move to dynamic initialization of rcu_fwds.
9. Complete threading rcu_fwd pointers through functions.
10. Dynamically allocate rcu_fwds structure.
11. Allow "CFLIST" to specify default list of scenarios.
12. Hoist calls to lscpu to higher-level kvm.sh script.
Thanx, Paul
------------------------------------------------------------------------
kernel/rcu/rcutorture.c | 241 +++++++------- tools/testing/selftests/rcutorture/bin/cpus2use.sh | 11 tools/testing/selftests/rcutorture/bin/jitter.sh | 30 + tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh | 3 tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 13 tools/testing/selftests/rcutorture/bin/kvm.sh | 30 + tools/testing/selftests/rcutorture/bin/mkinitrd.sh | 55 --- 7 files changed, 194 insertions(+), 189 deletions(-)
[email protected]
maintainerPATCH 1/12 torture: Use gawk instead of awk for systime() function
From: "Paul E. McKenney" <[email protected]>
In many environments, gawk provides systime(), but awk doesn't. This commit therefore changes awk scripts using systime() to instead be gawk scripts.
--- tools/testing/selftests/rcutorture/bin/jitter.sh | 4 ++-- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/rcutorture/bin/jitter.sh +2 -2
@@ -23,12 +23,12 @@ spinmax=${4-1000} n=1 -starttime=`awk 'BEGIN { print systime(); }' < /dev/null` +starttime=`gawk 'BEGIN { print systime(); }' < /dev/null` while : do # Check for done. - t=`awk -v s=$starttime 'BEGIN { print systime() - s; }' < /dev/null` + t=`gawk -v s=$starttime 'BEGIN { print systime() - s; }' < /dev/null` if test "$t" -gt "$duration" then exit 0;
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +3 -3
@@ -123,7 +123,7 @@ qemu_args=$5 boot_args=$6 cd $KVM -kstarttime=`awk 'BEGIN { print systime() }' < /dev/null` +kstarttime=`gawk 'BEGIN { print systime() }' < /dev/null` if test -z "$TORTURE_BUILDONLY" then echo ' ---' `date`: Starting kernel
@@ -177,7 +177,7 @@ do then qemu_pid=`cat "$resdir/qemu_pid"` fi - kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` + kruntime=`gawk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` if test -z "$qemu_pid" || kill -0 "$qemu_pid" > /dev/null 2>&1 then if test $kruntime -ge $seconds
@@ -213,7 +213,7 @@ then oldline="`tail $resdir/console.log`" while : do - kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` + kruntime=`gawk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` if kill -0 $qemu_pid > /dev/null 2>&1 then :
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 2/12 rcutorture: Dispense with Dracut for initrd creation
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The dracut scripting does not work on all platforms, and there are no known failures from the init binary based on the statically linked C program. This commit therefore removes the dracut scripting so that the statically linked C program is always used to create the init "script".
--- tools/testing/selftests/rcutorture/bin/mkinitrd.sh | 55 ++-------------------- 1 file changed, 3 insertions(+), 52 deletions(-)
tools/testing/selftests/rcutorture/bin/mkinitrd.sh +3 -52
@@ -20,58 +20,9 @@ if [ -s "$D/initrd/init" ]; then exit 0 fi -T=${TMPDIR-/tmp}/mkinitrd.sh.$$ -trap 'rm -rf $T' 0 2 -mkdir $T - -cat > $T/init << '__EOF___' -#!/bin/sh -# Run in userspace a few milliseconds every second. This helps to -# exercise the NO_HZ_FULL portions of RCU. The 192 instances of "a" was -# empirically shown to give a nice multi-millisecond burst of user-mode -# execution on a 2GHz CPU, as desired. Modern CPUs will vary from a -# couple of milliseconds up to perhaps 100 milliseconds, which is an -# acceptable range. -# -# Why not calibrate an exact delay? Because within this initrd, we -# are restricted to Bourne-shell builtins, which as far as I know do not -# provide any means of obtaining a fine-grained timestamp. - -a4="a a a a" -a16="$a4 $a4 $a4 $a4" -a64="$a16 $a16 $a16 $a16" -a192="$a64 $a64 $a64" -while : -do - q= - for i in $a192 - do - q="$q $i" - done - sleep 1 -done -__EOF___ - -# Try using dracut to create initrd -if command -v dracut >/dev/null 2>&1 -then - echo Creating $D/initrd using dracut. - # Filesystem creation - dracut --force --no-hostonly --no-hostonly-cmdline --module "base" $T/initramfs.img - cd $D - mkdir -p initrd - cd initrd - zcat $T/initramfs.img | cpio -id - cp $T/init init - chmod +x init - echo Done creating $D/initrd using dracut - exit 0 -fi - -# No dracut, so create a C-language initrd/init program and statically -# link it. This results in a very small initrd, but might be a bit less -# future-proof than dracut. -echo "Could not find dracut, attempting C initrd" +# Create a C-language initrd/init infinite-loop program and statically +# link it. This results in a very small initrd. +echo "Creating a statically linked C-language initrd" cd $D mkdir -p initrd cd initrd
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 3/12 torture: Handle jitter for CPUs that cannot be offlined
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Currently, jitter.sh assumes that the underlying hypervisor will be configured with all CPUs hotpluggable, with the possible exception of CPU 0. However, there are installations where the hypervisor prohibits offlining, which breaks jitter.sh. This commit therefore lists the CPUs that cannot be offlined up front, and checks for the case where no CPU can be offlined in the loop.
--- tools/testing/selftests/rcutorture/bin/jitter.sh | 26 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/jitter.sh +20 -6
@@ -25,6 +25,18 @@ n=1 starttime=`gawk 'BEGIN { print systime(); }' < /dev/null` +nohotplugcpus= +for i in /sys/devices/system/cpu/cpu[0-9]* +do + if test -f $i/online + then + : + else + curcpu=`echo $i | sed -e 's/^[^0-9]*//'` + nohotplugcpus="$nohotplugcpus $curcpu" + fi +done + while : do # Check for done.
@@ -35,13 +47,15 @@ do fi # Set affinity to randomly selected online CPU - cpus=`grep 1 /sys/devices/system/cpu/*/online | - sed -e 's,/[^/]*$,,' -e 's/^[^0-9]*//'` - - # Do not leave out poor old cpu0 which may not be hot-pluggable - if [ ! -f "/sys/devices/system/cpu/cpu0/online" ]; then - cpus="0 $cpus" + if cpus=`grep 1 /sys/devices/system/cpu/*/online 2>&1 | + sed -e 's,/[^/]*$,,' -e 's/^[^0-9]*//'` + then + : + else + cpus= fi + # Do not leave out non-hot-pluggable CPUs + cpus="$cpus $nohotplugcpus" cpumask=`awk -v cpus="$cpus" -v me=$me -v n=$n 'BEGIN { srand(n + me + systime());
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 4/12 torture: Handle systems lacking the mpstat command
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
The rcutorture scripting uses the mpstat command to determine how much the system is being used, and adjusts make's -j argument accordingly. However, mpstat isn't installed by default, so it would be good if the scripting does something useful when mpstat isn't present.
This commit therefore makes the scripts assumes that if mpstat is not present, they are free to use all the CPUs.
--- tools/testing/selftests/rcutorture/bin/cpus2use.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tools/testing/selftests/rcutorture/bin/cpus2use.sh +9 -2
@@ -15,8 +15,15 @@ then exit 0 fi ncpus=`grep '^processor' /proc/cpuinfo | wc -l` -idlecpus=`mpstat | tail -1 | \ - awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'` +if mpstat -V > /dev/null 2>&1 +then + idlecpus=`mpstat | tail -1 | \ + awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'` +else + # No mpstat command, so use all available CPUs. + echo The mpstat command is not available, so greedily using all CPUs. + idlecpus=$ncpus +fi awk -v ncpus=$ncpus -v idlecpus=$idlecpus < /dev/null ' BEGIN { cpus2use = idlecpus;
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 5/12 rcutorture: Add worst-case call_rcu() forward-progress results
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit adds the worst-case results from any call_rcu() forward-progress tests to the rcutorture test-summary output.
--- tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-recheck-rcu.sh +2 -1
@@ -25,6 +25,7 @@ stopstate="`grep 'End-test grace-period state: g' $i/console.log 2> /dev/null | tail -1 | sed -e 's/^\[[ 0-9.]*] //' | awk '{ print \"[\" $1 \" \" $5 \" \" $6 \" \" $7 \"]\"; }' | tr -d '\012\015'`" +fwdprog="`grep 'rcu_torture_fwd_prog_cr Duration' $i/console.log 2> /dev/null | sed -e 's/^\[[^]]*] //' | sort -k15nr | head -1 | awk '{ print $14 " " $15 }'`" if test -z "$ngps" then echo "$configfile ------- " $stopstate
@@ -39,7 +40,7 @@ else BEGIN { print ngps / dur }' < /dev/null` title="$title ($ngpsps/s)" fi - echo $title $stopstate + echo $title $stopstate $fwdprog nclosecalls=`grep --binary-files=text 'torture: Reader Batch' $i/console.log | tail -1 | awk '{for (i=NF-8;i<=NF;i++) sum+=$i; } END {print sum}'` if test -z "$nclosecalls" then
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 6/12 rcutorture: Pull callback forward-progress data into rcu_fwd struct
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
Now that RCU behaves reasonably well with the current single-kthread call_rcu() forward-progress testing, it is time to add more kthreads. This commit takes a first step towards that goal by wrapping what will be the per-kthread data into a new rcu_fwd structure.
--- kernel/rcu/rcutorture.c | 103 +++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 45 deletions(-)
kernel/rcu/rcutorture.c +58 -45
@@ -1663,23 +1663,34 @@ struct rcu_fwd_cb {struct rcu_fwd_cb *rfc_next;int rfc_gps; }; -static DEFINE_SPINLOCK (rcu_fwd_lock); -static struct rcu_fwd_cb *rcu_fwd_cb_head; -static struct rcu_fwd_cb **rcu_fwd_cb_tail = &rcu_fwd_cb_head; -static long n_launders_cb; -static unsigned long rcu_fwd_startat; -static bool rcu_fwd_emergency_stop; +#define MAX_FWD_CB_JIFFIES (8 * HZ)/* Maximum CB test duration. */ #define MIN_FWD_CB_LAUNDERS 3/* This many CB invocations to count. */ #define MIN_FWD_CBS_LAUNDERED 100/* Number of counted CBs. */ #define FWD_CBS_HIST_DIV 10/* Histogram buckets/second. */ +#define N_LAUNDERS_HIST (2 * MAX_FWD_CB_JIFFIES / (HZ / FWD_CBS_HIST_DIV)) +struct rcu_launder_hist {long n_launders;unsigned long launder_gp_seq; }; -#define N_LAUNDERS_HIST (2 * MAX_FWD_CB_JIFFIES / (HZ / FWD_CBS_HIST_DIV)) -static struct rcu_launder_hist n_launders_hist[N_LAUNDERS_HIST ]; -static unsigned long rcu_launder_gp_seq_start; + +struct rcu_fwd { +spinlock_t rcu_fwd_lock; +struct rcu_fwd_cb *rcu_fwd_cb_head; +struct rcu_fwd_cb **rcu_fwd_cb_tail; +long n_launders_cb; +unsigned long rcu_fwd_startat; +struct rcu_launder_hist n_launders_hist[N_LAUNDERS_HIST ]; +unsigned long rcu_launder_gp_seq_start; +}; + +struct rcu_fwd rcu_fwds = { + .rcu_fwd_lock =__SPIN_LOCK_UNLOCKED (rcu_fwds.rcu_fwd_lock), + .rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head, +}; + +bool rcu_fwd_emergency_stop;static void rcu_torture_fwd_cb_hist (void ) {
@@ -1688,16 +1699,17 @@ static void rcu_torture_fwd_cb_hist(void)int i;int j; -for (i =ARRAY_SIZE (n_launders_hist) -1 ; i >0 ; i--) -if (n_launders_hist[i].n_launders >0 ) +for (i =ARRAY_SIZE (rcu_fwds.n_launders_hist) -1 ; i >0 ; i--) +if (rcu_fwds.n_launders_hist[i].n_launders >0 )break ;pr_alert ("%s: Callback-invocation histogram (duration %lu jiffies):" , - __func__, jiffies - rcu_fwd_startat); - gps_old = rcu_launder_gp_seq_start; + __func__, jiffies - rcu_fwds.rcu_fwd_startat); + gps_old = rcu_fwds.rcu_launder_gp_seq_start;for (j =0 ; j <= i; j++) { - gps = n_launders_hist[j].launder_gp_seq; + gps = rcu_fwds.n_launders_hist[j].launder_gp_seq;pr_cont (" %ds/%d: %ld:%ld" , - j +1 ,FWD_CBS_HIST_DIV , n_launders_hist[j].n_launders, + j +1 ,FWD_CBS_HIST_DIV , + rcu_fwds.n_launders_hist[j].n_launders,rcutorture_seq_diff (gps, gps_old)); gps_old = gps; }
@@ -1714,17 +1726,17 @@ static void rcu_torture_fwd_cb_cr(struct rcu_head *rhp) rfcp->rfc_next =NULL ; rfcp->rfc_gps++; -spin_lock_irqsave (&rcu_fwd_lock, flags); - rfcpp = rcu_fwd_cb_tail; - rcu_fwd_cb_tail = &rfcp->rfc_next; +spin_lock_irqsave (&rcu_fwds.rcu_fwd_lock, flags); + rfcpp = rcu_fwds.rcu_fwd_cb_tail; + rcu_fwds.rcu_fwd_cb_tail = &rfcp->rfc_next;WRITE_ONCE (*rfcpp, rfcp); -WRITE_ONCE (n_launders_cb, n_launders_cb +1 ); - i = ((jiffies - rcu_fwd_startat) / (HZ /FWD_CBS_HIST_DIV )); -if (i >=ARRAY_SIZE (n_launders_hist)) - i =ARRAY_SIZE (n_launders_hist) -1 ; - n_launders_hist[i].n_launders++; - n_launders_hist[i].launder_gp_seq = cur_ops->get_gp_seq (); -spin_unlock_irqrestore (&rcu_fwd_lock, flags); +WRITE_ONCE (rcu_fwds.n_launders_cb, rcu_fwds.n_launders_cb +1 ); + i = ((jiffies - rcu_fwds.rcu_fwd_startat) / (HZ /FWD_CBS_HIST_DIV )); +if (i >=ARRAY_SIZE (rcu_fwds.n_launders_hist)) + i =ARRAY_SIZE (rcu_fwds.n_launders_hist) -1 ; + rcu_fwds.n_launders_hist[i].n_launders++; + rcu_fwds.n_launders_hist[i].launder_gp_seq = cur_ops->get_gp_seq (); +spin_unlock_irqrestore (&rcu_fwds.rcu_fwd_lock, flags); }// Give the scheduler a chance, even on nohz_full CPUs.
@@ -1751,16 +1763,16 @@ static unsigned long rcu_torture_fwd_prog_cbfree(void)struct rcu_fwd_cb *rfcp;for (;;) { -spin_lock_irqsave (&rcu_fwd_lock, flags); - rfcp = rcu_fwd_cb_head; +spin_lock_irqsave (&rcu_fwds.rcu_fwd_lock, flags); + rfcp = rcu_fwds.rcu_fwd_cb_head;if (!rfcp) { -spin_unlock_irqrestore (&rcu_fwd_lock, flags); +spin_unlock_irqrestore (&rcu_fwds.rcu_fwd_lock, flags);break ; } - rcu_fwd_cb_head = rfcp->rfc_next; -if (!rcu_fwd_cb_head) - rcu_fwd_cb_tail = &rcu_fwd_cb_head; -spin_unlock_irqrestore (&rcu_fwd_lock, flags); + rcu_fwds.rcu_fwd_cb_head = rfcp->rfc_next; +if (!rcu_fwds.rcu_fwd_cb_head) + rcu_fwds.rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head; +spin_unlock_irqrestore (&rcu_fwds.rcu_fwd_lock, flags);kfree (rfcp); freed++;rcu_torture_fwd_prog_cond_resched (freed);
@@ -1804,8 +1816,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries) sd = cur_ops->stall_dur () +1 ; sd4 = (sd + fwd_progress_div -1 ) / fwd_progress_div; dur = sd4 +torture_random (&trs) % (sd - sd4); -WRITE_ONCE (rcu_fwd_startat, jiffies); - stopat = rcu_fwd_startat + dur; +WRITE_ONCE (rcu_fwds.rcu_fwd_startat, jiffies); + stopat = rcu_fwds.rcu_fwd_startat + dur;while (time_before (jiffies, stopat) && !shutdown_time_arrived () && !READ_ONCE (rcu_fwd_emergency_stop) && !torture_must_stop ()) {
@@ -1864,23 +1876,23 @@ static void rcu_torture_fwd_prog_cr(void)/* Loop continuously posting RCU callbacks. */ WRITE_ONCE (rcu_fwd_cb_nodelay, true); cur_ops->sync ();/* Later readers see above write. */ -WRITE_ONCE (rcu_fwd_startat, jiffies); - stopat = rcu_fwd_startat +MAX_FWD_CB_JIFFIES ; +WRITE_ONCE (rcu_fwds.rcu_fwd_startat, jiffies); + stopat = rcu_fwds.rcu_fwd_startat +MAX_FWD_CB_JIFFIES ; n_launders =0 ; - n_launders_cb =0 ; + rcu_fwds.n_launders_cb =0 ;// Hoist initialization for multi-kthread n_launders_sa =0 ; n_max_cbs =0 ; n_max_gps =0 ; -for (i =0 ; i <ARRAY_SIZE (n_launders_hist); i++) - n_launders_hist[i].n_launders =0 ; +for (i =0 ; i <ARRAY_SIZE (rcu_fwds.n_launders_hist); i++) + rcu_fwds.n_launders_hist[i].n_launders =0 ; cver =READ_ONCE (rcu_torture_current_version); gps = cur_ops->get_gp_seq (); - rcu_launder_gp_seq_start = gps; + rcu_fwds.rcu_launder_gp_seq_start = gps;tick_dep_set_task (current,TICK_DEP_BIT_RCU );while (time_before (jiffies, stopat) && !shutdown_time_arrived () && !READ_ONCE (rcu_fwd_emergency_stop) && !torture_must_stop ()) { - rfcp =READ_ONCE (rcu_fwd_cb_head); + rfcp =READ_ONCE (rcu_fwds.rcu_fwd_cb_head); rfcpn =NULL ;if (rfcp) rfcpn =READ_ONCE (rfcp->rfc_next);
@@ -1888,7 +1900,7 @@ static void rcu_torture_fwd_prog_cr(void)if (rfcp->rfc_gps >=MIN_FWD_CB_LAUNDERS && ++n_max_gps >=MIN_FWD_CBS_LAUNDERED )break ; - rcu_fwd_cb_head = rfcpn; + rcu_fwds.rcu_fwd_cb_head = rfcpn; n_launders++; n_launders_sa++; }else {
@@ -1910,7 +1922,7 @@ static void rcu_torture_fwd_prog_cr(void) } } stoppedat = jiffies; - n_launders_cb_snap =READ_ONCE (n_launders_cb); + n_launders_cb_snap =READ_ONCE (rcu_fwds.n_launders_cb); cver =READ_ONCE (rcu_torture_current_version) - cver; gps =rcutorture_seq_diff (cur_ops->get_gp_seq (), gps); cur_ops->cb_barrier ();/* Wait for callbacks to be invoked. */
@@ -1921,7 +1933,8 @@ static void rcu_torture_fwd_prog_cr(void)WARN_ON (n_max_gps <MIN_FWD_CBS_LAUNDERED );pr_alert ("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld\n" , __func__, - stoppedat - rcu_fwd_startat, jiffies - stoppedat, + stoppedat - rcu_fwds.rcu_fwd_startat, + jiffies - stoppedat, n_launders + n_max_cbs - n_launders_cb_snap, n_launders, n_launders_sa, n_max_gps, n_max_cbs, cver, gps);
@@ -1943,7 +1956,7 @@ static int rcutorture_oom_notify(struct notifier_block *self,WARN (1 ,"%s invoked upon OOM during forward-progress testing.\n" , __func__);rcu_torture_fwd_cb_hist (); -rcu_fwd_progress_check (1 + (jiffies -READ_ONCE (rcu_fwd_startat)) /2 ); +rcu_fwd_progress_check (1 + (jiffies -READ_ONCE (rcu_fwds.rcu_fwd_startat)) /2 );WRITE_ONCE (rcu_fwd_emergency_stop, true);smp_mb ();/* Emergency stop before free and wait to avoid hangs. */ pr_info("%s: Freed %lu RCU callbacks.\n",
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 7/12 rcutorture: Thread rcu_fwd pointer through forward-progress functions
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
In order to add multiple kthreads, it will be necessary to allow the various functions to operate on a pointer to their kthread's rcu_fwd structure. This commit therefore starts the process of adding the needed "struct rcu_fwd" parameters and arguments to the various callback forward-progress functions.
Note that rcutorture_oom_notify() and rcu_torture_fwd_cb_hist() will eventually need to iterate over all kthreads' rcu_fwd structures.
--- kernel/rcu/rcutorture.c | 78 ++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 37 deletions(-)
kernel/rcu/rcutorture.c +41 -37
@@ -1661,6 +1661,7 @@ static void rcu_torture_fwd_prog_cb(struct rcu_head *rhp)struct rcu_fwd_cb {struct rcu_head rh;struct rcu_fwd_cb *rfc_next; +struct rcu_fwd *rfc_rfp;int rfc_gps; };
@@ -1692,24 +1693,24 @@ struct rcu_fwd rcu_fwds = {bool rcu_fwd_emergency_stop; -static void rcu_torture_fwd_cb_hist (void ) +static void rcu_torture_fwd_cb_hist (struct rcu_fwd *rfp) {unsigned long gps;unsigned long gps_old;int i;int j; -for (i =ARRAY_SIZE (rcu_fwds.n_launders_hist) -1 ; i >0 ; i--) -if (rcu_fwds.n_launders_hist[i].n_launders >0 ) +for (i =ARRAY_SIZE (rfp->n_launders_hist) -1 ; i >0 ; i--) +if (rfp->n_launders_hist[i].n_launders >0 )break ;pr_alert ("%s: Callback-invocation histogram (duration %lu jiffies):" , - __func__, jiffies - rcu_fwds.rcu_fwd_startat); - gps_old = rcu_fwds.rcu_launder_gp_seq_start; + __func__, jiffies - rfp->rcu_fwd_startat); + gps_old = rfp->rcu_launder_gp_seq_start;for (j =0 ; j <= i; j++) { - gps = rcu_fwds.n_launders_hist[j].launder_gp_seq; + gps = rfp->n_launders_hist[j].launder_gp_seq;pr_cont (" %ds/%d: %ld:%ld" , j +1 ,FWD_CBS_HIST_DIV , - rcu_fwds.n_launders_hist[j].n_launders, + rfp->n_launders_hist[j].n_launders,rcutorture_seq_diff (gps, gps_old)); gps_old = gps; }
@@ -1723,20 +1724,21 @@ static void rcu_torture_fwd_cb_cr(struct rcu_head *rhp)int i; struct rcu_fwd_cb *rfcp = container_of(rhp, struct rcu_fwd_cb, rh);struct rcu_fwd_cb **rfcpp; +struct rcu_fwd *rfp = rfcp->rfc_rfp; rfcp->rfc_next =NULL ; rfcp->rfc_gps++; -spin_lock_irqsave (&rcu_fwds.rcu_fwd_lock, flags); - rfcpp = rcu_fwds.rcu_fwd_cb_tail; - rcu_fwds.rcu_fwd_cb_tail = &rfcp->rfc_next; +spin_lock_irqsave (&rfp->rcu_fwd_lock, flags); + rfcpp = rfp->rcu_fwd_cb_tail; + rfp->rcu_fwd_cb_tail = &rfcp->rfc_next;WRITE_ONCE (*rfcpp, rfcp); -WRITE_ONCE (rcu_fwds.n_launders_cb, rcu_fwds.n_launders_cb +1 ); - i = ((jiffies - rcu_fwds.rcu_fwd_startat) / (HZ /FWD_CBS_HIST_DIV )); -if (i >=ARRAY_SIZE (rcu_fwds.n_launders_hist)) - i =ARRAY_SIZE (rcu_fwds.n_launders_hist) -1 ; - rcu_fwds.n_launders_hist[i].n_launders++; - rcu_fwds.n_launders_hist[i].launder_gp_seq = cur_ops->get_gp_seq (); -spin_unlock_irqrestore (&rcu_fwds.rcu_fwd_lock, flags); +WRITE_ONCE (rfp->n_launders_cb, rfp->n_launders_cb +1 ); + i = ((jiffies - rfp->rcu_fwd_startat) / (HZ /FWD_CBS_HIST_DIV )); +if (i >=ARRAY_SIZE (rfp->n_launders_hist)) + i =ARRAY_SIZE (rfp->n_launders_hist) -1 ; + rfp->n_launders_hist[i].n_launders++; + rfp->n_launders_hist[i].launder_gp_seq = cur_ops->get_gp_seq (); +spin_unlock_irqrestore (&rfp->rcu_fwd_lock, flags); }// Give the scheduler a chance, even on nohz_full CPUs.
@@ -1786,7 +1788,8 @@ static unsigned long rcu_torture_fwd_prog_cbfree(void) }/* Carry out need_resched()/cond_resched() forward-progress testing. */ -static void rcu_torture_fwd_prog_nr (int *tested,int *tested_tries) +static void rcu_torture_fwd_prog_nr (struct rcu_fwd *rfp, +int *tested,int *tested_tries) {unsigned long cver;unsigned long dur;
@@ -1816,8 +1819,8 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries) sd = cur_ops->stall_dur () +1 ; sd4 = (sd + fwd_progress_div -1 ) / fwd_progress_div; dur = sd4 +torture_random (&trs) % (sd - sd4); -WRITE_ONCE (rcu_fwds.rcu_fwd_startat, jiffies); - stopat = rcu_fwds.rcu_fwd_startat + dur; +WRITE_ONCE (rfp->rcu_fwd_startat, jiffies); + stopat = rfp->rcu_fwd_startat + dur;while (time_before (jiffies, stopat) && !shutdown_time_arrived () && !READ_ONCE (rcu_fwd_emergency_stop) && !torture_must_stop ()) {
@@ -1852,7 +1855,7 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries) }/* Carry out call_rcu() forward-progress testing. */ -static void rcu_torture_fwd_prog_cr (void ) +static void rcu_torture_fwd_prog_cr (struct rcu_fwd *rfp) {unsigned long cver;unsigned long flags;
@@ -1876,23 +1879,23 @@ static void rcu_torture_fwd_prog_cr(void)/* Loop continuously posting RCU callbacks. */ WRITE_ONCE (rcu_fwd_cb_nodelay, true); cur_ops->sync ();/* Later readers see above write. */ -WRITE_ONCE (rcu_fwds.rcu_fwd_startat, jiffies); - stopat = rcu_fwds.rcu_fwd_startat +MAX_FWD_CB_JIFFIES ; +WRITE_ONCE (rfp->rcu_fwd_startat, jiffies); + stopat = rfp->rcu_fwd_startat +MAX_FWD_CB_JIFFIES ; n_launders =0 ; - rcu_fwds.n_launders_cb =0 ;// Hoist initialization for multi-kthread + rfp->n_launders_cb =0 ;// Hoist initialization for multi-kthread n_launders_sa =0 ; n_max_cbs =0 ; n_max_gps =0 ; -for (i =0 ; i <ARRAY_SIZE (rcu_fwds.n_launders_hist); i++) - rcu_fwds.n_launders_hist[i].n_launders =0 ; +for (i =0 ; i <ARRAY_SIZE (rfp->n_launders_hist); i++) + rfp->n_launders_hist[i].n_launders =0 ; cver =READ_ONCE (rcu_torture_current_version); gps = cur_ops->get_gp_seq (); - rcu_fwds.rcu_launder_gp_seq_start = gps; + rfp->rcu_launder_gp_seq_start = gps;tick_dep_set_task (current,TICK_DEP_BIT_RCU );while (time_before (jiffies, stopat) && !shutdown_time_arrived () && !READ_ONCE (rcu_fwd_emergency_stop) && !torture_must_stop ()) { - rfcp =READ_ONCE (rcu_fwds.rcu_fwd_cb_head); + rfcp =READ_ONCE (rfp->rcu_fwd_cb_head); rfcpn =NULL ;if (rfcp) rfcpn =READ_ONCE (rfcp->rfc_next);
@@ -1900,7 +1903,7 @@ static void rcu_torture_fwd_prog_cr(void)if (rfcp->rfc_gps >=MIN_FWD_CB_LAUNDERS && ++n_max_gps >=MIN_FWD_CBS_LAUNDERED )break ; - rcu_fwds.rcu_fwd_cb_head = rfcpn; + rfp->rcu_fwd_cb_head = rfcpn; n_launders++; n_launders_sa++; }else {
@@ -1912,6 +1915,7 @@ static void rcu_torture_fwd_prog_cr(void) n_max_cbs++; n_launders_sa =0 ; rfcp->rfc_gps =0 ; + rfcp->rfc_rfp = rfp; } cur_ops->call (&rfcp->rh, rcu_torture_fwd_cb_cr);rcu_torture_fwd_prog_cond_resched (n_launders + n_max_cbs);
@@ -1922,7 +1926,7 @@ static void rcu_torture_fwd_prog_cr(void) } } stoppedat = jiffies; - n_launders_cb_snap =READ_ONCE (rcu_fwds.n_launders_cb); + n_launders_cb_snap =READ_ONCE (rfp->n_launders_cb); cver =READ_ONCE (rcu_torture_current_version) - cver; gps =rcutorture_seq_diff (cur_ops->get_gp_seq (), gps); cur_ops->cb_barrier ();/* Wait for callbacks to be invoked. */
@@ -1933,12 +1937,11 @@ static void rcu_torture_fwd_prog_cr(void)WARN_ON (n_max_gps <MIN_FWD_CBS_LAUNDERED );pr_alert ("%s Duration %lu barrier: %lu pending %ld n_launders: %ld n_launders_sa: %ld n_max_gps: %ld n_max_cbs: %ld cver %ld gps %ld\n" , __func__, - stoppedat - rcu_fwds.rcu_fwd_startat, - jiffies - stoppedat, + stoppedat - rfp->rcu_fwd_startat, jiffies - stoppedat, n_launders + n_max_cbs - n_launders_cb_snap, n_launders, n_launders_sa, n_max_gps, n_max_cbs, cver, gps); -rcu_torture_fwd_cb_hist (); +rcu_torture_fwd_cb_hist (rfp); }schedule_timeout_uninterruptible (HZ );/* Let CBs drain. */ tick_dep_clear_task (current,TICK_DEP_BIT_RCU );
@@ -1955,7 +1958,7 @@ static int rcutorture_oom_notify(struct notifier_block *self, {WARN (1 ,"%s invoked upon OOM during forward-progress testing.\n" , __func__); -rcu_torture_fwd_cb_hist (); +rcu_torture_fwd_cb_hist (&rcu_fwds);rcu_fwd_progress_check (1 + (jiffies -READ_ONCE (rcu_fwds.rcu_fwd_startat)) /2 );WRITE_ONCE (rcu_fwd_emergency_stop, true);smp_mb ();/* Emergency stop before free and wait to avoid hangs. */
@@ -1980,6 +1983,7 @@ static struct notifier_block rcutorture_oom_nb = {/* Carry out grace-period forward-progress testing. */ static int rcu_torture_fwd_prog (void *args) { +struct rcu_fwd *rfp = args;int tested =0 ;int tested_tries =0 ;
@@ -1991,8 +1995,8 @@ static int rcu_torture_fwd_prog(void *args)schedule_timeout_interruptible (fwd_progress_holdoff *HZ );WRITE_ONCE (rcu_fwd_emergency_stop, false);register_oom_notifier (&rcutorture_oom_nb); -rcu_torture_fwd_prog_nr (&tested, &tested_tries); -rcu_torture_fwd_prog_cr (); +rcu_torture_fwd_prog_nr (rfp, &tested, &tested_tries); +rcu_torture_fwd_prog_cr (rfp);unregister_oom_notifier (&rcutorture_oom_nb);/* Avoid slow periods, better to test when busy. */
@@ -2027,7 +2031,7 @@ static int __init rcu_torture_fwd_prog_init(void)if (fwd_progress_div <=0 ) fwd_progress_div =4 ;return torture_create_kthread (rcu_torture_fwd_prog, -NULL , fwd_prog_task); + &rcu_fwds, fwd_prog_task); }/* Callback function for RCU barrier testing. */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 8/12 rcutorture: Move to dynamic initialization of rcu_fwds
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
In order to add multiple call_rcu() forward-progress kthreads, it will be necessary to dynamically allocate and initialize. This commit therefore moves the initialization from compile time to instead immediately precede thread-creation time.
--- kernel/rcu/rcutorture.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/rcu/rcutorture.c +3 -5
@@ -1686,11 +1686,7 @@ struct rcu_fwd {unsigned long rcu_launder_gp_seq_start; }; -struct rcu_fwd rcu_fwds = { - .rcu_fwd_lock =__SPIN_LOCK_UNLOCKED (rcu_fwds.rcu_fwd_lock), - .rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head, -}; - +struct rcu_fwd rcu_fwds;bool rcu_fwd_emergency_stop;static void rcu_torture_fwd_cb_hist (struct rcu_fwd *rfp)
@@ -2026,6 +2022,8 @@ static int __init rcu_torture_fwd_prog_init(void)WARN_ON (1 );/* Make sure rcutorture notices conflict. */ return 0 ; } +spin_lock_init (&rcu_fwds.rcu_fwd_lock); + rcu_fwds.rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head;if (fwd_progress_holdoff <=0 ) fwd_progress_holdoff =1 ;if (fwd_progress_div <=0 )
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 9/12 rcutorture: Complete threading rcu_fwd pointers through functions
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit threads pointers to rcu_fwd structures through the remaining functions using rcu_fwds directly, namely rcu_torture_fwd_prog_cbfree(), rcutorture_oom_notify() and rcu_torture_fwd_prog_init().
--- kernel/rcu/rcutorture.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
kernel/rcu/rcutorture.c +21 -18
@@ -1754,23 +1754,23 @@ static void rcu_torture_fwd_prog_cond_resched(unsigned long iter)* Free all callbacks on the rcu_fwd_cb_head list, either because the * test is over or because we hit an OOM event. */ -static unsigned long rcu_torture_fwd_prog_cbfree (void ) +static unsigned long rcu_torture_fwd_prog_cbfree (struct rcu_fwd *rfp) {unsigned long flags;unsigned long freed =0 ;struct rcu_fwd_cb *rfcp;for (;;) { -spin_lock_irqsave (&rcu_fwds.rcu_fwd_lock, flags); - rfcp = rcu_fwds.rcu_fwd_cb_head; +spin_lock_irqsave (&rfp->rcu_fwd_lock, flags); + rfcp = rfp->rcu_fwd_cb_head;if (!rfcp) { -spin_unlock_irqrestore (&rcu_fwds.rcu_fwd_lock, flags); +spin_unlock_irqrestore (&rfp->rcu_fwd_lock, flags);break ; } - rcu_fwds.rcu_fwd_cb_head = rfcp->rfc_next; -if (!rcu_fwds.rcu_fwd_cb_head) - rcu_fwds.rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head; -spin_unlock_irqrestore (&rcu_fwds.rcu_fwd_lock, flags); + rfp->rcu_fwd_cb_head = rfcp->rfc_next; +if (!rfp->rcu_fwd_cb_head) + rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head; +spin_unlock_irqrestore (&rfp->rcu_fwd_lock, flags);kfree (rfcp); freed++;rcu_torture_fwd_prog_cond_resched (freed);
@@ -1926,7 +1926,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp) cver =READ_ONCE (rcu_torture_current_version) - cver; gps =rcutorture_seq_diff (cur_ops->get_gp_seq (), gps); cur_ops->cb_barrier ();/* Wait for callbacks to be invoked. */ - (void )rcu_torture_fwd_prog_cbfree (); + (void )rcu_torture_fwd_prog_cbfree (rfp);if (!torture_must_stop () && !READ_ONCE (rcu_fwd_emergency_stop) && !shutdown_time_arrived ()) {
@@ -1952,20 +1952,22 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp)static int rcutorture_oom_notify (struct notifier_block *self,unsigned long notused,void *nfreed) { +struct rcu_fwd *rfp = &rcu_fwds; +WARN (1 ,"%s invoked upon OOM during forward-progress testing.\n" , __func__); -rcu_torture_fwd_cb_hist (&rcu_fwds); -rcu_fwd_progress_check (1 + (jiffies -READ_ONCE (rcu_fwds.rcu_fwd_startat)) /2 ); +rcu_torture_fwd_cb_hist (rfp); +rcu_fwd_progress_check (1 + (jiffies -READ_ONCE (rfp->rcu_fwd_startat)) /2 );WRITE_ONCE (rcu_fwd_emergency_stop, true);smp_mb ();/* Emergency stop before free and wait to avoid hangs. */ pr_info ("%s: Freed %lu RCU callbacks.\n" , - __func__,rcu_torture_fwd_prog_cbfree ()); + __func__,rcu_torture_fwd_prog_cbfree (rfp));rcu_barrier ();pr_info ("%s: Freed %lu RCU callbacks.\n" , - __func__,rcu_torture_fwd_prog_cbfree ()); + __func__,rcu_torture_fwd_prog_cbfree (rfp));rcu_barrier ();pr_info ("%s: Freed %lu RCU callbacks.\n" , - __func__,rcu_torture_fwd_prog_cbfree ()); + __func__,rcu_torture_fwd_prog_cbfree (rfp));smp_mb ();/* Frees before return to avoid redoing OOM. */ (*(unsigned long *)nfreed)++;/* Forward progress CBs freed! */ pr_info ("%s returning after OOM processing.\n" , __func__);
@@ -2008,6 +2010,8 @@ static int rcu_torture_fwd_prog(void *args)/* If forward-progress checking is requested and feasible, spawn the thread. */ static int __init rcu_torture_fwd_prog_init (void ) { +struct rcu_fwd *rfp = &rcu_fwds; +if (!fwd_progress)return 0 ;/* Not requested, so don't do it. */ if (!cur_ops->stall_dur || cur_ops->stall_dur() <= 0 ||
@@ -2022,14 +2026,13 @@ static int __init rcu_torture_fwd_prog_init(void)WARN_ON (1 );/* Make sure rcutorture notices conflict. */ return 0 ; } -spin_lock_init (&rcu_fwds.rcu_fwd_lock); - rcu_fwds.rcu_fwd_cb_tail = &rcu_fwds.rcu_fwd_cb_head; +spin_lock_init (&rfp->rcu_fwd_lock); + rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;if (fwd_progress_holdoff <=0 ) fwd_progress_holdoff =1 ;if (fwd_progress_div <=0 ) fwd_progress_div =4 ; -return torture_create_kthread (rcu_torture_fwd_prog, - &rcu_fwds, fwd_prog_task); +return torture_create_kthread (rcu_torture_fwd_prog, rfp, fwd_prog_task); }/* Callback function for RCU barrier testing. */
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 10/12 rcutorture: Dynamically allocate rcu_fwds structure
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
This commit switches from static structure to dynamic allocation for rcu_fwds as another step towards providing multiple call_rcu() forward-progress kthreads.
--- kernel/rcu/rcutorture.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/rcu/rcutorture.c +8 -5
@@ -1686,7 +1686,7 @@ struct rcu_fwd {unsigned long rcu_launder_gp_seq_start; }; -struct rcu_fwd rcu_fwds; +struct rcu_fwd *rcu_fwds;bool rcu_fwd_emergency_stop;static void rcu_torture_fwd_cb_hist (struct rcu_fwd *rfp)
@@ -1952,7 +1952,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *rfp)static int rcutorture_oom_notify (struct notifier_block *self,unsigned long notused,void *nfreed) { -struct rcu_fwd *rfp = &rcu_fwds; +struct rcu_fwd *rfp = rcu_fwds;WARN (1 ,"%s invoked upon OOM during forward-progress testing.\n" , __func__);
@@ -2010,7 +2010,7 @@ static int rcu_torture_fwd_prog(void *args)/* If forward-progress checking is requested and feasible, spawn the thread. */ static int __init rcu_torture_fwd_prog_init (void ) { -struct rcu_fwd *rfp = &rcu_fwds; +struct rcu_fwd *rfp;if (!fwd_progress)return 0 ;/* Not requested, so don't do it. */
@@ -2026,12 +2026,15 @@ static int __init rcu_torture_fwd_prog_init(void)WARN_ON (1 );/* Make sure rcutorture notices conflict. */ return 0 ; } -spin_lock_init (&rfp->rcu_fwd_lock); - rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;if (fwd_progress_holdoff <=0 ) fwd_progress_holdoff =1 ;if (fwd_progress_div <=0 ) fwd_progress_div =4 ; + rfp =kzalloc (sizeof (*rfp),GFP_KERNEL ); +if (!rfp) +return -ENOMEM ; +spin_lock_init (&rfp->rcu_fwd_lock); + rfp->rcu_fwd_cb_tail = &rfp->rcu_fwd_cb_head;return torture_create_kthread (rcu_torture_fwd_prog, rfp, fwd_prog_task); }
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 11/12 torture: Allow "CFLIST" to specify default list of scenarios
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
On a large system, it can be convenient to tell rcutorture to run several instances of the default scenarios. Currently, this requires explicitly listing them, for example, "--configs '2*SRCU-N 2*SRCU-P...'". Although this works, it is rather inconvenient.
This commit therefore allows "CFLIST" to be specified to indicate the default list of scenarios called out in the relevant CFLIST file, for example, for RCU, tools/testing/selftests/rcutorture/configs/rcu/CFLIST. In addition, multipliers may be used to run multiple instances of all the scenarios. For example, on a 256-CPU system, "--configs '3*CFLIST'" would run three instances of each scenario concurrently with one CPU left over. Thus "--configs '3*CFLIST TINY01'" would exactly consume all 256 CPUs, which makes rcutorture's jitter feature more effective.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +13 -6
@@ -198,9 +198,10 @@ fi CONFIGFRAG=${KVM}/configs/${TORTURE_SUITE}; export CONFIGFRAG +defaultconfigs="`tr '\012' ' ' < $CONFIGFRAG/CFLIST`" if test -z "$configs" then - configs="`cat $CONFIGFRAG/CFLIST`" + configs=$defaultconfigs fi if test -z "$resdir"
@@ -209,7 +210,7 @@ then fi # Create a file of test-name/#cpus pairs, sorted by decreasing #cpus. -touch $T/cfgcpu +configs_derep= for CF in $configs do case $CF in
@@ -222,15 +223,21 @@ do CF1=$CF ;; esac + for ((cur_rep=0;cur_rep<$config_reps;cur_rep++)) + do + configs_derep="$configs_derep $CF1" + done +done +touch $T/cfgcpu +configs_derep="`echo $configs_derep | sed -e "s/\<CFLIST\>/$defaultconfigs/g"`" +for CF1 in $configs_derep +do if test -f "$CONFIGFRAG/$CF1" then cpu_count=`configNR_CPUS.sh $CONFIGFRAG/$CF1` cpu_count=`configfrag_boot_cpus "$TORTURE_BOOTARGS" "$CONFIGFRAG/$CF1" "$cpu_count"` cpu_count=`configfrag_boot_maxcpus "$TORTURE_BOOTARGS" "$CONFIGFRAG/$CF1" "$cpu_count"` - for ((cur_rep=0;cur_rep<$config_reps;cur_rep++)) - do - echo $CF1 $cpu_count >> $T/cfgcpu - done + echo $CF1 $cpu_count >> $T/cfgcpu else echo "The --configs file $CF1 does not exist, terminating." exit 1
Signature · 1 line
2.9.5
[email protected]
maintainerPATCH 12/12 torture: Hoist calls to lscpu to higher-level kvm.sh script
In reply to Paul E. McKenneyFrom: "Paul E. McKenney" <[email protected]>
On some kernels, concurrent calls to the lscpu command result in severe slowdowns. For example, on v4.16, a single lscpu invocation takes about two milliseconds, four concurrent invocations more than two seconds, and 16 concurrent invocations more than 20 seconds. Given that the only goal is to learn the number of CPUs, invoking lscpu but once suffices. This commit therefore invokes lscpu early in kvm.sh execution, setting the initial value of the TORTURE_ALLOTED_CPUS environment variable.
--- tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh | 7 +++---- tools/testing/selftests/rcutorture/bin/kvm.sh | 11 ++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh +3 -4
@@ -133,11 +133,10 @@ fi qemu_args="-enable-kvm -nographic $qemu_args" cpu_count=`configNR_CPUS.sh $resdir/ConfigFragment` cpu_count=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"` -vcpus=`identify_qemu_vcpus` -if test $cpu_count -gt $vcpus +if test "$cpu_count" -gt "$TORTURE_ALLOTED_CPUS" then - echo CPU count limited from $cpu_count to $vcpus | tee -a $resdir/Warnings - cpu_count=$vcpus + echo CPU count limited from $cpu_count to $TORTURE_ALLOTED_CPUS | tee -a $resdir/Warnings + cpu_count=$TORTURE_ALLOTED_CPUS fi qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
tools/testing/selftests/rcutorture/bin/kvm.sh +8 -3
@@ -24,7 +24,9 @@ dur=$((30*60)) dryrun="" KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM PATH=${KVM}/bin:$PATH; export PATH -TORTURE_ALLOTED_CPUS="" +. functions.sh + +TORTURE_ALLOTED_CPUS="`identify_qemu_vcpus`" TORTURE_DEFCONFIG=defconfig TORTURE_BOOT_IMAGE="" TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
@@ -40,8 +42,6 @@ cpus=0 ds=`date +%Y.%m.%d-%H:%M:%S` jitter="-1" -. functions.sh - usage () { echo "Usage: $scriptname optional arguments:" echo " --bootargs kernel-boot-arguments"
@@ -93,6 +93,11 @@ do checkarg --cpus "(number)" "$#" "$2" '^[0-9]*$' '^--' cpus=$2 TORTURE_ALLOTED_CPUS="$2" + max_cpus="`identify_qemu_vcpus`" + if test "$TORTURE_ALLOTED_CPUS" -gt "$max_cpus" + then + TORTURE_ALLOTED_CPUS=$max_cpus + fi shift ;; --datestamp)
Signature · 1 line
2.9.5