From 84f0415201e57e1919a2c91684e64bdedd85d159 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 27 Jan 2020 07:59:46 +0100 Subject: [PATCH] Consistently use nproc for counting the CPUs Coreutils command nproc can be used on Linux and BSD to count the number of available CPU cores. Use this instead of relying on the parsing of the Linux specific proc file system. Signed-off-by: Heinrich Schuchardt --- board/hisilicon/hikey/build-tf.mak | 2 +- test/common.sh | 2 +- test/fs/fs-test.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/board/hisilicon/hikey/build-tf.mak b/board/hisilicon/hikey/build-tf.mak index cebb34b61bdf..cde04827e8ea 100644 --- a/board/hisilicon/hikey/build-tf.mak +++ b/board/hisilicon/hikey/build-tf.mak @@ -1,6 +1,6 @@ CROSS_COMPILE := aarch64-linux-gnu- output_dir := $(PWD)/../bin -makejobs := $(shell grep '^processor' /proc/cpuinfo | sort -u | wc -l) +makejobs := $(nproc) makethreads := $(shell dc -e "$(makejobs) 1 + p") make_options := GCC49_AARCH64_PREFIX=$CROSS_COMPILE \ -j$(makethreads) -l$(makejobs) diff --git a/test/common.sh b/test/common.sh index 702d1ed0513f..904d579b7bfe 100644 --- a/test/common.sh +++ b/test/common.sh @@ -13,7 +13,7 @@ fail() { build_uboot() { echo "Build sandbox" OPTS="O=${OUTPUT_DIR} $1" - NUM_CPUS=$(grep -c processor /proc/cpuinfo) + NUM_CPUS=$(nproc) echo ${OPTS} make ${OPTS} sandbox_config make ${OPTS} -s -j${NUM_CPUS} diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh index 721af71d44ca..b87748106c7a 100755 --- a/test/fs/fs-test.sh +++ b/test/fs/fs-test.sh @@ -87,7 +87,7 @@ function check_clean() { # Generate sandbox U-Boot - gleaned from /test/dm/test-dm.sh function compile_sandbox() { unset CROSS_COMPILE - NUM_CPUS=$(cat /proc/cpuinfo |grep -c processor) + NUM_CPUS=$(nproc) make O=sandbox sandbox_config make O=sandbox -s -j${NUM_CPUS}