2 # SPDX-License-Identifier: GPL-2.0+
4 # Get an estimate of how CPU-hoggy to be.
8 # Copyright (C) IBM Corporation, 2013
10 # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
12 if test -n "$TORTURE_ALLOTED_CPUS"
14 echo $TORTURE_ALLOTED_CPUS
17 ncpus
=`grep '^processor' /proc/cpuinfo | wc -l`
18 if mpstat
-V > /dev
/null
2>&1
20 idlecpus
=`mpstat | tail -1 | \
21 awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'`
23 # No mpstat command, so use all available CPUs.
24 echo The mpstat
command is not available
, so greedily using all CPUs.
27 awk -v ncpus
=$ncpus -v idlecpus
=$idlecpus < /dev
/null
'
32 if (cpus2use < ncpus / 10)
33 cpus2use = ncpus / 10;
34 if (cpus2use == int(cpus2use))
35 cpus2use = int(cpus2use)
37 cpus2use = int(cpus2use) + 1