[PATCH v13 20/25] x86/resctrl: Enforce system RMID limit on AET
From: Tony Luck
Date: Mon Sep 28 2026 - 18:18:59 EST
AET (Application Energy Telemetry) event groups each support a specific
number of RMIDs. But that number may be higher than the number supported
by the system.
Ensure that info/PERF_PKG_MON/num_rmids does not display an unachievable
value to users by capping the maximum supported RMIDs in the resource to
the system maximum.
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
v13:
Drop sentence about SNC reducing number of RMIDs as it isn't
relevant.
s/lower/higher/ in commit message.
s/IA32_PQR_ASSOC.RMID/MSR_IA32_PQR_ASSOC.RMID/
Changed pqr_assoc_num_rmid from static to global.
Move clamp from arch/x86/kernel/cpu/resctrl/core.c to
arch/x86/kernel/cpu/resctrl/intel_aet.c
---
arch/x86/kernel/cpu/resctrl/internal.h | 2 ++
arch/x86/kernel/cpu/resctrl/core.c | 2 +-
arch/x86/kernel/cpu/resctrl/intel_aet.c | 7 +++++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index c66954bc01e7..1f080aad1b67 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -153,6 +153,8 @@ extern struct rdt_hw_resource rdt_resources_all[];
extern bool intel_rdt_mbm_need_quirk;
+extern u32 pqr_assoc_num_rmid;
+
void arch_mon_domain_online(struct rdt_resource *r, struct rdt_l3_mon_domain *d);
/* CPUID.(EAX=10H, ECX=ResID=1).EAX */
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 40466f29e48e..689b9e31fe7a 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -46,7 +46,7 @@ static DEFINE_MUTEX(domain_list_lock);
DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state);
/* Number of unique RMID values that can be written to MSR_IA32_PQR_ASSOC.RMID */
-static u32 pqr_assoc_num_rmid;
+u32 pqr_assoc_num_rmid;
static void mba_wrmsr_intel(struct msr_param *m);
static void cat_wrmsr(struct msr_param *m);
diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/resctrl/intel_aet.c
index 8aa2e18a6bbb..e64e5a44511f 100644
--- a/arch/x86/kernel/cpu/resctrl/intel_aet.c
+++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c
@@ -274,6 +274,12 @@ static bool enable_events(struct event_group *e, struct pmt_feature_group *p)
else
r->mon.num_rmid = e->num_rmid;
+ /*
+ * AET may claim to support more RMIDs than are permitted to be
+ * assigned to MSR_IA32_PQR_ASSOC.RMID. Enforce this limit.
+ */
+ r->mon.num_rmid = min(r->mon.num_rmid, pqr_assoc_num_rmid);
+
if (skipped_events)
pr_info("%s %s:0x%x monitoring detected (skipped %d events)\n", r->name,
e->pfname, e->guid, skipped_events);
@@ -391,6 +397,7 @@ void intel_aet_unmount(void)
struct event_group **peg;
guard(mutex)(&aet_register_lock);
+
if (!pmt_in_use)
return;
--
2.55.0