[PATCH 03/12] fs/resctrl: Fix the step-up estimate of the MBA software controller
From: Jinjie Ruan
Date: Sun Nov 29 2026 - 22:25:15 EST
The controller steps up while the target is above the bandwidth expected
after the next step, estimated as:
cur_bw * (control + bw_gran) / control,
but uses min_bw in place of bw_gran.
Intel sets the two equal, and AMD refuses the controller as its MBA is
not linear, so neither is affected. MPAM can be: with a maximum control
of 8 or more bits, min_bw rounds to 0% while bw_gran is 1%. The estimate
then falls back to cur_bw, so the control steps up for any target above
it and oscillates. A zero min_bw also lets the control reach zero, where
the estimate divides by zero in the MBM overflow worker.
Use bw_gran, take the step up directly when the control is zero, and
only step up when the target is above the measured bandwidth.
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
fs/resctrl/monitor.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index ee8e9095f674..4becfe684587 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -673,6 +673,11 @@ static struct rdt_ctrl_domain *get_sc_ctrl_domain_from_cpu(int cpu,
* with 10% granularity steps, check whether moving to 40% would go past
* the limit by multiplying current bandwidth by "(30 + 10) / 30".
*
+ * A zero min_bw lets the control reach zero, where the ratio is
+ * undefined. Take the step up without evaluating it, but only when the
+ * target is above the measured bandwidth: a zero control would otherwise
+ * be raised for a zero target.
+ *
* Return: true when the control value changes, false otherwise.
*/
static bool mba_sc_next_ctrl_val(struct rdt_resource *r_mba, u32 cur_msr_val,
@@ -683,8 +688,8 @@ static bool mba_sc_next_ctrl_val(struct rdt_resource *r_mba, u32 cur_msr_val,
return true;
}
- if (cur_msr_val < MAX_MBA_BW &&
- user_bw > (cur_bw * (cur_msr_val + r_mba->membw.min_bw) / cur_msr_val)) {
+ if (cur_msr_val < MAX_MBA_BW && user_bw > cur_bw && (cur_msr_val == 0 ||
+ user_bw > (cur_bw * (cur_msr_val + r_mba->membw.bw_gran) / cur_msr_val))) {
*new_msr_val = cur_msr_val + r_mba->membw.bw_gran;
return true;
}
--
2.34.1