[RFC PATCH 3/6] x86/resctrl: Rename prev_msr to prev_mon_val
From: Chen Yu
Date: Wed May 27 2026 - 05:42:49 EST
Rename the prev_msr field in struct arch_mbm_state to prev_mon_val.
With ERDT, the previous monitor value may come from an MMIO
register rather than from an MSR, so the "msr" suffix is no longer
accurate. The new name describes the field by its meaning (the
previous monitor value) instead of by the access method.
This is preparation for ERDT support, which reads monitoring
counters via MMIO.
No functional change.
Co-developed-by: Anil S Keshavamurthy <anil.s.keshavamurthy@xxxxxxxxx>
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@xxxxxxxxx>
Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
---
arch/x86/kernel/cpu/resctrl/internal.h | 8 +++----
arch/x86/kernel/cpu/resctrl/monitor.c | 30 +++++++++++++-------------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 9c59bd5e028e..97065dc6e14f 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -31,13 +31,13 @@
/**
* struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s
* return value.
- * @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes)
- * @prev_msr: Value of IA32_QM_CTR last time it was read for the RMID used to
- * find this struct.
+ * @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes)
+ * @prev_mon_val: Previous monitor counter value for the RMID used to
+ * find this struct.
*/
struct arch_mbm_state {
u64 chunks;
- u64 prev_msr;
+ u64 prev_mon_val;
};
/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 9bd87bae4983..991f0a796551 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -186,7 +186,7 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_l3_mon_domain *d
prmid = logical_rmid_to_physical_rmid(cpu, rmid);
/* Record any initial, non-zero count value. */
- __rmid_read_phys(prmid, eventid, &am->prev_msr);
+ __rmid_read_phys(prmid, eventid, &am->prev_mon_val);
}
}
@@ -209,16 +209,16 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_l3_mon_domai
}
}
-static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int width)
+static u64 mbm_overflow_count(u64 prev_val, u64 cur_val, unsigned int width)
{
u64 shift = 64 - width, chunks;
- chunks = (cur_msr << shift) - (prev_msr << shift);
+ chunks = (cur_val << shift) - (prev_val << shift);
return chunks >> shift;
}
static u64 get_corrected_val(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
- u32 rmid, enum resctrl_event_id eventid, u64 msr_val)
+ u32 rmid, enum resctrl_event_id eventid, u64 mon_val)
{
struct rdt_hw_l3_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d);
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
@@ -227,12 +227,12 @@ static u64 get_corrected_val(struct rdt_resource *r, struct rdt_l3_mon_domain *d
am = get_arch_mbm_state(hw_dom, rmid, eventid);
if (am) {
- am->chunks += mbm_overflow_count(am->prev_msr, msr_val,
+ am->chunks += mbm_overflow_count(am->prev_mon_val, mon_val,
hw_res->mbm_width);
chunks = get_corrected_mbm_count(rmid, am->chunks);
- am->prev_msr = msr_val;
+ am->prev_mon_val = mon_val;
} else {
- chunks = msr_val;
+ chunks = mon_val;
}
return chunks * hw_res->mon_scale;
@@ -245,7 +245,7 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
struct rdt_hw_l3_mon_domain *hw_dom;
struct rdt_l3_mon_domain *d;
struct arch_mbm_state *am;
- u64 msr_val;
+ u64 mon_val;
u32 prmid;
int cpu;
int ret;
@@ -262,14 +262,14 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
hw_dom = resctrl_to_arch_mon_dom(d);
cpu = cpumask_any(&hdr->cpu_mask);
prmid = logical_rmid_to_physical_rmid(cpu, rmid);
- ret = __rmid_read_phys(prmid, eventid, &msr_val);
+ ret = __rmid_read_phys(prmid, eventid, &mon_val);
if (!ret) {
- *val = get_corrected_val(r, d, rmid, eventid, msr_val);
+ *val = get_corrected_val(r, d, rmid, eventid, mon_val);
} else if (ret == -EINVAL) {
am = get_arch_mbm_state(hw_dom, rmid, eventid);
if (am)
- am->prev_msr = 0;
+ am->prev_mon_val = 0;
}
return ret;
@@ -324,7 +324,7 @@ void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *d
memset(am, 0, sizeof(*am));
/* Record any initial, non-zero count value. */
- __cntr_id_read(cntr_id, &am->prev_msr);
+ __cntr_id_read(cntr_id, &am->prev_mon_val);
}
}
@@ -332,14 +332,14 @@ int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
u32 unused, u32 rmid, int cntr_id,
enum resctrl_event_id eventid, u64 *val)
{
- u64 msr_val;
+ u64 mon_val;
int ret;
- ret = __cntr_id_read(cntr_id, &msr_val);
+ ret = __cntr_id_read(cntr_id, &mon_val);
if (ret)
return ret;
- *val = get_corrected_val(r, d, rmid, eventid, msr_val);
+ *val = get_corrected_val(r, d, rmid, eventid, mon_val);
return 0;
}
--
2.25.1