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 2/6] fs/resctrl: Do not update bandwidth from a failed counter read
Date: Mon, 9 Nov 2026 21:26:17 +0800 [thread overview]
Message-ID: <20261109132621.3862497-3-ruanjinjie01@gmail.com> (raw)
In-Reply-To: <20261109132621.3862497-1-ruanjinjie01@gmail.com>
From: Jinjie Ruan <ruanjinjie@huawei.com>
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@huawei.com>
Cc: <stable@vger.kernel.org> # 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
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 ` [RFC PATCH 1/6] fs/resctrl: Avoid division by zero in the MBA software controller Jinjie Ruan
2026-11-09 13:26 ` Jinjie Ruan [this message]
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-3-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®