[PATCH v8 6/9] x86/resctrl: Refactor the monitor read function

From: Chen Yu

Date: Fri Sep 18 2026 - 01:02:45 EST


Split the monitor read helper into an L3 read path and an AET (Intel Application
Energy Telemetry) read path. This makes the two distinct monitoring sources
easier to extend independently and prepares the L3 path for ERDT-based MMIO
reads.

No functional change.

Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
Tested-by: Hongyu Ning <hongyu.ning@xxxxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/resctrl/monitor.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 3838e0a13d36..138fd420131b 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -239,9 +239,8 @@ static u64 get_corrected_val(struct rdt_resource *r, struct rdt_l3_mon_domain *d
return chunks * hw_res->mon_scale;
}

-int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
- u32 unused, u32 rmid, enum resctrl_event_id eventid,
- void *arch_priv, u64 *val, void *ignored)
+static int arch_l3_read_event(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
+ u32 rmid, enum resctrl_event_id eventid, u64 *val)
{
struct rdt_hw_l3_mon_domain *hw_dom;
struct rdt_l3_mon_domain *d;
@@ -251,11 +250,6 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
int cpu;
int ret;

- resctrl_arch_rmid_read_context_check();
-
- if (r->rid == RDT_RESOURCE_PERF_PKG)
- return intel_aet_read_event(hdr->id, rmid, arch_priv, val);
-
if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3))
return -EINVAL;

@@ -281,6 +275,22 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
return ret;
}

+int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
+ u32 unused, u32 rmid, enum resctrl_event_id eventid,
+ void *arch_priv, u64 *val, void *ignored)
+{
+ resctrl_arch_rmid_read_context_check();
+
+ switch (r->rid) {
+ case RDT_RESOURCE_L3:
+ return arch_l3_read_event(r, hdr, rmid, eventid, val);
+ case RDT_RESOURCE_PERF_PKG:
+ return intel_aet_read_event(hdr->id, rmid, arch_priv, val);
+ default:
+ return -EINVAL;
+ }
+}
+
static int __cntr_id_read(u32 cntr_id, u64 *val)
{
struct msr msr_val = {
--
2.25.1