[PATCH v14 19/24] x86/resctrl: Enforce system RMID limit on AET
From: Tony Luck
Date: Mon Oct 19 2026 - 16:59:21 EST
The RMID a CPU uses for telemetry is the RMID written to
MSR_IA32_PQR_ASSOC.RMID, so the number of RMIDs that register can hold
(enumerated via CPUID) bounds every monitoring resource. Each AET
(Application Energy Telemetry) event group separately describes how many
RMIDs its counters support.
The number of RMIDs an event group supports may be higher than the number
that can be written to MSR_IA32_PQR_ASSOC.RMID. The telemetry resource
then advertises more RMIDs than can ever be used, both to user space in
info/PERF_PKG_MON/num_rmids and, on systems where telemetry is the only
monitoring resource, as the number of RMIDs available to the mount.
Cap the number of RMIDs of the telemetry resource at the number that can
be written to MSR_IA32_PQR_ASSOC.RMID.
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
v14:
New commit comment
---
arch/x86/kernel/cpu/resctrl/internal.h | 2 ++
arch/x86/kernel/cpu/resctrl/core.c | 2 +-
arch/x86/kernel/cpu/resctrl/intel_aet.c | 6 ++++++
3 files changed, 9 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 75cd602d65ae..5c88236d850f 100644
--- a/arch/x86/kernel/cpu/resctrl/intel_aet.c
+++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c
@@ -308,6 +308,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);
--
2.56.0