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 ncpus=`grep '^processor' /proc/cpuinfo | wc -l`
13 idlecpus=`mpstat | tail -1 | \
14 awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'`
15 awk -v ncpus=$ncpus -v idlecpus=$idlecpus < /dev/null '
20 if (cpus2use < ncpus / 10)
21 cpus2use = ncpus / 10;
22 if (cpus2use == int(cpus2use))
23 cpus2use = int(cpus2use)
25 cpus2use = int(cpus2use) + 1