Re: [PATCH] x86/topo: Map vendor CPU types to generic Linux such types

Pawan Gupta <[email protected]>
Newsgroups org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel
Message-ID <xsoek4nqflm4b54c4gc334hv4jqkpgnmi3mu5xffz4vevtmmrt@vfkoedmpssfy>
On Thu, Aug 27, 2026 at 01:44:25PM -0700, Borislav Petkov wrote:
> Here's the cleanup ontop, lemme know pls whether that makes sense.
> 
> Some noteworthy things:
> 
> * this basically switches to TOPO_CPU_TYPE and only the detection code knows
> about the vendor-specific ones. The generic types are union set of both.
> 
> * We do some CPUID calls where needed:
> 
> -			native_id = c->topo.intel_native_model_id;
> +			native_id = cpuid_eax(0x1a) & GENMASK(23, 0);
> 
> and in get_topology_cpu_type() but those will go away too with Ahmed's rework
> 
> The rest is just manual conversion labour. Oh, and TOPO_CPU_TYPE_ANY is gone
> too, so that Pawan can sleep at night :-P

And put my OCD to rest :-)
(BTW, some of that is acquired occupational hazard.)

> Thoughts?

Overall, looks like a good cleanup to me.

> I think it is better this way instead of carrying intel_type and amd_type in
> cpuinfo - now the topology code is preparing things for us.
> 
> I'll split it into proper patches if people are ok with it.
> 
> Thx.
...
> --- a/arch/x86/kernel/cpu/topology_common.c
> +++ b/arch/x86/kernel/cpu/topology_common.c
> @@ -35,13 +35,17 @@ void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
>  enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c)
>  {
>  	if (c->x86_vendor == X86_VENDOR_INTEL) {
> -		switch (c->topo.intel_type) {
> +		unsigned int type = (cpuid_eax(0x1a) >> 24) & 0xff;

You already mentioned about the cpuid taken care elsewhere, just noting
that this needs a (c->cpuid_level >= 0x1a) check.

> +		switch (type) {
>  		case INTEL_CPU_TYPE_ATOM: return TOPO_CPU_TYPE_EFFICIENCY;
>  		case INTEL_CPU_TYPE_CORE: return TOPO_CPU_TYPE_PERFORMANCE;
>  		}
>  	}

Since x86_match_cpu() matches with boot_cpu_data, one rough edge remaining
is, a secondary cpu_type in a hybrid system can never be matched. For
this reason X86_MATCH_VFM_CPU_TYPE() is of little use now.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.