From nobody Mon Feb 9 01:17:20 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5657635898; Sat, 25 Oct 2025 09:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761384887; cv=none; b=PGGLFvC3BmgfzBt0yUz6CZh5YgckH3K9B5MMViH67DdKzDgNIDn1J+lKt+kiVBLSKEFsnCdXCs3KcjcsvcwitdFuoy0o8VgQor2XI9W+vXdo2c+AIFJYzMT+nyYngUheKgouFuMU8kHTrDs0MusEKeuUIa4zWFOSqTV3jom26Jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761384887; c=relaxed/simple; bh=LV8sGQ71xsL085epJdSMDWxSQ/YnHemUNu6BoJUcrfU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aOmF2v5hU/c9aBU2oCAcBtSr8wUrvPgkp2Rmz9fzieOG73NACqyD8vVk8XHRXrcRdQyEZ4Ow3F8idzLok/kd8ldof0pi8rb6unBMhhPlAN1K74a0VC8OWFkSODV1W/CjCUy7OMmAAWgkhXcQWNts2ZnB5dMrF6wbchb/fRqNR/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=pI2Ce4vy; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="pI2Ce4vy" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=lKlFKPFWui0rBF7JkALPT4rV4/6BtprmXI6qCc+ucnA=; b=pI2Ce4vySPQvfHaznAABDEnVBnVP5iKVw+xG5yvYh+bN0vv24/CP7qMoFWYrpqHsj4RYoRu3X z+fZXrVao8Lu/FXvBQzyK53O5TTEzH7KrybEvJkIUlmqabHGNXmO4OIA1AuIUmiQNXe9URANqOy cc8GcvVx4i33G4OQvyLozkU= Received: from mail.maildlp.com (unknown [172.19.163.48]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4ctvjW3FDSz1prLt; Sat, 25 Oct 2025 17:34:07 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 3FCA6180087; Sat, 25 Oct 2025 17:34:34 +0800 (CST) Received: from huawei.com (10.50.87.109) by kwepemf100008.china.huawei.com (7.202.181.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 25 Oct 2025 17:34:32 +0800 From: Zeng Heng To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH] arm64/mpam: Clean MBWU monitor overflow bit Date: Sat, 25 Oct 2025 17:34:28 +0800 Message-ID: <20251025093428.1379218-1-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" The MSMON_MBWU register accumulates counts monotonically forward and would not automatically cleared to zero on overflow. The overflow portion is exactly what mpam_msmon_overflow_val() computes, there is no need to additionally subtract mbwu_state->prev_val. Before invoking write_msmon_ctl_flt_vals(), the overflow bit of the MSMON_MBWU register must first be read to prevent it from being inadvertently cleared by the write operation. Then, before updating the monitor configuration, the overflow bit should be cleared to zero. Finally, use the overflow bit instead of relying on counter wrap-around to determine whether an overflow has occurred, that avoids the case where a wrap-around (now > prev_val) is overlooked. Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_devices.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index 0dd048279e02..575980e3a366 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -1062,6 +1062,21 @@ static u64 mpam_msmon_overflow_val(enum mpam_device_= features type) } } =20 +static bool read_msmon_mbwu_is_overflow(struct mpam_msc *msc) +{ + u32 ctl; + bool overflow; + + ctl =3D mpam_read_monsel_reg(msc, CFG_MBWU_CTL); + overflow =3D ctl & MSMON_CFG_x_CTL_OFLOW_STATUS ? true : false; + + if (overflow) + mpam_write_monsel_reg(msc, CFG_MBWU_CTL, ctl & + ~MSMON_CFG_x_CTL_OFLOW_STATUS); + + return overflow; +} + /* Call with MSC lock held */ static void __ris_msmon_read(void *arg) { @@ -1069,6 +1084,7 @@ static void __ris_msmon_read(void *arg) bool config_mismatch; struct mon_read *m =3D arg; u64 now, overflow_val =3D 0; + bool mbwu_overflow =3D false; struct mon_cfg *ctx =3D m->ctx; bool reset_on_next_read =3D false; struct mpam_msc_ris *ris =3D m->ris; @@ -1091,6 +1107,7 @@ static void __ris_msmon_read(void *arg) reset_on_next_read =3D mbwu_state->reset_on_next_read; mbwu_state->reset_on_next_read =3D false; } + mbwu_overflow =3D read_msmon_mbwu_is_overflow(msc); } =20 /* @@ -1138,8 +1155,8 @@ static void __ris_msmon_read(void *arg) mbwu_state =3D &ris->mbwu_state[ctx->mon]; =20 /* Add any pre-overflow value to the mbwu_state->val */ - if (mbwu_state->prev_val > now) - overflow_val =3D mpam_msmon_overflow_val(m->type) - mbwu_state->prev_va= l; + if (mbwu_overflow) + overflow_val =3D mpam_msmon_overflow_val(m->type); =20 mbwu_state->prev_val =3D now; mbwu_state->correction +=3D overflow_val; --=20 2.25.1