From patchwork Thu Dec 4 20:51:58 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12314 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 04A98DDEE2 for ; Fri, 5 Dec 2008 07:52:47 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from mout-bounce.kundenserver.de (mout-bounce.kundenserver.de [212.227.17.2]) by ozlabs.org (Postfix) with ESMTP id 6D6F3DDE0F for ; Fri, 5 Dec 2008 07:52:07 +1100 (EST) Received: from noname (port-92-200-38-116.dynamic.qsc.de [92.200.38.116]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1L8LB22MJs-0000ps; Thu, 04 Dec 2008 21:52:01 +0100 From: Arnd Bergmann To: Lee Schermerhorn Subject: [PATCH, v2] numactl: fix libnuma on big-endian 64-bit systems Date: Thu, 4 Dec 2008 21:51:58 +0100 User-Agent: KMail/1.9.9 References: <200812041834.45931.arnd@arndb.de> <1228412816.6959.48.camel@lts-notebook> <200812042149.06163.arnd@arndb.de> In-Reply-To: <200812042149.06163.arnd@arndb.de> X-Face: I@=L^?./?$U, EK.)V[4*>`zSqm0>65YtkOe>TFD'!aw?7OVv#~5xd\s, [~w]-J!)|%=]>=?utf-8?q?+=0A=09=7EohchhkRGW=3F=7C6=5FqTmkd=5Ft=3FLZC=23Q-=60=2E=60Y=2Ea=5E?= =?utf-8?q?3zb?=) =?utf-8?q?+U-JVN=5DWT=25cw=23=5BYo0=267C=26bL12wWGlZi=0A=09=7EJ=3B=5Cwg?= =?utf-8?q?=3B3zRnz?=, J"CT_)=\H'1/{?SR7GDu?WIopm.HaBG=QYj"NZD_[zrM\Gip^U MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200812042151.58676.arnd@arndb.de> X-Provags-ID: V01U2FsdGVkX1/vhjShWDvo9pqxBW1wKEIMvzKuBJ1wAyIiTX2 xGOd7HE1ap8hZlZIHHpxev2yqPbCIdRnF0uLOMhv4atb2i4yJi 7K4lGXrKF/2foDokKygDg== Cc: linuxppc-dev@ozlabs.org, Mijo Safradin , Cliff Wickman , Christoph Lameter X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org The read-mask function assumes that it is running in 32-bit mode, by addressing the bitmask as a series of int values, instead of longs. This is broken as can easily be reproduced by running numademo on a bit-endian 64-bit system. Changing the addressing to use 'long' values fixes the problem. Reported-by: Mijo Safradin Signed-off-by: Arnd Bergmann --- libnuma.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libnuma.c b/libnuma.c index 4d26093..9a9fbbe 100755 --- a/libnuma.c +++ b/libnuma.c @@ -376,9 +376,9 @@ read_mask(char *s, struct bitmask *bmp) { char *end = s; char *prevend; - unsigned int *start = (unsigned int *)bmp->maskp; - unsigned int *p = start; - unsigned int *q; + unsigned long *start = bmp->maskp; + unsigned long *p = start; + unsigned long *q; unsigned int i; unsigned int n = 0; @@ -415,14 +415,14 @@ read_mask(char *s, struct bitmask *bmp) } /* Poor mans fls() */ - for(i = 31; i >= 0; i--) + for(i = sizeof(long) * 8 - 1; i >= 0; i--) if (test_bit(i, start + n)) break; /* * Return the last bit set */ - return ((sizeof(unsigned int)*8) * n) + i; + return ((sizeof(unsigned long)*8) * n) + i; } /*