From: Jinjie Ruan <ruanjinjie01@gmail.com>
To: babu.moger@amd.com, ben.horgan@arm.com, bp@alien8.de,
corbet@lwn.net, Dave.Martin@arm.com, fenghuay@nvidia.com,
james.morse@arm.com, rdunlap@infradead.org,
reinette.chatre@intel.com, skhan@linuxfoundation.org,
tony.luck@intel.com, x86@kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: ruanjinjie@huawei.com
Subject: [RFC PATCH 1/6] fs/resctrl: Avoid division by zero in the MBA software controller
Date: Mon, 9 Nov 2026 21:26:16 +0800 [thread overview]
Message-ID: <20261109132621.3862497-2-ruanjinjie01@gmail.com> (raw)
In-Reply-To: <20261109132621.3862497-1-ruanjinjie01@gmail.com>
From: Jinjie Ruan <ruanjinjie@huawei.com>
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@huawei.com>
---
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
next prev parent reply other threads:[~2026-11-09 13:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 13:26 [RFC PATCH 00/6] resctrl: Support mba_MBps on MPAM Jinjie Ruan
2026-11-09 13:26 ` Jinjie Ruan [this message]
2026-11-09 13:26 ` [RFC PATCH 2/6] fs/resctrl: Do not update bandwidth from a failed counter read Jinjie Ruan
2026-11-09 13:26 ` [RFC PATCH 3/6] fs/resctrl: Take the CPU hotplug lock for software controller updates Jinjie Ruan
2026-11-09 13:26 ` [RFC PATCH 4/6] fs/resctrl: Allow mba_MBps with assignable MBM counters Jinjie Ruan
2026-11-09 13:26 ` [RFC PATCH 5/6] fs/resctrl: Reject mba_MBps when the maximum is only a soft limit Jinjie Ruan
2026-11-09 13:26 ` [RFC PATCH 6/6] arm_mpam: Program the hard limit for the software controller Jinjie Ruan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261109132621.3862497-2-ruanjinjie01@gmail.com \
--to=ruanjinjie01@gmail.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=reinette.chatre@intel.com \
--cc=ruanjinjie@huawei.com \
--cc=skhan@linuxfoundation.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®