mirror of
https://github.com/brain-hackers/linux-brain.git
synced 2024-06-09 23:36:23 +09:00
7225c07772
Currently, rcutorture will use relatively few CPUs to build the kernel on a busy system, which is often as it should be. However, if the user has used the --cpus argument to dedicate a specified number of CPUs to this torture test, it would be good if the kernel build also made use of them. This commit therefore changes the cpus2use.sh script to use --cpus when specified and to do the idleness calculations otherwise. Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
34 lines
718 B
Bash
Executable File
34 lines
718 B
Bash
Executable File
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0+
|
|
#
|
|
# Get an estimate of how CPU-hoggy to be.
|
|
#
|
|
# Usage: cpus2use.sh
|
|
#
|
|
# Copyright (C) IBM Corporation, 2013
|
|
#
|
|
# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
|
|
|
|
if test -n "$TORTURE_ALLOTED_CPUS"
|
|
then
|
|
echo $TORTURE_ALLOTED_CPUS
|
|
exit 0
|
|
fi
|
|
ncpus=`grep '^processor' /proc/cpuinfo | wc -l`
|
|
idlecpus=`mpstat | tail -1 | \
|
|
awk -v ncpus=$ncpus '{ print ncpus * ($7 + $NF) / 100 }'`
|
|
awk -v ncpus=$ncpus -v idlecpus=$idlecpus < /dev/null '
|
|
BEGIN {
|
|
cpus2use = idlecpus;
|
|
if (cpus2use < 1)
|
|
cpus2use = 1;
|
|
if (cpus2use < ncpus / 10)
|
|
cpus2use = ncpus / 10;
|
|
if (cpus2use == int(cpus2use))
|
|
cpus2use = int(cpus2use)
|
|
else
|
|
cpus2use = int(cpus2use) + 1
|
|
print cpus2use;
|
|
}'
|
|
|