public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/proc: fix /proc/cpuinfo cpu offline bug
@ 2008-10-17  8:55 Lai Jiangshan
  2008-10-17 11:41 ` Alexey Dobriyan
  0 siblings, 1 reply; 5+ messages in thread
From: Lai Jiangshan @ 2008-10-17  8:55 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel Mailing List


In my test, I found that if a cpu has been offline,
the next cpus may not be shown in the /proc/cpuinfo.

trivially reproduce this bug:

1) add these lines in the end of show_cpuinfo()
	if (m->size - m->count - 20 > 0)
		seq_printf(m, "%*s", (int)(m->size - m->count - 20), "show bug\n");

2) rebuilt kernel & reboot
3) offline cpu#1
4) cat /proc/cpuinfo
   cpu#2 and cpu#3 .... cannot be shown in /proc/cpuinfo

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index a26c480..01b1244 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -160,14 +160,16 @@ static void *c_start(struct seq_file *m, loff_t *pos)
 {
 	if (*pos == 0)	/* just in case, cpu 0 is not the first */
 		*pos = first_cpu(cpu_online_map);
-	if ((*pos) < nr_cpu_ids && cpu_online(*pos))
+	else
+		*pos = next_cpu_nr(*pos - 1, cpu_online_map);
+	if ((*pos) < nr_cpu_ids)
 		return &cpu_data(*pos);
 	return NULL;
 }
 
 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
 {
-	*pos = next_cpu(*pos, cpu_online_map);
+	(*pos)++;
 	return c_start(m, pos);
 }
 




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

end of thread, other threads:[~2008-10-22  4:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-17  8:55 [PATCH] x86/proc: fix /proc/cpuinfo cpu offline bug Lai Jiangshan
2008-10-17 11:41 ` Alexey Dobriyan
2008-10-17 12:44   ` Lai Jiangshan
2008-10-22  4:39     ` Lai Jiangshan
2008-10-22  4:42       ` Lai Jiangshan

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