Skip to contentSkip to conversation

x86/topology: Add support for Low Power cpu_type

PATCH Applied Vishal Badole 2 participants 7 messages Jul 21 – Jul 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover x86/topology: Add support for Low Power cpu_type

This series extends the x86 topology cpu_type classification to support a Low Power core type, in addition to the existing Performance and Efficiency types.

AMD heterogeneous parts report the core type via CPUID Fn0x80000026 EBX[31:28] (Extended CPU Topology, Core Type). Value 2 identifies a low-power core. Distinguishing it from a regular efficiency core matters for:

- user space exposure via /sys/kernel/debug/x86/topo/cpus/*, which today reports cpu_type "unknown" for low-power cores

- amd_get_boost_ratio_numerator(): on every X86_FEATURE_AMD_HTR_CORES-capable AMD/Hygon part, low-power cores must scale by amd_get_highest_perf() rather than the fixed CPPC_HIGHEST_PERF_PERFORMANCE ceiling, matching the existing efficiency-core path

During the v1 review, Sashiko flagged a pre-existing issue in how x86_match_cpu() handles vendor CPU types. v2 therefore starts with a preparatory patch from Borislav that switches matching to the kernel's vendor-agnostic TOPO_CPU_TYPE_* enum; see its commit message for details. The Low Power support is then added on top.

The series is structured as:

1/3 Map the vendor (Intel/AMD) hardware core type to the
vendor-agnostic enum x86_topology_cpu_type at enumeration and match against it. See the patch's commit message for details.

2/3 Replace the bare 0/1 in get_topology_cpu_type() with named
enum amd_cpu_type constants, mirroring the existing Intel side. No functional change.

3/3 Add TOPO_CPU_TYPE_LOW_POWER, wire it through
get_topology_cpu_type(), get_topology_cpu_type_name() and the switch in amd_get_boost_ratio_numerator() so allmodconfig builds cleanly under -Werror=switch.

Changes in v2:
- New preparatory patch 1/3 from Borislav Petkov switching x86_match_cpu() to the vendor-agnostic TOPO_CPU_TYPE_* enum; see its commit message for the rationale. (Thomas Gleixner, Borislav Petkov)
- No change to the Low Power translation logic itself; patches 2/3 and 3/3 are the v1 patches rebased on top of the new 1/3.

v1: https://lore.kernel.org/all/[email protected]

Borislav Petkov (AMD) (1):
x86/topo: Map vendor CPU types to generic Linux such types

Vishal Badole (2):
x86/topology: Name the AMD core-type values
x86/topology: Add TOPO_CPU_TYPE_LOW_POWER

 arch/x86/include/asm/processor.h      | 19 +++++++++++++----
 arch/x86/include/asm/topology.h       |  9 ++++----
 arch/x86/kernel/acpi/cppc.c           |  7 ++++---
 arch/x86/kernel/cpu/match.c           | 30 +--------------------------
 arch/x86/kernel/cpu/topology.h        |  1 +
 arch/x86/kernel/cpu/topology_amd.c    |  6 ++++--
 arch/x86/kernel/cpu/topology_common.c | 15 ++++++++++----
 7 files changed, 40 insertions(+), 47 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 x86/topo: Map vendor CPU types to generic Linux such types

From: "Borislav Petkov (AMD)" <[email protected]>

Sashiko reported¹ that a confusion could ensue if a vendor-specific CPU type 0 (performance) gets attempted to be used in a x86_cpu_id match table. The current logic treats 0 as the wildcard X86_CPU_TYPE_ANY and such a thing would end up matching the wrong CPUs.

This is all backwards because we started using the vendor-specific CPU type number instead of using a Linux-defined, generic CPU type which is agnostic.

Convert the current logic to it before users start appearing.

¹https://sashiko.dev/#/patchset/20260629094349.533301-1-Vishal.Badole%40amd.com

---
 arch/x86/include/asm/processor.h      | 18 ++++++++++++----
 arch/x86/include/asm/topology.h       |  7 -------
 arch/x86/kernel/acpi/cppc.c           |  4 ++--
 arch/x86/kernel/cpu/match.c           | 30 +--------------------------
 arch/x86/kernel/cpu/topology.h        |  1 +
 arch/x86/kernel/cpu/topology_amd.c    |  6 ++++--
 arch/x86/kernel/cpu/topology_common.c |  8 +++++--
 7 files changed, 28 insertions(+), 46 deletions(-)
arch/x86/include/asm/processor.h +14 -4
index 87b1d4c0727e..fc0350fe8f5e 100644
@@ -68,9 +68,13 @@ extern u16 __read_mostly tlb_lld_2m;
 extern u16 __read_mostly tlb_lld_4m;
 extern u16 __read_mostly tlb_lld_1g;
 
-/*
- * CPU type and hardware bug flags. Kept separately for each CPU.
- */
+enum x86_topology_cpu_type {
+	/* X86_CPU_TYPE_ANY */
+	TOPO_CPU_TYPE_ANY = 0,
+	TOPO_CPU_TYPE_PERFORMANCE,
+	TOPO_CPU_TYPE_EFFICIENCY,
+	TOPO_CPU_TYPE_UNKNOWN,
+};
 
 struct cpuinfo_topology {
 	// Real APIC ID read from the local APIC
@@ -104,7 +108,7 @@ struct cpuinfo_topology {
 
 	// Hardware defined CPU-type
 	union {
-		u32		cpu_type;
+		u32		hw_cpu_type;
 		struct {
 			// CPUID.1A.EAX[23-0]
 			u32	intel_native_model_id	:24;
@@ -119,8 +123,14 @@ struct cpuinfo_topology {
 				amd_type		:4;
 		};
 	};
+
+	// Linux vendor-agnostic CPU type
+	enum x86_topology_cpu_type cpu_type;
 };
 
+/*
+ * CPU type and hardware bug flags. Kept separately for each CPU.
+ */
 struct cpuinfo_x86 {
 	union {
 		/*
arch/x86/include/asm/topology.h +0 -7
index 8fb61d2465eb..ef76ba674f1b 100644
@@ -114,12 +114,6 @@ enum x86_topology_domains {
 	TOPO_MAX_DOMAIN,
 };
 
-enum x86_topology_cpu_type {
-	TOPO_CPU_TYPE_PERFORMANCE,
-	TOPO_CPU_TYPE_EFFICIENCY,
-	TOPO_CPU_TYPE_UNKNOWN,
-};
-
 struct x86_topology_system {
 	unsigned int	dom_shifts[TOPO_MAX_DOMAIN];
 	unsigned int	dom_size[TOPO_MAX_DOMAIN];
@@ -160,7 +154,6 @@ extern unsigned int __num_nodes_per_package;
 struct cpuinfo_x86;
 
 const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c);
-enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
 
 static inline unsigned int topology_max_packages(void)
 {
arch/x86/kernel/acpi/cppc.c +2 -2
index be4c5e9e5ff6..b8f5dd0a8117 100644
@@ -241,7 +241,6 @@ EXPORT_SYMBOL_GPL(amd_detect_prefcore);
  */
 int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 {
-	enum x86_topology_cpu_type core_type = get_topology_cpu_type(&cpu_data(cpu));
 	bool prefcore;
 	int ret;
 	u32 tmp;
@@ -273,8 +272,9 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 
 	/* detect if running on heterogeneous design */
 	if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) {
-		switch (core_type) {
+		switch (cpu_data(cpu).topo.cpu_type) {
 		case TOPO_CPU_TYPE_UNKNOWN:
+		case TOPO_CPU_TYPE_ANY:
 			pr_warn("Undefined core type found for cpu %d\n", cpu);
 			break;
 		case TOPO_CPU_TYPE_PERFORMANCE:
arch/x86/kernel/cpu/match.c +1 -29
index 4604802692da..7ab077f0cc66 100644
@@ -5,34 +5,6 @@
 #include <linux/export.h>
 #include <linux/slab.h>
 
-/**
- * x86_match_vendor_cpu_type - helper function to match the hardware defined
- *                             cpu-type for a single entry in the x86_cpu_id
- *                             table. Note, this function does not match the
- *                             generic cpu-types TOPO_CPU_TYPE_EFFICIENCY and
- *                             TOPO_CPU_TYPE_PERFORMANCE.
- * @c: Pointer to the cpuinfo_x86 structure of the CPU to match.
- * @m: Pointer to the x86_cpu_id entry to match against.
- *
- * Return: true if the cpu-type matches, false otherwise.
- */
-static bool x86_match_vendor_cpu_type(struct cpuinfo_x86 *c, const struct x86_cpu_id *m)
-{
-	if (m->type == X86_CPU_TYPE_ANY)
-		return true;
-
-	/* Hybrid CPUs are special, they are assumed to match all cpu-types */
-	if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU))
-		return true;
-
-	if (c->x86_vendor == X86_VENDOR_INTEL)
-		return m->type == c->topo.intel_type;
-	if (c->x86_vendor == X86_VENDOR_AMD)
-		return m->type == c->topo.amd_type;
-
-	return false;
-}
-
 /**
  * x86_match_cpu - match current CPU against an array of x86_cpu_ids
  * @match: Pointer to array of x86_cpu_ids. Last entry terminated with
@@ -81,7 +53,7 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
 			continue;
 		if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
 			continue;
-		if (!x86_match_vendor_cpu_type(c, m))
+		if (m->type != X86_CPU_TYPE_ANY && c->topo.cpu_type != m->type)
 			continue;
 		return m;
 	}
arch/x86/kernel/cpu/topology.h +1 -0
index 37326297f80c..74e02bacd854 100644
@@ -22,6 +22,7 @@ void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
 bool cpu_parse_topology_ext(struct topo_scan *tscan);
 void cpu_parse_topology_amd(struct topo_scan *tscan);
 void cpu_topology_fixup_amd(struct topo_scan *tscan);
+enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
 
 static inline u32 topo_shift_apicid(u32 apicid, enum x86_topology_domains dom)
 {
arch/x86/kernel/cpu/topology_amd.c +4 -2
index da080d732e10..c5a6944df86a 100644
@@ -177,8 +177,10 @@ static void topoext_fixup(struct topo_scan *tscan)
 
 static void parse_topology_amd(struct topo_scan *tscan)
 {
-	if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES))
-		tscan->c->topo.cpu_type = cpuid_ebx(0x80000026);
+	if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) {
+		tscan->c->topo.hw_cpu_type = cpuid_ebx(0x80000026);
+		tscan->c->topo.cpu_type    = get_topology_cpu_type(tscan->c);
+	}
 
 	/*
 	 * Try to get SMT, CORE, TILE, and DIE shifts from extended
arch/x86/kernel/cpu/topology_common.c +6 -2
index cf7513416b70..b9d025f3373a 100644
@@ -168,8 +168,12 @@ static void parse_topology(struct topo_scan *tscan, bool early)
 	case X86_VENDOR_INTEL:
 		if (!IS_ENABLED(CONFIG_CPU_SUP_INTEL) || !cpu_parse_topology_ext(tscan))
 			parse_legacy(tscan);
-		if (c->cpuid_level >= 0x1a)
-			c->topo.cpu_type = cpuid_eax(0x1a);
+
+		if (c->cpuid_level >= 0x1a) {
+			c->topo.hw_cpu_type = cpuid_eax(0x1a);
+			c->topo.cpu_type    = get_topology_cpu_type(c);
+		}
+
 		break;
 	}
 }
Signature · 1 line
2.34.1
#2 lore raw

[tip: x86/cpu] x86/topo: Map vendor CPU types to generic Linux such types

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     598ebce64c4cfaca54cbecdc25a7ef56ea701051
Gitweb:        https://git.kernel.org/tip/598ebce64c4cfaca54cbecdc25a7ef56ea701051
Author:        Borislav Petkov (AMD) <[email protected]>
AuthorDate:    Tue, 21 Jul 2026 21:15:12 +05:30
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 23 Jul 2026 14:23:15 -07:00

x86/topo: Map vendor CPU types to generic Linux such types

Sashiko reported¹ that a confusion could ensue if a vendor-specific CPU type 0 (performance) gets attempted to be used in a x86_cpu_id match table. The current logic treats 0 as the wildcard X86_CPU_TYPE_ANY and such a thing would end up matching the wrong CPUs.

This is all backwards because we started using the vendor-specific CPU type number instead of using a Linux-defined, generic CPU type which is agnostic.

Convert the current logic to it before users start appearing.

¹https://sashiko.dev/#/patchset/20260629094349.533301-1-Vishal.Badole%40amd.com

---
 arch/x86/include/asm/processor.h      | 18 ++++++++++++----
 arch/x86/include/asm/topology.h       |  7 +------
 arch/x86/kernel/acpi/cppc.c           |  4 +--
 arch/x86/kernel/cpu/match.c           | 30 +--------------------------
 arch/x86/kernel/cpu/topology.h        |  1 +-
 arch/x86/kernel/cpu/topology_amd.c    |  6 +++--
 arch/x86/kernel/cpu/topology_common.c |  8 +++++--
 7 files changed, 28 insertions(+), 46 deletions(-)
arch/x86/include/asm/processor.h +14 -4
index 87b1d4c..fc0350f 100644
@@ -68,9 +68,13 @@ extern u16 __read_mostly tlb_lld_2m;
 extern u16 __read_mostly tlb_lld_4m;
 extern u16 __read_mostly tlb_lld_1g;
 
-/*
- * CPU type and hardware bug flags. Kept separately for each CPU.
- */
+enum x86_topology_cpu_type {
+	/* X86_CPU_TYPE_ANY */
+	TOPO_CPU_TYPE_ANY = 0,
+	TOPO_CPU_TYPE_PERFORMANCE,
+	TOPO_CPU_TYPE_EFFICIENCY,
+	TOPO_CPU_TYPE_UNKNOWN,
+};
 
 struct cpuinfo_topology {
 	// Real APIC ID read from the local APIC
@@ -104,7 +108,7 @@ struct cpuinfo_topology {
 
 	// Hardware defined CPU-type
 	union {
-		u32		cpu_type;
+		u32		hw_cpu_type;
 		struct {
 			// CPUID.1A.EAX[23-0]
 			u32	intel_native_model_id	:24;
@@ -119,8 +123,14 @@ struct cpuinfo_topology {
 				amd_type		:4;
 		};
 	};
+
+	// Linux vendor-agnostic CPU type
+	enum x86_topology_cpu_type cpu_type;
 };
 
+/*
+ * CPU type and hardware bug flags. Kept separately for each CPU.
+ */
 struct cpuinfo_x86 {
 	union {
 		/*
arch/x86/include/asm/topology.h +0 -7
index 8fb61d2..ef76ba6 100644
@@ -114,12 +114,6 @@ enum x86_topology_domains {
 	TOPO_MAX_DOMAIN,
 };
 
-enum x86_topology_cpu_type {
-	TOPO_CPU_TYPE_PERFORMANCE,
-	TOPO_CPU_TYPE_EFFICIENCY,
-	TOPO_CPU_TYPE_UNKNOWN,
-};
-
 struct x86_topology_system {
 	unsigned int	dom_shifts[TOPO_MAX_DOMAIN];
 	unsigned int	dom_size[TOPO_MAX_DOMAIN];
@@ -160,7 +154,6 @@ extern unsigned int __num_nodes_per_package;
 struct cpuinfo_x86;
 
 const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c);
-enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
 
 static inline unsigned int topology_max_packages(void)
 {
arch/x86/kernel/acpi/cppc.c +2 -2
index be4c5e9..b8f5dd0 100644
@@ -241,7 +241,6 @@ EXPORT_SYMBOL_GPL(amd_detect_prefcore);
  */
 int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 {
-	enum x86_topology_cpu_type core_type = get_topology_cpu_type(&cpu_data(cpu));
 	bool prefcore;
 	int ret;
 	u32 tmp;
@@ -273,8 +272,9 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 
 	/* detect if running on heterogeneous design */
 	if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) {
-		switch (core_type) {
+		switch (cpu_data(cpu).topo.cpu_type) {
 		case TOPO_CPU_TYPE_UNKNOWN:
+		case TOPO_CPU_TYPE_ANY:
 			pr_warn("Undefined core type found for cpu %d\n", cpu);
 			break;
 		case TOPO_CPU_TYPE_PERFORMANCE:
arch/x86/kernel/cpu/match.c +1 -29
index 4604802..7ab077f 100644
@@ -6,34 +6,6 @@
 #include <linux/slab.h>
 
 /**
- * x86_match_vendor_cpu_type - helper function to match the hardware defined
- *                             cpu-type for a single entry in the x86_cpu_id
- *                             table. Note, this function does not match the
- *                             generic cpu-types TOPO_CPU_TYPE_EFFICIENCY and
- *                             TOPO_CPU_TYPE_PERFORMANCE.
- * @c: Pointer to the cpuinfo_x86 structure of the CPU to match.
- * @m: Pointer to the x86_cpu_id entry to match against.
- *
- * Return: true if the cpu-type matches, false otherwise.
- */
-static bool x86_match_vendor_cpu_type(struct cpuinfo_x86 *c, const struct x86_cpu_id *m)
-{
-	if (m->type == X86_CPU_TYPE_ANY)
-		return true;
-
-	/* Hybrid CPUs are special, they are assumed to match all cpu-types */
-	if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU))
-		return true;
-
-	if (c->x86_vendor == X86_VENDOR_INTEL)
-		return m->type == c->topo.intel_type;
-	if (c->x86_vendor == X86_VENDOR_AMD)
-		return m->type == c->topo.amd_type;
-
-	return false;
-}
-
-/**
  * x86_match_cpu - match current CPU against an array of x86_cpu_ids
  * @match: Pointer to array of x86_cpu_ids. Last entry terminated with
  *         {}.
@@ -81,7 +53,7 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
 			continue;
 		if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
 			continue;
-		if (!x86_match_vendor_cpu_type(c, m))
+		if (m->type != X86_CPU_TYPE_ANY && c->topo.cpu_type != m->type)
 			continue;
 		return m;
 	}
arch/x86/kernel/cpu/topology.h +1 -0
index 3732629..74e02ba 100644
@@ -22,6 +22,7 @@ void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
 bool cpu_parse_topology_ext(struct topo_scan *tscan);
 void cpu_parse_topology_amd(struct topo_scan *tscan);
 void cpu_topology_fixup_amd(struct topo_scan *tscan);
+enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
 
 static inline u32 topo_shift_apicid(u32 apicid, enum x86_topology_domains dom)
 {
arch/x86/kernel/cpu/topology_amd.c +4 -2
index da080d7..c5a6944 100644
@@ -177,8 +177,10 @@ static void topoext_fixup(struct topo_scan *tscan)
 
 static void parse_topology_amd(struct topo_scan *tscan)
 {
-	if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES))
-		tscan->c->topo.cpu_type = cpuid_ebx(0x80000026);
+	if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) {
+		tscan->c->topo.hw_cpu_type = cpuid_ebx(0x80000026);
+		tscan->c->topo.cpu_type    = get_topology_cpu_type(tscan->c);
+	}
 
 	/*
 	 * Try to get SMT, CORE, TILE, and DIE shifts from extended
arch/x86/kernel/cpu/topology_common.c +6 -2
index cf75134..b9d025f 100644
@@ -168,8 +168,12 @@ static void parse_topology(struct topo_scan *tscan, bool early)
 	case X86_VENDOR_INTEL:
 		if (!IS_ENABLED(CONFIG_CPU_SUP_INTEL) || !cpu_parse_topology_ext(tscan))
 			parse_legacy(tscan);
-		if (c->cpuid_level >= 0x1a)
-			c->topo.cpu_type = cpuid_eax(0x1a);
+
+		if (c->cpuid_level >= 0x1a) {
+			c->topo.hw_cpu_type = cpuid_eax(0x1a);
+			c->topo.cpu_type    = get_topology_cpu_type(c);
+		}
+
 		break;
 	}
 }
#3 lore raw

PATCH v2 2/3 x86/topology: Name the AMD core-type values

In reply to Vishal Badole

Replace the bare 0/1 in get_topology_cpu_type() with named constants that mirror what the AMD APM publishes for CPUID Fn0x80000026 EBX[31:28] (Extended CPU Topology, Core Type):

0 - Performance core
1 - Efficient core
2 - Low-power core (used by a follow-up)

No functional change.

---
 arch/x86/include/asm/topology.h       | 6 ++++++
 arch/x86/kernel/cpu/topology_common.c | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)
arch/x86/include/asm/topology.h +6 -0
index ef76ba674f1b..1825691af941 100644
@@ -114,6 +114,12 @@ enum x86_topology_domains {
 	TOPO_MAX_DOMAIN,
 };
 
+enum amd_cpu_type {
+	AMD_CPU_TYPE_PERFORMANCE	= 0,
+	AMD_CPU_TYPE_EFFICIENCY		= 1,
+	AMD_CPU_TYPE_LOW_POWER		= 2,
+};
+
 struct x86_topology_system {
 	unsigned int	dom_shifts[TOPO_MAX_DOMAIN];
 	unsigned int	dom_size[TOPO_MAX_DOMAIN];
arch/x86/kernel/cpu/topology_common.c +2 -2
index b9d025f3373a..71b6c33afe0b 100644
@@ -42,8 +42,8 @@ enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c)
 	}
 	if (c->x86_vendor == X86_VENDOR_AMD) {
 		switch (c->topo.amd_type) {
-		case 0:	return TOPO_CPU_TYPE_PERFORMANCE;
-		case 1:	return TOPO_CPU_TYPE_EFFICIENCY;
+		case AMD_CPU_TYPE_PERFORMANCE:	return TOPO_CPU_TYPE_PERFORMANCE;
+		case AMD_CPU_TYPE_EFFICIENCY:	return TOPO_CPU_TYPE_EFFICIENCY;
 		}
 	}
 
Signature · 1 line
2.34.1
merge bot Applied
#4 lore raw

[tip: x86/cpu] x86/topology: Name the AMD core-type values

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     bdb1b1f03b9b1cc1cde7d54f8b5b2f9a6bdda782
Gitweb:        https://git.kernel.org/tip/bdb1b1f03b9b1cc1cde7d54f8b5b2f9a6bdda782
Author:        Vishal Badole <[email protected]>
AuthorDate:    Tue, 21 Jul 2026 21:15:13 +05:30
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 23 Jul 2026 14:23:27 -07:00

x86/topology: Name the AMD core-type values

Replace the bare 0/1 in get_topology_cpu_type() with named constants that mirror what the AMD APM publishes for CPUID Fn0x80000026 EBX[31:28] (Extended CPU Topology, Core Type):

0 - Performance core
1 - Efficient core
2 - Low-power core (used by a follow-up)

No functional change.

---
 arch/x86/include/asm/topology.h       | 6 ++++++
 arch/x86/kernel/cpu/topology_common.c | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)
arch/x86/include/asm/topology.h +6 -0
index ef76ba6..1825691 100644
@@ -114,6 +114,12 @@ enum x86_topology_domains {
 	TOPO_MAX_DOMAIN,
 };
 
+enum amd_cpu_type {
+	AMD_CPU_TYPE_PERFORMANCE	= 0,
+	AMD_CPU_TYPE_EFFICIENCY		= 1,
+	AMD_CPU_TYPE_LOW_POWER		= 2,
+};
+
 struct x86_topology_system {
 	unsigned int	dom_shifts[TOPO_MAX_DOMAIN];
 	unsigned int	dom_size[TOPO_MAX_DOMAIN];
arch/x86/kernel/cpu/topology_common.c +2 -2
index b9d025f..71b6c33 100644
@@ -42,8 +42,8 @@ enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c)
 	}
 	if (c->x86_vendor == X86_VENDOR_AMD) {
 		switch (c->topo.amd_type) {
-		case 0:	return TOPO_CPU_TYPE_PERFORMANCE;
-		case 1:	return TOPO_CPU_TYPE_EFFICIENCY;
+		case AMD_CPU_TYPE_PERFORMANCE:	return TOPO_CPU_TYPE_PERFORMANCE;
+		case AMD_CPU_TYPE_EFFICIENCY:	return TOPO_CPU_TYPE_EFFICIENCY;
 		}
 	}
 
#5 lore raw

PATCH v2 3/3 x86/topology: Add TOPO_CPU_TYPE_LOW_POWER

In reply to Vishal Badole

AMD heterogeneous parts report a third core type via CPUID Fn0x80000026 EBX[31:28] (Extended CPU Topology, Core Type):

0 - Performance
1 - Efficiency
2 - Low Power

get_topology_cpu_type() only translates the first two, so on parts that ship low-power cores the third type falls through to TOPO_CPU_TYPE_UNKNOWN. That has two visible effects:

- /sys/kernel/debug/x86/topo/cpus/* reports cpu_type "unknown" via get_topology_cpu_type_name().

- amd_get_boost_ratio_numerator() hits the default arm of its x86_topology_cpu_type switch and uses the CPPC_HIGHEST_PERF_PREFCORE fallback instead of scaling by amd_get_highest_perf() as efficiency cores do.

Add TOPO_CPU_TYPE_LOW_POWER, translate AMD_CPU_TYPE_LOW_POWER to it in get_topology_cpu_type(), and expose a "low_power" name via get_topology_cpu_type_name().

In amd_get_boost_ratio_numerator(), share the efficiency-core arm of the switch with the new type so low-power cores scale by amd_get_highest_perf() rather than the performance-core ceiling. The new case sits under the existing cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES) gate and therefore applies to every HTR_CORES-capable AMD/Hygon part that reports core type 2.

---
 arch/x86/include/asm/processor.h      | 1 +
 arch/x86/kernel/acpi/cppc.c           | 3 ++-
 arch/x86/kernel/cpu/topology_common.c | 3 +++
 3 files changed, 6 insertions(+), 1 deletion(-)
arch/x86/include/asm/processor.h +1 -0
index fc0350fe8f5e..9e8183441888 100644
@@ -73,6 +73,7 @@ enum x86_topology_cpu_type {
 	TOPO_CPU_TYPE_ANY = 0,
 	TOPO_CPU_TYPE_PERFORMANCE,
 	TOPO_CPU_TYPE_EFFICIENCY,
+	TOPO_CPU_TYPE_LOW_POWER,
 	TOPO_CPU_TYPE_UNKNOWN,
 };
 
arch/x86/kernel/acpi/cppc.c +2 -1
index b8f5dd0a8117..bbade0da5130 100644
@@ -281,8 +281,9 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 			/* use the max scale for performance cores */
 			*numerator = CPPC_HIGHEST_PERF_PERFORMANCE;
 			return 0;
+		case TOPO_CPU_TYPE_LOW_POWER:
 		case TOPO_CPU_TYPE_EFFICIENCY:
-			/* use the highest perf value for efficiency cores */
+			/* use the highest perf value for efficiency and low-power cores */
 			ret = amd_get_highest_perf(cpu, &tmp);
 			if (ret)
 				return ret;
arch/x86/kernel/cpu/topology_common.c +3 -0
index 71b6c33afe0b..581f2fcd7e42 100644
@@ -44,6 +44,7 @@ enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c)
 		switch (c->topo.amd_type) {
 		case AMD_CPU_TYPE_PERFORMANCE:	return TOPO_CPU_TYPE_PERFORMANCE;
 		case AMD_CPU_TYPE_EFFICIENCY:	return TOPO_CPU_TYPE_EFFICIENCY;
+		case AMD_CPU_TYPE_LOW_POWER:	return TOPO_CPU_TYPE_LOW_POWER;
 		}
 	}
 
@@ -57,6 +58,8 @@ const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c)
 		return "performance";
 	case TOPO_CPU_TYPE_EFFICIENCY:
 		return "efficiency";
+	case TOPO_CPU_TYPE_LOW_POWER:
+		return "low_power";
 	default:
 		return "unknown";
 	}
Signature · 1 line
2.34.1
merge bot Applied
#6 lore raw

[tip: x86/cpu] x86/topology: Add TOPO_CPU_TYPE_LOW_POWER

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     924be9d673eb75deef2f71ddee0d7d89fe69bb7b
Gitweb:        https://git.kernel.org/tip/924be9d673eb75deef2f71ddee0d7d89fe69bb7b
Author:        Vishal Badole <[email protected]>
AuthorDate:    Tue, 21 Jul 2026 21:15:14 +05:30
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 23 Jul 2026 14:23:47 -07:00

x86/topology: Add TOPO_CPU_TYPE_LOW_POWER

AMD heterogeneous parts report a third core type via CPUID Fn0x80000026 EBX[31:28] (Extended CPU Topology, Core Type):

0 - Performance
1 - Efficiency
2 - Low Power

get_topology_cpu_type() only translates the first two, so on parts that ship low-power cores the third type falls through to TOPO_CPU_TYPE_UNKNOWN.

Add TOPO_CPU_TYPE_LOW_POWER which takes care of this new type.

[ bp: Massage commit message, zap the "what" explanation. ]

---
 arch/x86/include/asm/processor.h      | 1 +
 arch/x86/kernel/acpi/cppc.c           | 3 ++-
 arch/x86/kernel/cpu/topology_common.c | 3 +++
 3 files changed, 6 insertions(+), 1 deletion(-)
arch/x86/include/asm/processor.h +1 -0
index fc0350f..9e81834 100644
@@ -73,6 +73,7 @@ enum x86_topology_cpu_type {
 	TOPO_CPU_TYPE_ANY = 0,
 	TOPO_CPU_TYPE_PERFORMANCE,
 	TOPO_CPU_TYPE_EFFICIENCY,
+	TOPO_CPU_TYPE_LOW_POWER,
 	TOPO_CPU_TYPE_UNKNOWN,
 };
 
arch/x86/kernel/acpi/cppc.c +2 -1
index b8f5dd0..bbade0d 100644
@@ -281,8 +281,9 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 			/* use the max scale for performance cores */
 			*numerator = CPPC_HIGHEST_PERF_PERFORMANCE;
 			return 0;
+		case TOPO_CPU_TYPE_LOW_POWER:
 		case TOPO_CPU_TYPE_EFFICIENCY:
-			/* use the highest perf value for efficiency cores */
+			/* use the highest perf value for efficiency and low-power cores */
 			ret = amd_get_highest_perf(cpu, &tmp);
 			if (ret)
 				return ret;
arch/x86/kernel/cpu/topology_common.c +3 -0
index 71b6c33..581f2fc 100644
@@ -44,6 +44,7 @@ enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c)
 		switch (c->topo.amd_type) {
 		case AMD_CPU_TYPE_PERFORMANCE:	return TOPO_CPU_TYPE_PERFORMANCE;
 		case AMD_CPU_TYPE_EFFICIENCY:	return TOPO_CPU_TYPE_EFFICIENCY;
+		case AMD_CPU_TYPE_LOW_POWER:	return TOPO_CPU_TYPE_LOW_POWER;
 		}
 	}
 
@@ -57,6 +58,8 @@ const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c)
 		return "performance";
 	case TOPO_CPU_TYPE_EFFICIENCY:
 		return "efficiency";
+	case TOPO_CPU_TYPE_LOW_POWER:
+		return "low_power";
 	default:
 		return "unknown";
 	}