[RFC PATCH 1/6] fs/resctrl: Avoid division by zero in the MBA software controller
From: Jinjie Ruan
Date: Mon Nov 09 2026 - 08:28:50 EST
From: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
The software controller estimates the bandwidth after the next step as
cur_bw * (control + min_bw) / control and raises the control while the
target stays above that estimate.
MPAM allows the control to reach zero: its bandwidth control is a
16-bit fraction, so 0% is valid, and its step is non-zero. The
estimate then divides by zero in the MBM overflow worker. On x86 the
minimum equals the step, so the control never leaves zero and the
division is not reached.
Take the step up without evaluating the estimate when the control is
zero. Check first that the target is above the measured bandwidth so a
zero target does not oscillate.
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
fs/resctrl/monitor.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 04e4ea612b7c..dbc6770508e6 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -749,11 +749,15 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_l3_mon_domain *dom_m
* on a system 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.
*/
if (cur_msr_val > r_mba->membw.min_bw && user_bw < cur_bw) {
new_msr_val = cur_msr_val - r_mba->membw.bw_gran;
- } else if (cur_msr_val < MAX_MBA_BW &&
- (user_bw > (cur_bw * (cur_msr_val + r_mba->membw.min_bw) / cur_msr_val))) {
+ } else 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.min_bw) / cur_msr_val))) {
new_msr_val = cur_msr_val + r_mba->membw.bw_gran;
} else {
return;
--
2.43.0