[RFC PATCH 5/8] x86/resctrl: Refactor rdt_get_cache_alloc_cfg()

From: Tony Luck

Date: Mon Oct 26 2026 - 17:58:34 EST


Enumeration of the parameters for L2 and L3 cache allocation is in
a common format in separate sub-leaves of CPUID leaf 0x10. A helper
function is used to process both L2 and L3.

Asymmetric enumeration is in leaf 0x28 in the same format as leaf 0x10.

In preparation to support asymmetric L2 configurations make the leaf
a parameter to rdt_get_cache_alloc_cfg().

No functional change.

Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
arch/x86/kernel/cpu/resctrl/core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index c66ff4cdd84b..c26fc75ccc07 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -348,7 +348,7 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)
return true;
}

-static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
+static void rdt_get_cache_alloc_cfg(int leaf, int idx, struct rdt_resource *r)
{
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
struct resctrl_hw_ctrl *hw_ctrl;
@@ -357,7 +357,7 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
union cpuid_0x10_x_edx edx;
u32 ebx, default_ctrl;

- cpuid_count(CPUID_LEAF_RDT_A, idx, &eax.full, &ebx, &ecx.full, &edx.full);
+ cpuid_count(leaf, idx, &eax.full, &ebx, &ecx.full, &edx.full);
hw_res->num_closid = edx.split.cos_max + 1;
hw_ctrl = kzalloc_obj(*hw_ctrl);
if (!hw_ctrl)
@@ -1061,7 +1061,7 @@ static __init bool get_rdt_alloc_resources(void)

if (rdt_cpu_has(X86_FEATURE_CAT_L3)) {
r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
- rdt_get_cache_alloc_cfg(1, r);
+ rdt_get_cache_alloc_cfg(CPUID_LEAF_RDT_A, 1, r);
if (rdt_cpu_has(X86_FEATURE_CDP_L3))
rdt_get_cdp_l3_config();
if (rdt_cpu_has(X86_FEATURE_SDCIAE))
@@ -1071,7 +1071,7 @@ static __init bool get_rdt_alloc_resources(void)
if (rdt_cpu_has(X86_FEATURE_CAT_L2)) {
/* CPUID 0x10.2 fields are same format at 0x10.1 */
r = &rdt_resources_all[RDT_RESOURCE_L2].r_resctrl;
- rdt_get_cache_alloc_cfg(2, r);
+ rdt_get_cache_alloc_cfg(CPUID_LEAF_RDT_A, 2, r);
if (rdt_cpu_has(X86_FEATURE_CDP_L2))
rdt_get_cdp_l2_config();
ret = true;
--
2.56.0