public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] garbage values in file /proc/net/sockstat
@ 2006-01-23 11:21 pravin shelar
  2006-01-23 11:24 ` Andi Kleen
  0 siblings, 1 reply; 13+ messages in thread
From: pravin shelar @ 2006-01-23 11:21 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Ravikiran G Thirumalai, Shai Fultheim, linux-kernel,
	David S. Miller

	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 <pravins@calsoftinc.com>
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>

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) */

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-01-26 10:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-23 11:21 [PATCH] garbage values in file /proc/net/sockstat pravin shelar
2006-01-23 11:24 ` Andi Kleen
2006-01-23 13:28   ` Eric Dumazet
2006-01-23 15:11     ` Andi Kleen
2006-01-23 16:28       ` Eric Dumazet
2006-01-23 16:46         ` Eric Dumazet
2006-01-25 13:31           ` Andi Kleen
2006-01-25 19:59             ` Ravikiran G Thirumalai
2006-01-25 20:47               ` Ravikiran G Thirumalai
2006-01-26  0:32               ` Andi Kleen
2006-01-25 21:45     ` Red zones (was: [PATCH] garbage values in file /proc/net/sockstat) Bernd Eckenfels
2006-01-26  5:28       ` Red zones Eric Dumazet
2006-01-26 10:07         ` Bernd Eckenfels

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox