Skip to content

Commit

Permalink
Consistently use nproc for counting the CPUs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xypron authored and trini committed Jan 30, 2020
1 parent 0f97e92 commit 84f0415
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion board/hisilicon/hikey/build-tf.mak
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion test/fs/fs-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit 84f0415

Please sign in to comment.