[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251022133913.629859-1-zengheng4@huawei.com>
Date: Wed, 22 Oct 2025 21:39:13 +0800
From: Zeng Heng <zengheng4@...wei.com>
To: <james.morse@....com>
CC: <amitsinght@...vell.com>, <baisheng.gao@...soc.com>,
<baolin.wang@...ux.alibaba.com>, <bobo.shaobowang@...wei.com>,
<carl@...amperecomputing.com>, <catalin.marinas@....com>, <dakr@...nel.org>,
<dave.martin@....com>, <david@...hat.com>, <dfustini@...libre.com>,
<fenghuay@...dia.com>, <gregkh@...uxfoundation.org>, <gshan@...hat.com>,
<guohanjun@...wei.com>, <jeremy.linton@....com>,
<jonathan.cameron@...wei.com>, <kobak@...dia.com>, <lcherian@...vell.com>,
<lenb@...nel.org>, <linux-acpi@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<lpieralisi@...nel.org>, <peternewman@...gle.com>, <quic_jiles@...cinc.com>,
<rafael@...nel.org>, <robh@...nel.org>, <rohit.mathew@....com>,
<scott@...amperecomputing.com>, <sdonthineni@...dia.com>,
<sudeep.holla@....com>, <tan.shaopeng@...itsu.com>, <will@...nel.org>,
<xhao@...ux.alibaba.com>, <zengheng4@...wei.com>,
<wangkefeng.wang@...wei.com>
Subject: [PATCH mpam mpam/snapshot/v6.14-rc1] arm64/mpam: Fix MBWU monitor overflow handling
Bandwidth counters need to run continuously to correctly reflect the
bandwidth. When reading the previously configured MSMON_CFG_MBWU_CTL,
software must recognize that the MSMON_CFG_x_CTL_OFLOW_STATUS bit may
have been set by hardware because of the counter overflow.
The existing logic incorrectly treats this bit as an indication that the
monitor configuration has been changed and consequently zeros the MBWU
statistics by mistake.
Also fix the handling of overflow amount calculation. There's no need to
subtract mbwu_state->prev_val when calculating overflow_val.
Signed-off-by: Zeng Heng <zengheng4@...wei.com>
---
drivers/resctrl/mpam_devices.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 0dd048279e02..06f3ec9887d2 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1101,7 +1101,8 @@ static void __ris_msmon_read(void *arg)
clean_msmon_ctl_val(&cur_ctl);
gen_msmon_ctl_flt_vals(m, &ctl_val, &flt_val);
config_mismatch = cur_flt != flt_val ||
- cur_ctl != (ctl_val | MSMON_CFG_x_CTL_EN);
+ (cur_ctl & ~MSMON_CFG_x_CTL_OFLOW_STATUS) !=
+ (ctl_val | MSMON_CFG_x_CTL_EN);
if (config_mismatch || reset_on_next_read)
write_msmon_ctl_flt_vals(m, ctl_val, flt_val);
@@ -1138,8 +1139,9 @@ static void __ris_msmon_read(void *arg)
mbwu_state = &ris->mbwu_state[ctx->mon];
/* Add any pre-overflow value to the mbwu_state->val */
- if (mbwu_state->prev_val > now)
- overflow_val = mpam_msmon_overflow_val(m->type) - mbwu_state->prev_val;
+ if (mbwu_state->prev_val > now &&
+ (cur_ctl & MSMON_CFG_x_CTL_OFLOW_STATUS))
+ overflow_val = mpam_msmon_overflow_val(ris);
mbwu_state->prev_val = now;
mbwu_state->correction += overflow_val;
--
2.25.1
Powered by blists - more mailing lists