From: "Amit K. Arora" Subject: [PATCH 1/2] handle NUMA distances properly for non-contiguous nodes Date: Mon, 2 Mar 2009 18:49:12 +0530 Message-ID: <20090302131912.GA32416@amitarora.in.ibm.com> References: <20090302130546.GA31167@amitarora.in.ibm.com> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <20090302130546.GA31167@amitarora.in.ibm.com> Sender: linux-numa-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-numa@vger.kernel.org Cc: aarora@linux.vnet.ibm.com Patch: numactl-handle-NUMA-dist-properly.patch This patch fixes the problem of displaying incorrect NUMA distances. It increases the table size to accomodate node distance information for nodes from 0 to nodemax. parse_numbers() makes sure not to add distances for nodes which are not existing. Signed-off-by: Amit K Arora diff -Nuarp numactl-2.0.2.ORG/distance.c numactl-2.0.2/distance.c --- numactl-2.0.2.ORG/distance.c 2009-03-02 02:34:12.000000000 -0600 +++ numactl-2.0.2/distance.c 2009-03-02 05:29:48.000000000 -0600 @@ -26,25 +26,16 @@ static int distance_numnodes; static int *distance_table; -static int count_numbers(char *s) -{ - int n = 0; - for (;;) { - char *end; - strtoul(s, &end, 0); - if (s == end) - return n; - s = end; - n++; - } -} - static void parse_numbers(char *s, int *iptr, int n) { - int i; + int i, d, j; char *end; - for (i = 0; i < n; i++) { - *iptr++ = strtoul(s, &end, 0); + for (i = 0, j = 0; i < n; i++, j++) { + d = strtoul(s, &end, 0); + /* Skip unavailable nodes */ + while (j 0) err = 0; - break; + if (!err && nd