Skip to contentSkip to conversation

fix wrong proc cpuinfo on x64

Patch2/2 Zou Nan hai 2 participants 2 messages Nov 6, 2007 x86

lore
Share & tools
lore
#0 lore raw

in 2.6.24-rc1 kernel,
The /proc/cpuinfo display is wrong.

Another issue is that it will display bogus cpus with wrong information if the kernel is compiled with a big CONFIG_NR_CPU.

That is because before a cpu in cpu_present_map is up, c->cpu_index of that cpu is 0.
thus the cpu_online(c->cpu_index) check in show_cpuinfo is invalid.

This patch will let cpuinfo_op use cpu_online_map instead of cpu_present_map to iterate cpus.

arch/x86/kernel/setup_64.c +3 -5
@@ -1078,8 +1078,6 @@ static int show_cpuinfo(struct seq_file 
 
 
 #ifdef CONFIG_SMP
-	if (!cpu_online(c->cpu_index))
-		return 0;
 	cpu = c->cpu_index;
 #endif
 
@@ -1171,15 +1169,15 @@ static int show_cpuinfo(struct seq_file 
 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_possible_map);
-	if ((*pos) < NR_CPUS && cpu_possible(*pos))
+		*pos = first_cpu(cpu_online_map);
+	if ((*pos) < NR_CPUS && cpu_online(*pos))
 		return &cpu_data(*pos);
 	return NULL;
 }
 
 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
 {
-	*pos = next_cpu(*pos, cpu_possible_map);
+	*pos = next_cpu(*pos, cpu_online_map);
 	return c_start(m, pos);
 }
 
#1 lore raw
Quoted 9 lines · Zou Nan hai

in 2.6.24-rc1 kernel,
The /proc/cpuinfo display is wrong.

Another issue is that it will display bogus cpus with wrong information if the kernel is compiled with a big CONFIG_NR_CPU.

That is because before a cpu in cpu_present_map is up, c->cpu_index of that cpu is 0.
thus the cpu_online(c->cpu_index) check in show_cpuinfo is invalid.

This issue should already be fixed with that patch

http://marc.info/?l=linux-kernel&m=119394201230954

Quoted 2 lines

This patch will let cpuinfo_op use cpu_online_map instead of cpu_present_map to iterate cpus.

BTW, the problem affects i386 as well.

Regards,

Andreas

Signature · 5 lines
Operating | AMD Saxony Limited Liability Company & Co. KG,
  System  | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 Research | Register Court Dresden: HRA 4896, General Partner authorized
  Center  | to represent: AMD Saxony LLC (Wilmington, Delaware, US)
  (OSRC)  | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy