* [PATCH] Consistently use nproc for counting the CPUs
@ 2020-01-27 6:59 Heinrich Schuchardt
2020-01-31 1:41 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2020-01-27 6:59 UTC (permalink / raw)
To: u-boot
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 <xypron.glpk@gmx.de>
---
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 cebb34b61b..cde04827e8 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 702d1ed051..904d579b7b 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 721af71d44..b87748106c 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}
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] Consistently use nproc for counting the CPUs
2020-01-27 6:59 [PATCH] Consistently use nproc for counting the CPUs Heinrich Schuchardt
@ 2020-01-31 1:41 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-01-31 1:41 UTC (permalink / raw)
To: u-boot
On Mon, Jan 27, 2020 at 07:59:46AM +0100, Heinrich Schuchardt wrote:
> 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 <xypron.glpk@gmx.de>
Applied to u-boot/master, thanks!
--
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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-31 1:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-27 6:59 [PATCH] Consistently use nproc for counting the CPUs Heinrich Schuchardt
2020-01-31 1:41 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.