[PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller

Andrew Cooper posted 16 patches 1 week, 4 days ago
[PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller
Posted by Andrew Cooper 1 week, 4 days ago
This makes the correctness of future changes more obvious.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Julian Vetter <julian.vetter@vates.tech>
CC: Teddy Astie <teddy.astie@vates.tech>
---
 xen/arch/x86/cpu/common.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index dda0d5d39c92..89b58e6182b9 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)
     CPU_DATA_INIT((*c));
 }
 
-static void generic_identify(struct cpuinfo_x86 *c)
+void identify_cpu(struct cpuinfo_x86 *c)
 {
 	uint64_t val;
 	u32 eax, ebx, ecx, edx, tmp;
+	int i;
+
+	reset_cpuinfo(c, false);
 
 	/* Get vendor name */
 	cpuid(0, &c->cpuid_level, &ebx, &ecx, &edx);
@@ -550,17 +553,6 @@ static void generic_identify(struct cpuinfo_x86 *c)
 		c->x86_capability[FEATURESET_m10Al] = val;
 		c->x86_capability[FEATURESET_m10Ah] = val >> 32;
 	}
-}
-
-/*
- * This does the hard work of actually picking apart the CPU stuff...
- */
-void identify_cpu(struct cpuinfo_x86 *c)
-{
-	int i;
-
-	reset_cpuinfo(c, false);
-	generic_identify(c);
 
 #ifdef NOISY_CAPS
 	printk(KERN_DEBUG "CPU: After vendor identify, caps:");
-- 
2.39.5


Re: [PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller
Posted by Jan Beulich 1 week, 3 days ago
On 26.01.2026 18:53, Andrew Cooper wrote:
> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)
>      CPU_DATA_INIT((*c));
>  }
>  
> -static void generic_identify(struct cpuinfo_x86 *c)
> +void identify_cpu(struct cpuinfo_x86 *c)
>  {
>  	uint64_t val;
>  	u32 eax, ebx, ecx, edx, tmp;
> +	int i;
> +
> +	reset_cpuinfo(c, false);
>  
>  	/* Get vendor name */
>  	cpuid(0, &c->cpuid_level, &ebx, &ecx, &edx);
> @@ -550,17 +553,6 @@ static void generic_identify(struct cpuinfo_x86 *c)
>  		c->x86_capability[FEATURESET_m10Al] = val;
>  		c->x86_capability[FEATURESET_m10Ah] = val >> 32;
>  	}
> -}
> -
> -/*
> - * This does the hard work of actually picking apart the CPU stuff...
> - */
> -void identify_cpu(struct cpuinfo_x86 *c)
> -{
> -	int i;
> -
> -	reset_cpuinfo(c, false);
> -	generic_identify(c);
>  
>  #ifdef NOISY_CAPS
>  	printk(KERN_DEBUG "CPU: After vendor identify, caps:");

To aid reducing the gap between the calls of .c_early_init() and .c_init()
(that the next patch's description talks about), wouldn't it make sense to
also drop this NOISY_CAPS thingy right here? The log message saying "After
vendor identify" isn't quite accurate anyway.

Jan
Re: [PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller
Posted by Andrew Cooper 1 week, 3 days ago
On 27/01/2026 2:02 pm, Jan Beulich wrote:
> On 26.01.2026 18:53, Andrew Cooper wrote:
>> --- a/xen/arch/x86/cpu/common.c
>> +++ b/xen/arch/x86/cpu/common.c
>> @@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)
>>      CPU_DATA_INIT((*c));
>>  }
>>  
>> -static void generic_identify(struct cpuinfo_x86 *c)
>> +void identify_cpu(struct cpuinfo_x86 *c)
>>  {
>>  	uint64_t val;
>>  	u32 eax, ebx, ecx, edx, tmp;
>> +	int i;
>> +
>> +	reset_cpuinfo(c, false);
>>  
>>  	/* Get vendor name */
>>  	cpuid(0, &c->cpuid_level, &ebx, &ecx, &edx);
>> @@ -550,17 +553,6 @@ static void generic_identify(struct cpuinfo_x86 *c)
>>  		c->x86_capability[FEATURESET_m10Al] = val;
>>  		c->x86_capability[FEATURESET_m10Ah] = val >> 32;
>>  	}
>> -}
>> -
>> -/*
>> - * This does the hard work of actually picking apart the CPU stuff...
>> - */
>> -void identify_cpu(struct cpuinfo_x86 *c)
>> -{
>> -	int i;
>> -
>> -	reset_cpuinfo(c, false);
>> -	generic_identify(c);
>>  
>>  #ifdef NOISY_CAPS
>>  	printk(KERN_DEBUG "CPU: After vendor identify, caps:");
> To aid reducing the gap between the calls of .c_early_init() and .c_init()
> (that the next patch's description talks about), wouldn't it make sense to
> also drop this NOISY_CAPS thingy right here? The log message saying "After
> vendor identify" isn't quite accurate anyway.

See patch 13.

I put it later because it probably doesn't want backporting, and this might.

~Andrew
Re: [PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller
Posted by Jan Beulich 1 week, 3 days ago
On 26.01.2026 18:53, Andrew Cooper wrote:
> This makes the correctness of future changes more obvious.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

Especially with the way the diff is presented, could I talk you into ...

> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)
>      CPU_DATA_INIT((*c));
>  }
>  
> -static void generic_identify(struct cpuinfo_x86 *c)
> +void identify_cpu(struct cpuinfo_x86 *c)
>  {
>  	uint64_t val;
>  	u32 eax, ebx, ecx, edx, tmp;
> +	int i;

... taking the opportunity and make this unsigned int?

Jan