Skip to content

Commit b8dfff9

Browse files
committed
torture: Handle systems lacking the mpstat command
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. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 517f17a commit b8dfff9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ then
1515
exit 0
1616
fi
1717
ncpus=`grep '^processor' /proc/cpuinfo | wc -l`
18-
idlecpus=`mpstat | tail -1 | \
19-
awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'`
18+
if mpstat -V > /dev/null 2>&1
19+
then
20+
idlecpus=`mpstat | tail -1 | \
21+
awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'`
22+
else
23+
# No mpstat command, so use all available CPUs.
24+
echo The mpstat command is not available, so greedily using all CPUs.
25+
idlecpus=$ncpus
26+
fi
2027
awk -v ncpus=$ncpus -v idlecpus=$idlecpus < /dev/null '
2128
BEGIN {
2229
cpus2use = idlecpus;

0 commit comments

Comments
 (0)