The current way of getting the number of cpus uses different assumptions which may or may not be true in the future: * /proc/cpuinfo exists * cpuinfo provides a list of all processing units * all processing units are available for the current process and its childs * the word 'processor' is only used in the cpu index and 'model name' lines * cpu index is strict monotonic increasing * lowest cpu index is 0 and highest cpu index is n-1 (n is the number of processing units)
At least the number of available processing units for the current process can be shown to be wrong. on current systems by assigning a singe cpu to a process and its childs:
$ numactl --physcpubind=0 nproc 1
$ numactl --physcpubind=0 sh -c 'NUM_CPUS=`cat /proc/cpuinfo | grep -v "model name" | grep processor | tail -1 | awk -F" " '''{print $$3}'''`;echo `expr $NUM_CPUS + 1`' 4
nproc is part of coreutils since version 8.1. On systems without nproc it will just assume that a single processing unit is available.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batman-adv/Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/batman-adv/Makefile b/batman-adv/Makefile index 4f6a460..adfbbc9 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -41,7 +41,7 @@ REVISION= $(shell if [ -d .svn ]; then \ fi; \ fi)
-NUM_CPUS = $(shell NUM_CPUS=`cat /proc/cpuinfo | grep -v 'model name' | grep processor | tail -1 | awk -F' ' '{print $$3}'`;echo `expr $$NUM_CPUS + 1`) +NUM_CPUS = $(shell nproc 2> /dev/null || echo 1)
include $(PWD)/Makefile.kbuild
The current way of getting the number of cpus uses different assumptions which may or may not be true in the future: * /proc/cpuinfo exists * cpuinfo provides a list of all processing units * all processing units are available for the current process and its childs * the word 'processor' is only used in the cpu index and 'model name' lines * cpu index is strict monotonic increasing * lowest cpu index is 0 and highest cpu index is n-1 (n is the number of processing units)
At least the number of available processing units for the current process can be shown to be wrong. on current systems by assigning a singe cpu to a process and its childs:
$ numactl --physcpubind=0 nproc 1
$ numactl --physcpubind=0 sh -c 'NUM_CPUS=`cat /proc/cpuinfo | grep -v "model name" | grep processor | tail -1 | awk -F" " '''{print $$3}'''`;echo `expr $NUM_CPUS + 1`' 4
nproc is part of coreutils since version 8.1. On systems without nproc it will just assume that a single processing unit is available.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batctl/Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/batctl/Makefile b/batctl/Makefile index ab9c075..ef80d3c 100644 --- a/batctl/Makefile +++ b/batctl/Makefile @@ -67,7 +67,7 @@ REVISION_VERSION ="\ rv$(REVISION)"
BAT_VERSION = $(shell grep "^#define SOURCE_VERSION " $(SOURCE_VERSION_HEADER) | sed -e '1p' -n | awk -F '"' '{print $$2}' | awk '{print $$1}') FILE_NAME = $(PACKAGE_NAME)_$(BAT_VERSION)-rv$(REVISION)_$@ -NUM_CPUS = $(shell NUM_CPUS=`cat /proc/cpuinfo | grep -v 'model name' | grep processor | tail -1 | awk -F' ' '{print $$3}'`;echo `expr $$NUM_CPUS + 1`) +NUM_CPUS = $(shell nproc 2> /dev/null || echo 1)
all:
The current way of getting the number of cpus uses different assumptions which may or may not be true in the future: * /proc/cpuinfo exists * cpuinfo provides a list of all processing units * all processing units are available for the current process and its childs * the word 'processor' is only used in the cpu index and 'model name' lines * cpu index is strict monotonic increasing * lowest cpu index is 0 and highest cpu index is n-1 (n is the number of processing units)
At least the number of available processing units for the current process can be shown to be wrong. on current systems by assigning a singe cpu to a process and its childs:
$ numactl --physcpubind=0 nproc 1
$ numactl --physcpubind=0 sh -c 'NUM_CPUS=`cat /proc/cpuinfo | grep -v "model name" | grep processor | tail -1 | awk -F" " '''{print $$3}'''`;echo `expr $NUM_CPUS + 1`' 4
nproc is part of coreutils since version 8.1. On systems without nproc it will just assume that a single processing unit is available.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batman/Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/batman/Makefile b/batman/Makefile index 8eafb26..fdf8232 100644 --- a/batman/Makefile +++ b/batman/Makefile @@ -77,7 +77,7 @@ REVISION_VERSION ="\ rv$(REVISION)"
BAT_VERSION = $(shell grep "^#define SOURCE_VERSION " $(SOURCE_VERSION_HEADER) | sed -e '1p' -n | awk -F '"' '{print $$2}' | awk '{print $$1}') FILE_NAME = $(PACKAGE_NAME)_$(BAT_VERSION)-rv$(REVISION)_$@ -NUM_CPUS = $(shell NUM_CPUS=`cat /proc/cpuinfo | grep -v 'model name' | grep processor | tail -1 | awk -F' ' '{print $$3}'`;echo `expr $$NUM_CPUS + 1`) +NUM_CPUS = $(shell nproc 2> /dev/null || echo 1)
all:
The current way of getting the number of cpus uses different assumptions which may or may not be true in the future: * /proc/cpuinfo exists * cpuinfo provides a list of all processing units * all processing units are available for the current process and its childs * the word 'processor' is only used in the cpu index and 'model name' lines * cpu index is strict monotonic increasing * lowest cpu index is 0 and highest cpu index is n-1 (n is the number of processing units)
At least the number of available processing units for the current process can be shown to be wrong. on current systems by assigning a singe cpu to a process and its childs:
$ numactl --physcpubind=0 nproc 1
$ numactl --physcpubind=0 sh -c 'NUM_CPUS=`cat /proc/cpuinfo | grep -v "model name" | grep processor | tail -1 | awk -F" " '''{print $$3}'''`;echo `expr $NUM_CPUS + 1`' 4
nproc is part of coreutils since version 8.1. On systems without nproc it will just assume that a single processing unit is available.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- vis/Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/vis/Makefile b/vis/Makefile index 675dcd8..a119758 100644 --- a/vis/Makefile +++ b/vis/Makefile @@ -49,7 +49,7 @@ REVISION_VERSION="\ rv$(REVISION)"
VIS_VERSION= $(shell grep "^#define SOURCE_VERSION " $(SOURCE_VERSION_HEADER) | sed -e '1p' -n | awk -F '"' '{print $$2}' | awk '{print $$1}') FILE_NAME= $(PACKAGE_NAME)_$(VIS_VERSION)-rv$(REVISION)_$@ -NUM_CPUS = $(shell NUM_CPUS=`cat /proc/cpuinfo | grep -v 'model name' | grep processor | tail -1 | awk -F' ' '{print $$3}'`;echo `expr $$NUM_CPUS + 1`) +NUM_CPUS = $(shell nproc 2> /dev/null || echo 1)
all:
On Wednesday 23 June 2010 14:12:56 Sven Eckelmann wrote:
nproc is part of coreutils since version 8.1. On systems without nproc it will just assume that a single processing unit is available.
Ok, I applied the batman-adv and batctl patch in revision 1719 & 1720. However, the other patches I'd rather not commit because these branches are unmaintained. As soon as a maintainer shows up they can go in.
Cheers, Marek
b.a.t.m.a.n@lists.open-mesh.org