aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrarit Bhargava <prarit@redhat.com>2015-05-26 04:28:17 -0400
committerIngo Molnar <mingo@kernel.org>2015-05-27 08:38:24 -0400
commitadafb98da6a7af5e45362933a7dae6ab0e5076bf (patch)
tree3b1b72516f4e0c5353e774cac9cbe1fbd5e5d839
parentb9d16a2a21aa9c264a29dd84d6f7b03581517a03 (diff)
x86/cpu: Strip any /proc/cpuinfo model name field whitespace
When comparing the 'model name' field of each core in /proc/cpuinfo it was noticed that there is a whitespace difference between the cores' model names. After some quick investigation it was noticed that the model name fields were actually different -- processor 0's model name field had trailing whitespace removed, while the other processors did not. Another way of seeing this behaviour is to convert spaces into underscores in the output of /proc/cpuinfo, [thetango@prarit ~]# grep "^model name" /proc/cpuinfo | uniq -c | sed 's/\ /_/g' ______1_model_name :_AMD_Opteron(TM)_Processor_6272 _____63_model_name :_AMD_Opteron(TM)_Processor_6272_________________ which shows the discrepancy. This occurs because the kernel calls strim() on cpu 0's x86_model_id field to output a pretty message to the console in print_cpu_info(), and as a result strips the whitespace at the end of the ->x86_model_id field. But, the ->x86_model_id field should be the same for the all identical CPUs in the box. Thus, we need to remove both leading and trailing whitespace. As a result, the print_cpu_info() output looks like smpboot: CPU0: AMD Opteron(TM) Processor 6272 (fam: 15, model: 01, stepping: 02) and the x86_model_id field is correct on all processors on AMD platforms: _____64_model_name :_AMD_Opteron(TM)_Processor_6272 Output is still correct on an Intel box: ____144_model_name :_Intel(R)_Xeon(R)_CPU_E7-8890_v3_@_2.50GHz Signed-off-by: Prarit Bhargava <prarit@redhat.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1432050210-32036-1-git-send-email-prarit@redhat.com Link: http://lkml.kernel.org/r/1432628901-18044-15-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/cpu/common.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a62cf04dac8a..41a8e9cb30bc 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -419,7 +419,6 @@ static const struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
419static void get_model_name(struct cpuinfo_x86 *c) 419static void get_model_name(struct cpuinfo_x86 *c)
420{ 420{
421 unsigned int *v; 421 unsigned int *v;
422 char *p, *q;
423 422
424 if (c->extended_cpuid_level < 0x80000004) 423 if (c->extended_cpuid_level < 0x80000004)
425 return; 424 return;
@@ -431,18 +430,10 @@ static void get_model_name(struct cpuinfo_x86 *c)
431 c->x86_model_id[48] = 0; 430 c->x86_model_id[48] = 0;
432 431
433 /* 432 /*
434 * Intel chips right-justify this string for some dumb reason; 433 * Remove leading whitespace on Intel processors and trailing
435 * undo that brain damage: 434 * whitespace on AMD processors.
436 */ 435 */
437 p = q = &c->x86_model_id[0]; 436 memmove(c->x86_model_id, strim(c->x86_model_id), 48);
438 while (*p == ' ')
439 p++;
440 if (p != q) {
441 while (*p)
442 *q++ = *p++;
443 while (q <= &c->x86_model_id[48])
444 *q++ = '\0'; /* Zero-pad the rest */
445 }
446} 437}
447 438
448void cpu_detect_cache_sizes(struct cpuinfo_x86 *c) 439void cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
@@ -1122,7 +1113,7 @@ void print_cpu_info(struct cpuinfo_x86 *c)
1122 printk(KERN_CONT "%s ", vendor); 1113 printk(KERN_CONT "%s ", vendor);
1123 1114
1124 if (c->x86_model_id[0]) 1115 if (c->x86_model_id[0])
1125 printk(KERN_CONT "%s", strim(c->x86_model_id)); 1116 printk(KERN_CONT "%s", c->x86_model_id);
1126 else 1117 else
1127 printk(KERN_CONT "%d86", c->x86); 1118 printk(KERN_CONT "%d86", c->x86);
1128 1119