From patchwork Wed Jun 23 12:12:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 267 Return-Path: Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by open-mesh.net (Postfix) with SMTP id 48617154475 for ; Wed, 23 Jun 2010 14:13:39 +0200 (CEST) Received: (qmail invoked by alias); 23 Jun 2010 12:13:38 -0000 Received: from unknown (EHLO sven-desktop.lazhur.ath.cx) [89.246.204.65] by mail.gmx.net (mp029) with SMTP; 23 Jun 2010 14:13:38 +0200 X-Authenticated: #15668376 X-Provags-ID: V01U2FsdGVkX1+fYCovefKfuLYTtgCdnBES8x70nN1/5MMTeJoOmc zKAx9PvAsB1syr From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 23 Jun 2010 14:12:59 +0200 Message-Id: <1277295179-30503-4-git-send-email-sven.eckelmann@gmx.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1277295179-30503-1-git-send-email-sven.eckelmann@gmx.de> References: <1277295179-30503-1-git-send-email-sven.eckelmann@gmx.de> X-Y-GMX-Trusted: 0 Subject: [B.A.T.M.A.N.] [PATCH 4/4] vis: Use nproc to get number of available processors X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2010 12:13:39 -0000 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 --- 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: