[RFC PATCH 2/6] fs/resctrl: Do not update bandwidth from a failed counter read
From: Jinjie Ruan
Date: Mon Nov 09 2026 - 08:39:21 EST
From: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
mbm_update_one_event() reads a monitoring group's counter once per
second and updates the bandwidth used by the MBA software controller
through mbm_bw_count().
When the read fails, rmid_read::err is set and the accumulated counter
value stays zero, but mbm_bw_count() runs anyway. Subtracting the
previous sample from zero wraps to a huge value, which becomes the
group's bandwidth; the controller then moves the control the wrong
way. The failure is reachable with assignable counters, where a group
has no counter for the event once the shared pool is exhausted.
Update the bandwidth only when the read succeeded. A failed read keeps
the previous bandwidth; the counter keeps accumulating, so the next
successful sample spans the failed interval and is larger. The
controller steps down once and recovers on the next round.
Fixes: 2c272fadb58b ("x86/resctrl: Compute memory bandwidth for all supported events")
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # v6.14+
---
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 dbc6770508e6..2319e8e619bd 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -788,10 +788,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.43.0