[RFC PATCH v2 3/9] fs/resctrl: Do not update bandwidth from a failed counter read

From: Jinjie Ruan

Date: Thu Nov 12 2026 - 08:53:13 EST


Every second, mbm_update_one_event() reads a monitoring group's
counter and passes the result to mbm_bw_count(). When the read fails,
rmid_read::err is set but the value stays zero, and mbm_bw_count()
runs anyway. Subtracting the previous sample from zero wraps to a
huge bandwidth, and the controller moves the control the wrong way.

The read fails when the architecture reports the counter as
unavailable, and, with assignable counters, when the group has no
counter because the shared pool is exhausted.

Update the bandwidth only after a successful read. A failed read keeps
the previous bandwidth; the counter keeps accumulating, so the next
sample spans the failed interval and is larger. The controller steps
down once and recovers in the next round.

Fixes: 30442571ec81 ("x86/resctrl: Calculate bandwidth from the previous __mon_event_count() chunks")
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # v6.1+
---
fs/resctrl/monitor.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index f067329e92c6..49a4b4ce95d4 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -801,10 +801,11 @@ static void mbm_update_one_event(struct rdt_resource *r, struct rdt_l3_mon_domai
__mon_event_count(rdtgrp, &rr);

/*
- * If the software controller is enabled, compute the
- * bandwidth for this event id.
+ * If the software controller is enabled, compute the bandwidth for
+ * this event id. Do not update it when the counter could not be read:
+ * that would store a bogus zero sample as the previous bandwidth.
*/
- if (is_mba_sc(NULL))
+ if (is_mba_sc(NULL) && !rr.err)
mbm_bw_count(rdtgrp, &rr);

if (rr.arch_mon_ctx)
--
2.34.1