Skip to contentSkip to conversation

Consistently use nproc for counting the CPUs

PATCH New Heinrich Schuchardt 2 participants 2 messages Jan 27, 2020 – Jan 31, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 board/hisilicon/hikey/build-tf.mak | 2 +-
 test/common.sh                     | 2 +-
 test/fs/fs-test.sh                 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
board/hisilicon/hikey/build-tf.mak +1 -1
index cebb34b61b..cde04827e8 100644
@@ -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)
test/common.sh +1 -1
index 702d1ed051..904d579b7b 100644
@@ -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}
test/fs/fs-test.sh +1 -1
index 721af71d44..b87748106c 100755
@@ -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}
 

--
2.24.1

#1 lore raw

PATCH 1/1 Consistently use nproc for counting the CPUs

Quoted 5 lines · Heinrich Schuchardt

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200130/abcf7385/attachment.sig>