Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbWAWLWP (ORCPT ); Mon, 23 Jan 2006 06:22:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751418AbWAWLWP (ORCPT ); Mon, 23 Jan 2006 06:22:15 -0500 Received: from calsoftinc.com ([64.62.215.98]:27526 "HELO calsoftinc.com") by vger.kernel.org with SMTP id S1751417AbWAWLWP (ORCPT ); Mon, 23 Jan 2006 06:22:15 -0500 Date: Mon, 23 Jan 2006 16:51:34 +0530 (IST) From: pravin shelar X-X-Sender: pravins@pravin.s To: Andi Kleen cc: Ravikiran G Thirumalai , Shai Fultheim , linux-kernel@vger.kernel.org, "David S. Miller" Subject: [PATCH] garbage values in file /proc/net/sockstat Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2534 Lines: 67 In 2.6.16-rc1-mm1, (for x86_64 arch) cpu_possible_map is not same as NR_CPUS (prefill_possible_map()). Therefore per cpu areas are allocated for cpu_possible cpus only (setup_per_cpu_areas()). This causes sockstat to return garbage value on x84_64 arch. So these per_cpu accesses are geting relocated (RELOC_HIDE) using boot_cpu_pda[]->data_offset which is not initialized. There are other instances of same bug where per_cpu() macro is used without cpu_possible() check. e.g. net/core/utils.c :: net_random_reseed(), net/core/dev.c :: net_dev_init(), etc. This patch fixes these bugs. Regards, Pravin. --- Signed-off by: Pravin B. Shelar Signed-off-by: Ravikiran Thirumalai Signed-off-by: Shai Fultheim Index: linux-2.6.15.1/net/core/dev.c =================================================================== --- linux-2.6.15.1.orig/net/core/dev.c 2006-01-23 02:31:13.000000000 -0800 +++ linux-2.6.15.1/net/core/dev.c 2006-01-23 02:32:12.000000000 -0800 @@ -3240,7 +3240,7 @@ static int __init net_dev_init(void) * Initialise the packet receive queues. */ - for (i = 0; i < NR_CPUS; i++) { + for_each_cpu (i) { struct softnet_data *queue; queue = &per_cpu(softnet_data, i); Index: linux-2.6.15.1/net/core/utils.c =================================================================== --- linux-2.6.15.1.orig/net/core/utils.c 2006-01-23 02:31:13.000000000 -0800 +++ linux-2.6.15.1/net/core/utils.c 2006-01-23 02:32:12.000000000 -0800 @@ -133,7 +133,7 @@ static int net_random_reseed(void) unsigned long seed[NR_CPUS]; get_random_bytes(seed, sizeof(seed)); - for (i = 0; i < NR_CPUS; i++) { + for_each_cpu(i) { struct nrnd_state *state = &per_cpu(net_rand_state,i); __net_srandom(state, seed[i]); } Index: linux-2.6.15.1/net/socket.c =================================================================== --- linux-2.6.15.1.orig/net/socket.c 2006-01-23 02:31:13.000000000 -0800 +++ linux-2.6.15.1/net/socket.c 2006-01-23 02:32:12.000000000 -0800 @@ -2079,7 +2079,7 @@ void socket_seq_show(struct seq_file *se int cpu; int counter = 0; - for (cpu = 0; cpu < NR_CPUS; cpu++) + for_each_cpu (cpu) counter += per_cpu(sockets_in_use, cpu); /* It can be negative, by the way. 8) */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/