[PATCH v2 11/17] x86/resctrl: Report Unsupported when MBM events are read

From: Babu Moger
Date: Fri Jan 19 2024 - 13:25:35 EST


Hardware reports "Unavailable" when a user tries to read the event when
ABMC is enabled and event is not assigned. "Unavailable" is reported in
other error cases also.

To differentiate these cases, skip reading the event and report
"Unsupported" that way users can take corrective action.

Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v2: New patch based on feedback.
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index beccb0e87ba7..cc4c41eede25 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -542,12 +542,14 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
int rdtgroup_mondata_show(struct seq_file *m, void *arg)
{
struct kernfs_open_file *of = m->private;
+ struct rdt_hw_resource *hw_res;
u32 resid, evtid, domid;
struct rdtgroup *rdtgrp;
struct rdt_resource *r;
union mon_data_bits md;
struct rdt_domain *d;
struct rmid_read rr;
+ int mon_state;
int ret = 0;

rdtgrp = rdtgroup_kn_lock_live(of->kn);
@@ -568,6 +570,19 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
goto out;
}

+ hw_res = resctrl_to_arch_res(r);
+ if (hw_res->abmc_enabled && evtid != QOS_L3_OCCUP_EVENT_ID) {
+ if (evtid == QOS_L3_MBM_TOTAL_EVENT_ID)
+ mon_state = TOTAL_ASSIGN;
+ else
+ mon_state = LOCAL_ASSIGN;
+
+ if (!(rdtgrp->mon.monitor_state & mon_state)) {
+ seq_puts(m, "Unsupported\n");
+ goto out;
+ }
+ }
+
mon_event_read(&rr, r, d, rdtgrp, evtid, false);

if (rr.err == -EIO)
--
2.34.1