public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86, cpuinfo remove cpu_data x86_model_id trailing whitespace
@ 2015-05-18 22:01 Prarit Bhargava
  2015-05-18 22:05 ` Prarit Bhargava
  0 siblings, 1 reply; 2+ messages in thread
From: Prarit Bhargava @ 2015-05-18 22:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prarit Bhargava, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, Andy Lutomirski, Borislav Petkov, Denys Vlasenko,
	Dave Hansen, Igor Mammedov, Fenghua Yu

When comparing 'model name' fields in /proc/cpuinfo it was noticed that
a simple test comparing the model name fields was failing.  After some
simple investigation it was noticed that, in fact, the model name fields
are different for each processor.  Processor 0's model name field had
white space 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 two different model name fields even though they should be the
same.

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 truncates the whitespace at the end of the x86_model_id field.

The x86_model_id field should be the same for the same processors.  This
patch removes traliing space on every processor's x86_model_id field to make
them consistent and maintains the correct output for print_cpu_info():

smpboot: CPU0: AMD Opteron(TM) Processor 6272 (fam: 15, model: 01, stepping: 02)

The x86_model_id field is correct and has no whitespace across all processors:

[thetango@prarit ~]# grep "^model name" /proc/cpuinfo | uniq -c | sed 's/\ /_/g'
_____64_model_name      :_AMD_Opteron(TM)_Processor_6272

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/x86/kernel/cpu/common.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a62cf04..fa771bb 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -443,6 +443,7 @@ static void get_model_name(struct cpuinfo_x86 *c)
 		while (q <= &c->x86_model_id[48])
 			*q++ = '\0';	/* Zero-pad the rest */
 	}
+	strim(c->x86_model_id);
 }
 
 void cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
@@ -1122,7 +1123,7 @@ void print_cpu_info(struct cpuinfo_x86 *c)
 		printk(KERN_CONT "%s ", vendor);
 
 	if (c->x86_model_id[0])
-		printk(KERN_CONT "%s", strim(c->x86_model_id));
+		printk(KERN_CONT "%s", c->x86_model_id);
 	else
 		printk(KERN_CONT "%d86", c->x86);
 
-- 
1.7.9.3


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

* Re: [PATCH] x86, cpuinfo remove cpu_data x86_model_id trailing whitespace
  2015-05-18 22:01 [PATCH] x86, cpuinfo remove cpu_data x86_model_id trailing whitespace Prarit Bhargava
@ 2015-05-18 22:05 ` Prarit Bhargava
  0 siblings, 0 replies; 2+ messages in thread
From: Prarit Bhargava @ 2015-05-18 22:05 UTC (permalink / raw)
  To: Prarit Bhargava
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Andy Lutomirski, Borislav Petkov, Denys Vlasenko, Dave Hansen,
	Igor Mammedov, Fenghua Yu



On 05/18/2015 06:01 PM, Prarit Bhargava wrote:
> When comparing 'model name' fields in /proc/cpuinfo it was noticed that
> a simple test comparing the model name fields was failing.  After some
> simple investigation it was noticed that, in fact, the model name fields
> are different for each processor.  Processor 0's model name field had
> white space 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 two different model name fields even though they should be the
> same.
> 
> 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 truncates the whitespace at the end of the x86_model_id field.
> 
> The x86_model_id field should be the same for the same processors.  This
> patch removes traliing space on every processor's x86_model_id field to make
> them consistent and maintains the correct output for print_cpu_info():
> 
> smpboot: CPU0: AMD Opteron(TM) Processor 6272 (fam: 15, model: 01, stepping: 02)
> 
> The x86_model_id field is correct and has no whitespace across all processors:
> 
> [thetango@prarit ~]# grep "^model name" /proc/cpuinfo | uniq -c | sed 's/\ /_/g'
> _____64_model_name      :_AMD_Opteron(TM)_Processor_6272
> 

Nack this ... hpa has suggested that I backwards search from the 48th character
for the first non-null ... I'll put together a new patch.

P.

> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Denys Vlasenko <dvlasenk@redhat.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Fenghua Yu <fenghua.yu@intel.com>
> ---
>  arch/x86/kernel/cpu/common.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index a62cf04..fa771bb 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -443,6 +443,7 @@ static void get_model_name(struct cpuinfo_x86 *c)
>  		while (q <= &c->x86_model_id[48])
>  			*q++ = '\0';	/* Zero-pad the rest */
>  	}
> +	strim(c->x86_model_id);
>  }
>  
>  void cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
> @@ -1122,7 +1123,7 @@ void print_cpu_info(struct cpuinfo_x86 *c)
>  		printk(KERN_CONT "%s ", vendor);
>  
>  	if (c->x86_model_id[0])
> -		printk(KERN_CONT "%s", strim(c->x86_model_id));
> +		printk(KERN_CONT "%s", c->x86_model_id);
>  	else
>  		printk(KERN_CONT "%d86", c->x86);
>  
> 

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

end of thread, other threads:[~2015-05-18 22:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18 22:01 [PATCH] x86, cpuinfo remove cpu_data x86_model_id trailing whitespace Prarit Bhargava
2015-05-18 22:05 ` Prarit Bhargava

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