From nobody Thu Oct 2 13:05:36 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 21DB515A8; Tue, 16 Sep 2025 13:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758028651; cv=none; b=cwMJuB36AyQDSFHsBF0LBlttzY27Q3WcN68qRvSQ07s0Zbq0Nq0oAgOUKwPwsNp65Q+5Ja/4lzVNrSUqmjFDaxHb+rBTltzlaBLwPCq5HeQ18Msw4stzl8cgPM2uwHJbF1u//TXm+rCsY+JByidguH1elOBrY0zTnAhpgv72B0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758028651; c=relaxed/simple; bh=PjMRw6sHcOYLHYj8pf9QThXIPuDyUQgrjK8mOkIlPtg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d1YaVx71EBArO/c2rkTVatDTVNoC4lTu+jKQQMlikEdZ8d1Ky3qr9pFADYreLz6Fs2aC+CSqKdhtw0g0jIjIoq4+zS425/9QxFxp9I90ueuOq36fLmezgXminu0Qt2+T+EByUGLqCYOPCAmn9PjH/K2PmUnDMWuaW1nXMnMqhms= 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; arc=none smtp.client-ip=45.249.212.188 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 Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4cR2Pp2WdlzRkJN; Tue, 16 Sep 2025 21:12:46 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id C7BA91402EB; Tue, 16 Sep 2025 21:17:23 +0800 (CST) Received: from huawei.com (10.175.103.91) 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; Tue, 16 Sep 2025 21:17:22 +0800 From: Zeng Heng To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH] arm_mpam: Try reading again if MPAM instance returns not ready Date: Tue, 16 Sep 2025 21:17:17 +0800 Message-ID: <20250916131717.2980875-1-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250910204309.20751-7-james.morse@arm.com> References: <20250910204309.20751-7-james.morse@arm.com> 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: kwepems200002.china.huawei.com (7.221.188.68) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" After updating the monitor configuration, the first read of the monitoring result requires waiting for the "not ready" duration before an effective value can be obtained. Because a component consists of multiple MPAM instances, after updating the configuration of each instance, should wait for the "not ready" period of per single instance before the valid monitoring value can be obtained, not just wait for once interval per component. Signed-off-by: Zeng Heng --- It's fine to merge this patch directly into patch 7 of the responding patchset. --- drivers/resctrl/mpam_devices.c | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index 2962cd018207..e79a46646863 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -1183,11 +1183,14 @@ static void __ris_msmon_read(void *arg) } *m->val +=3D now; + m->err =3D 0; } static int _msmon_read(struct mpam_component *comp, struct mon_read *arg) { int err, idx; + bool read_again; + u64 wait_jiffies; struct mpam_msc *msc; struct mpam_vmsc *vmsc; struct mpam_msc_ris *ris; @@ -1198,10 +1201,22 @@ static int _msmon_read(struct mpam_component *comp,= struct mon_read *arg) list_for_each_entry_rcu(ris, &vmsc->ris, vmsc_list) { arg->ris =3D ris; + read_again =3D false; +again: err =3D smp_call_function_any(&msc->accessibility, __ris_msmon_read, arg, true); + if (arg->err =3D=3D -EBUSY && !read_again) { + read_again =3D true; + + wait_jiffies =3D usecs_to_jiffies(comp->class->nrdy_usec); + while (wait_jiffies) + wait_jiffies =3D schedule_timeout_uninterruptible(wait_jiffies); + + goto again; + } + if (!err && arg->err) err =3D arg->err; if (err) @@ -1218,9 +1233,7 @@ static int _msmon_read(struct mpam_component *comp, s= truct mon_read *arg) int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx, enum mpam_device_features type, u64 *val) { - int err; struct mon_read arg; - u64 wait_jiffies =3D 0; struct mpam_props *cprops =3D &comp->class->props; might_sleep(); @@ -1237,24 +1250,7 @@ int mpam_msmon_read(struct mpam_component *comp, str= uct mon_cfg *ctx, arg.val =3D val; *val =3D 0; - err =3D _msmon_read(comp, &arg); - if (err =3D=3D -EBUSY && comp->class->nrdy_usec) - wait_jiffies =3D usecs_to_jiffies(comp->class->nrdy_usec); - - while (wait_jiffies) - wait_jiffies =3D schedule_timeout_uninterruptible(wait_jiffies); - - if (err =3D=3D -EBUSY) { - memset(&arg, 0, sizeof(arg)); - arg.ctx =3D ctx; - arg.type =3D type; - arg.val =3D val; - *val =3D 0; - - err =3D _msmon_read(comp, &arg); - } - - return err; + return _msmon_read(comp, &arg); } void mpam_msmon_reset_mbwu(struct mpam_component *comp, struct mon_cfg *ct= x) -- 2.25.1