From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95640CAC598 for ; Tue, 16 Sep 2025 13:17:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cZaJWa0JCi+wm5lpEPZv4c4wFk88sPicWafUgoZpD9A=; b=uFhkDFPp2XBsFXd7IT22r86roy xeb9g+gtasB0Qh+DkOuXZyZ7XlELPEUZwlKzmB1W31Rg7Z4vuutVwYVojZnPLqmnwy/uGydqGcbJp g3nLP0S4xJM1vc8WTz7lN1qtOFWteMW5N75phWvRtiSc5QKSME9M9iCo/J3r/SGol2aLsr53G5E/i RFSki7XpClsw4pckG+Woq38jWSFqSK4VGcGa7A+IfA4LftuuJeiPpuObXf5jZppBGxfN41w5ajpNj pzc/VdS33T/IoZcjh9brgd52JU4VRsYzi1hmjYSmBVjZ0dGpQuQlG+qVEGodxt81esttedKft/6GY OYsiPA+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uyVZ4-00000007u3f-2Z73; Tue, 16 Sep 2025 13:17:46 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uyVZ1-00000007u0p-0W1h for linux-arm-kernel@lists.infradead.org; Tue, 16 Sep 2025 13:17:45 +0000 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> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemf100008.china.huawei.com (7.202.181.222) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250916_061743_550283_11B50A23 X-CRM114-Status: GOOD ( 13.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 += now; + m->err = 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 = ris; + read_again = false; +again: err = smp_call_function_any(&msc->accessibility, __ris_msmon_read, arg, true); + if (arg->err == -EBUSY && !read_again) { + read_again = true; + + wait_jiffies = usecs_to_jiffies(comp->class->nrdy_usec); + while (wait_jiffies) + wait_jiffies = schedule_timeout_uninterruptible(wait_jiffies); + + goto again; + } + if (!err && arg->err) err = arg->err; if (err) @@ -1218,9 +1233,7 @@ static int _msmon_read(struct mpam_component *comp, struct 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 = 0; struct mpam_props *cprops = &comp->class->props; might_sleep(); @@ -1237,24 +1250,7 @@ int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx, arg.val = val; *val = 0; - err = _msmon_read(comp, &arg); - if (err == -EBUSY && comp->class->nrdy_usec) - wait_jiffies = usecs_to_jiffies(comp->class->nrdy_usec); - - while (wait_jiffies) - wait_jiffies = schedule_timeout_uninterruptible(wait_jiffies); - - if (err == -EBUSY) { - memset(&arg, 0, sizeof(arg)); - arg.ctx = ctx; - arg.type = type; - arg.val = val; - *val = 0; - - err = _msmon_read(comp, &arg); - } - - return err; + return _msmon_read(comp, &arg); } void mpam_msmon_reset_mbwu(struct mpam_component *comp, struct mon_cfg *ctx) -- 2.25.1