Re: [PATCH v2 4/5] x86/cpu: Add CPU type to struct cpuinfo_topology

From: Borislav Petkov
Date: Tue Oct 22 2024 - 08:04:12 EST


On Tue, Oct 22, 2024 at 01:57:20PM +0200, Borislav Petkov wrote:
> diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c
> index 9a6069e7133c..38220b64c6b3 100644
> --- a/arch/x86/kernel/cpu/topology_common.c
> +++ b/arch/x86/kernel/cpu/topology_common.c
> @@ -27,6 +27,23 @@ void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
> }
> }
>
> +const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c)
> +{
> + enum x86_topology_cpu_type type;
> +
> + if (c->x86_vendor == X86_VENDOR_INTEL)
> + type = get_intel_cpu_type(c);
> + if (c->x86_vendor == X86_VENDOR_AMD)
> + type = get_amd_cpu_type(c);
> +
> + if (type == TOPO_CPU_TYPE_PERFORMANCE)
> + return "performance";
> + else if (type == TOPO_CPU_TYPE_EFFICIENCY)
> + return "efficiency";
> + else
> + return "unknown";
> +}

I guess you still need topology_cpu_type() in your next patch but that's easy
- you simply call it in get_topology_cpu_type_name().

The point being debugfs will dump the name of the core type and not some magic
number which no one knows.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette