From patchwork Sat Jan 4 10:12:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zeng Heng X-Patchwork-Id: 13926178 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 7011DE77188 for ; Sat, 4 Jan 2025 10:07:14 +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=pf3p1yxwL7clvdxq1c5cAaA7ibJIsPpx0t8k4P3P/iA=; b=biUhnig7JDBGKtAcvhIMov0Jsk W1ktLBAQKGfPIdEWVa97gmjIaGU9LTHWuv6mqyvBa/IuPXtMFelJIcpT22ZmPaYZb787UDQWscL58 ItjK2e6D1Nf6TBHqXDxOOuVrerpe+lshOlfZRAcqzvBGvXnMZkhaJQOyXHSGSceEKfvbwHhd4QIpG THO6dXcpDeRKcRlHZ3YGJncEA3Enij4VSJ97p6/AOp0fpgiuMkIknleg9O3tsEs7EmG2Y5IkBLqKS RoxBOraf7Dr2Hli5nv5kG/FuRG/akRmFJyF4H65/NjZJxcF8QPzTzYImnePKXWNqLmtKeCg1vUtqg 9pU3ZSKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tU13g-0000000EqCw-1cGl; Sat, 04 Jan 2025 10:07:04 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tU0xv-0000000EpXi-0uAk for linux-arm-kernel@lists.infradead.org; Sat, 04 Jan 2025 10:01:10 +0000 Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YQGCT4XFNz1JGgr; Sat, 4 Jan 2025 18:00:21 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 97DCF14011D; Sat, 4 Jan 2025 18:01:02 +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; Sat, 4 Jan 2025 18:01:01 +0800 From: Zeng Heng To: , CC: , , , Subject: [RFC PATCH mpam mpam/snapshot/v6.12-rc1 v4 1/5] arm_mpam: Introduce the definitions of intPARTID and reqPARTID Date: Sat, 4 Jan 2025 18:12:20 +0800 Message-ID: <20250104101224.873926-2-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250104101224.873926-1-zengheng4@huawei.com> References: <20250104101224.873926-1-zengheng4@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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-20250104_020107_572130_9CCADB96 X-CRM114-Status: GOOD ( 18.00 ) 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 The narrow-partid feature in MPAM allows for a more efficient use of PARTIDs by enabling a many-to-one mapping of reqpartids (requested PARTIDs) to intpartids (internal PARTIDs). This mapping reduces the number of unique PARTIDs needed, thus allowing more tasks or processes to be monitored and managed with the available resources. Regarding intPARTID, MPAM uses it as the unit for control group configuration delivery. MPAM will synchronize the delivered configuration to all reqPARTIDs mapped to the same intPARTIDs. The number of intPARTIDs is indicated by MPAMF_PARTID_NRW_IDR.INTPARTID_MAX if implemented, or directly use the number of PARTID as intpartid_max if narrow-partid feature is not supported. reqPARTIDs can be used to expand the number of monitors, for each control group is no longer simply restricted by the range of PMG. By mapping between intPARTID and reqPARTID, the number of monitors would be greatly expanded and more fine-grained monitoring under a control group will be achieved. As a MPAM driver applicable to general scenarios, it needs to be compatible with systems not supporting narrow-partid and mixed MSCs (some MSCs support narrow-partid and some do not) systems. We determine the number of closids in the following manner: reqPARTID-np -- The number of reqPARTIDs supported by MSCs that support narrow-partid. intPARTID-np -- The number of intPARTIDs supported by MSCs that support narrow partid. PARTID-nnp -- The number of PARTIDs supported by MSCs that do not support narrow partid. n - Indicates the maximum number of control groups l - Represents the total number of reqpartids m - Indicates the number of reqpartids per control group n = min(intPARTID-np, PARTID-nnp) l = min(reqPARTID-np, PARTID-nnp) m = l // n To illustrate how to determine n, l, and m through examples, we can assume a specific example: l3 - Does not support the narrow PARTID feature, supports a range of 256 PARTIDs. mata - Supports the narrow-partid feature, supports 32 intPARTIDs, and supports 256 reqPARTIDs. Then, n = min(PARTID-l3, intPARTID-mata) = min(256, 32) = 32 l = min(PARTID-l3, reqPARTID-mata) = min(256,256) = 256 m = 256 / 32 = 8 After initialization, the driver determines the 'n' parameter returned by resctrl_arch_get_num_closid() and the 'l' parameter returned by get_num_reqpartid(). Signed-off-by: Zeng Heng --- drivers/platform/arm64/mpam/mpam_devices.c | 12 +++++++++++- drivers/platform/arm64/mpam/mpam_internal.h | 2 ++ drivers/platform/arm64/mpam/mpam_resctrl.c | 9 +++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/platform/arm64/mpam/mpam_devices.c b/drivers/platform/arm64/mpam/mpam_devices.c index 9463045c0011..ca621bb132e9 100644 --- a/drivers/platform/arm64/mpam/mpam_devices.c +++ b/drivers/platform/arm64/mpam/mpam_devices.c @@ -67,6 +67,7 @@ static DEFINE_MUTEX(mpam_cpuhp_state_lock); * Generating traffic outside this range will result in screaming interrupts. */ u16 mpam_partid_max; +u16 mpam_intpartid_max; u8 mpam_pmg_max; static bool partid_max_init, partid_max_published; static DEFINE_SPINLOCK(partid_max_lock); @@ -222,10 +223,16 @@ int mpam_register_requestor(u16 partid_max, u8 pmg_max) spin_lock(&partid_max_lock); if (!partid_max_init) { mpam_partid_max = partid_max; + /* + * Update mpam_intpartid_max here, in case the + * system doesn't have narrow-partid feature. + */ + mpam_intpartid_max = partid_max; mpam_pmg_max = pmg_max; partid_max_init = true; } else if (!partid_max_published) { mpam_partid_max = min(mpam_partid_max, partid_max); + mpam_intpartid_max = min(mpam_intpartid_max, partid_max); mpam_pmg_max = min(mpam_pmg_max, pmg_max); } else { /* New requestors can't lower the values */ @@ -984,7 +991,9 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris) u16 partid_max = FIELD_GET(MPAMF_PARTID_NRW_IDR_INTPARTID_MAX, nrwidr); mpam_set_feature(mpam_feat_partid_nrw, props); - msc->partid_max = min(msc->partid_max, partid_max); + msc->intpartid_max = min(msc->partid_max, partid_max); + } else { + msc->intpartid_max = msc->partid_max; } mpam_mon_sel_outer_unlock(msc); @@ -1046,6 +1055,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc) spin_lock(&partid_max_lock); mpam_partid_max = min(mpam_partid_max, msc->partid_max); + mpam_intpartid_max = min(mpam_intpartid_max, msc->intpartid_max); mpam_pmg_max = min(mpam_pmg_max, msc->pmg_max); spin_unlock(&partid_max_lock); diff --git a/drivers/platform/arm64/mpam/mpam_internal.h b/drivers/platform/arm64/mpam/mpam_internal.h index 5af6ed60272e..5fc9f09b6945 100644 --- a/drivers/platform/arm64/mpam/mpam_internal.h +++ b/drivers/platform/arm64/mpam/mpam_internal.h @@ -86,6 +86,7 @@ struct mpam_msc bool error_irq_requested; bool error_irq_hw_enabled; u16 partid_max; + u16 intpartid_max; u8 pmg_max; unsigned long ris_idxs[128 / BITS_PER_LONG]; u32 ris_max; @@ -466,6 +467,7 @@ static inline void mpam_assert_srcu_read_lock_held(void) /* System wide partid/pmg values */ extern u16 mpam_partid_max; +extern u16 mpam_intpartid_max; extern u8 mpam_pmg_max; /* Scheduled work callback to enable mpam once all MSC have been probed */ diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/arm64/mpam/mpam_resctrl.c index 76ddbce0ea9c..ac3d228befcf 100644 --- a/drivers/platform/arm64/mpam/mpam_resctrl.c +++ b/drivers/platform/arm64/mpam/mpam_resctrl.c @@ -162,6 +162,11 @@ static bool mpam_resctrl_hide_cdp(enum resctrl_res_level rid) * only the system wide safe value is safe to use. */ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) +{ + return mpam_intpartid_max + 1; +} + +static u32 get_num_reqpartid(void) { return mpam_partid_max + 1; } @@ -169,9 +174,9 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) u32 resctrl_arch_system_num_rmid_idx(void) { u8 closid_shift = fls(mpam_pmg_max); - u32 num_partid = resctrl_arch_get_num_closid(NULL); + u32 num_reqpartid = get_num_reqpartid(); - return num_partid << closid_shift; + return num_reqpartid << closid_shift; } u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) From patchwork Sat Jan 4 10:12:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zeng Heng X-Patchwork-Id: 13926175 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 83AC1E77188 for ; Sat, 4 Jan 2025 10:03:44 +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=KK/XAkytN7SLMOdq6GNZZM30GbqCrqfsnra80chxLZI=; b=afm4iYxawNvbFmOkBM57DzZt49 y3ztd+cHTJz5O2R9QblXTegNaLU6mgm67XMWplwgozI5Sw9bIiYtUNzWUJmU7xTLkJ3ZUbcrhXGZj OsJUeeemTJp8od3q5/5b8ksz0/80oW6D1Ir74sP8sUFrw5y9wwClH9nq+czQTFkmxsr5ziFMp6bnP FxlPMtRX1hlw3KHBdxoyMyOqJTlexnq/ctZxBXVfsAI/NXhuHTS+TPNpudRQ/C4vVR40TrS1cINlH odI1MsrPV1bJt1CN+hd3y9sPevg34FCAFdt1BKq4EiSUZUyaWOb43vp/onu4FfUJNu2pt71ZTzOQr /fbnSS0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tU10G-0000000Epth-3rIj; Sat, 04 Jan 2025 10:03:32 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tU0xu-0000000EpXh-2rLQ for linux-arm-kernel@lists.infradead.org; Sat, 04 Jan 2025 10:01:10 +0000 Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4YQGDj0qwPz20n5Y; Sat, 4 Jan 2025 18:01:25 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 33FB21402C7; Sat, 4 Jan 2025 18:01:03 +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; Sat, 4 Jan 2025 18:01:02 +0800 From: Zeng Heng To: , CC: , , , Subject: [RFC PATCH mpam mpam/snapshot/v6.12-rc1 v4 2/5] arm_mpam: Add limitation for the Narrow-PARTID feature Date: Sat, 4 Jan 2025 18:12:21 +0800 Message-ID: <20250104101224.873926-3-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250104101224.873926-1-zengheng4@huawei.com> References: <20250104101224.873926-1-zengheng4@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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-20250104_020106_902854_DD9A6B91 X-CRM114-Status: GOOD ( 14.77 ) 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 Because it needs to support mixed systems that include MSCs with and without Narrow-PARTID support, there are the following incompatible control issues. If an MSC does not support Narrow-PARTID and its control method is not of the "partition bitmap" type, then delivering the resctrl control group configuration across multiple PARTIDs will change the user's expected behavior. Currently, there is no way to solve this problem by programming different control values simply, so here decide to restrict the usage scenarios of this feature. When we find that the MATA MSC does not support the Narrow-PARTID feature, the driver will disable the feature, which means get_num_reqpartid() directly returns the number of intPARTIDs. Signed-off-by: Zeng Heng --- drivers/platform/arm64/mpam/mpam_resctrl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/arm64/mpam/mpam_resctrl.c index ac3d228befcf..b9a33001916b 100644 --- a/drivers/platform/arm64/mpam/mpam_resctrl.c +++ b/drivers/platform/arm64/mpam/mpam_resctrl.c @@ -168,6 +168,21 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) static u32 get_num_reqpartid(void) { + struct mpam_resctrl_res *res; + struct rdt_resource *r_mba; + struct mpam_props *cprops; + + r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA); + res = container_of(r_mba, struct mpam_resctrl_res, resctrl_res); + cprops = &res->class->props; + + /* + * If the MBA does not support Narrow-PARTID, + * then the feature should be disabled at the system level. + */ + if (!mpam_has_feature(mpam_feat_partid_nrw, cprops)) + return resctrl_arch_get_num_closid(NULL); + return mpam_partid_max + 1; } From patchwork Sat Jan 4 10:12:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zeng Heng X-Patchwork-Id: 13926177 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 E7E80E77197 for ; Sat, 4 Jan 2025 10:06:06 +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-Transfer-Encoding: Content-Type: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=ZTg0WQwY2H6K8bWHKgRdkl/IAS/FPcxjG4kq4IYr3t8=; b=2YxjaUKQvcaqjwPcv5w9dSPmOI bWANjkdBEpR2ze4w2oUXOxxnbzUYw+0Gwg7iuFd69uxAf1oJroMXW3cNHPOtqbNHeM4wC11D4wN+1 eqkD/UHd6vg6RLHhyvGhnm+SLbpDvH8D+vc1+j3cMuZsfsP6uV9q4OAHKY1V5KlKXShQyiqv0ORBI iJJnmdsCgS4odeO7gojBFrDiu2boJFyIla5ftpqlM+hly+LALFqVV4EwFt1qvvPcpArNfmtqz+P7y hddtbPu4ZZUs9MJ68ondtba1RBTCCE81GMR8wa6LeHKU+POEhauNTNcPyVMPIhNDhEDyhjaVaJ+Jn 2/K1z+hA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tU12Y-0000000Eq6e-0zTj; Sat, 04 Jan 2025 10:05:54 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tU0xu-0000000EpXg-2rGl for linux-arm-kernel@lists.infradead.org; Sat, 04 Jan 2025 10:01:10 +0000 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4YQGDj5Qfdz20n8F; Sat, 4 Jan 2025 18:01:25 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id D1D6E1A0188; Sat, 4 Jan 2025 18:01:03 +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; Sat, 4 Jan 2025 18:01:03 +0800 From: Zeng Heng To: , CC: , , , Subject: [RFC PATCH mpam mpam/snapshot/v6.12-rc1 v4 3/5] arm_mpam: Provide conversion method for new closid/rmid pairs Date: Sat, 4 Jan 2025 18:12:22 +0800 Message-ID: <20250104101224.873926-4-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250104101224.873926-1-zengheng4@huawei.com> References: <20250104101224.873926-1-zengheng4@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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-20250104_020107_065668_7E22C35F X-CRM114-Status: GOOD ( 19.73 ) 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 The MPAM driver statically assigns all reqPARTIDs to respective intPARTIDs. For the new rmid allocation strategy, it will check if there is an available rmid of any reqPARTID which belongs to the input closid, not just the rmids belonging to the closid. For a mixture of MSCs system, for MSCs that do not support narrow-partid, we use the PARTIDs exceeding the number of closids as reqPARTIDs for expanding the monitoring groups. In order to keep the existing resctrl API interface, the rmid contains both req_idx and PMG information instead of PMG only under the MPAM driver. The req_idx represents the req_idx-th sub-monitoring group under the control group. The new rmid would be like: rmid = (req_idx << shift | pmg). The mapping relationships between each group's closid/rmid and the respective MSCs' intPARTID/reqPARTID/PARTID are illustrated: n - Indicates the total number of intPARTIDs m - Indicates the number of reqPARTIDs per intPARTID P - Partition group (control group) M - Monitoring group Group closid rmid.req_idx PARTID MSCs with narrow-partid MSCs without narrow-partid P1 0 - 0 intPARTID_1 PARTID_1 M1_1 0 0 0 ├── reqPARTID_1_1 ├── PARTID_1_1 M1_2 0 1 0+n ├── reqPARTID_1_2 ├── PARTID_1_2 M1_3 0 2 0+n*2 ├── reqPARTID_1_3 ├── PARTID_1_3 ... ├── ... ├── ... M1_m 0 (m-1) 0+n*(m-1) └── reqPARTID_1_m └── PARTID_1_m P2 1 - 1 intPARTID_2 PARTID_2 M2_1 1 0 1 ├── reqPARTID_2_1 ├── PARTID_2_1 M2_2 1 1 1+n ├── reqPARTID_2_2 ├── PARTID_2_2 M2_3 1 2 1+n*2 ├── reqPARTID_2_3 ├── PARTID_2_3 ... ├── ... ├── ... M2_m 1 (m-1) 1+n*(m-1) └── reqPARTID_2_m └── PARTID_2_m Pn (n-1) - (n-1) intPARTID_n PARTID_n Mn_1 (n-1) 0 (n-1) ├── reqPARTID_n_1 ├── PARTID_n_1 Mn_2 (n-1) 1 (n-1)+n ├── reqPARTID_n_2 ├── PARTID_n_2 Mn_3 (n-1) 2 (n-1)+n*2 ├── reqPARTID_n_3 ├── PARTID_n_3 ... ├── ... ├── ... Mn_m (n-1) (m-1) (n-1)+n*(m-1) = n*m-1 └── reqPARTID_n_m └── PARTID_n_m Based on the example provided, the conversion relationship between closid/rmid and (req)PARTID/PMG is: (req)PARTID = (rmid.req_idx * n) + intPARTID PMG = rmid.pmg and still, intPARTID = resctrl_get_config_index(closid, resctrl_conf_type) The resctrl layer uses the new conversion functions(closid_rmid2reqpartid() and rmid2pmg() respectively) to gain the new (req)PARTID/PMG pair. It can be noted that the approach of allocating the first n IDs to intPARTIDs keeps the existing conversion between closid and intPARTID. We still use the resctrl_get_config_index() for conversion, maintaining the original semantics during the MPAM configuration updating. Essentially, the narrowing feature is an enhanced monitoring feature, we only expand the definition of rmid, while reqPARTID is only used in monitoring-related processes. Now each control group has m (req)PARTIDs, which are used to expand the number of monitoring groups under one control group. Therefore, the number of monitoring groups is no longer limited by the range of MPAM's PMG, which enhances the extensibility of the system's monitoring capabilities. Signed-off-by: Zeng Heng --- drivers/platform/arm64/mpam/mpam_resctrl.c | 128 +++++++++++++++------ 1 file changed, 95 insertions(+), 33 deletions(-) diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/arm64/mpam/mpam_resctrl.c index b9a33001916b..064332e62c4d 100644 --- a/drivers/platform/arm64/mpam/mpam_resctrl.c +++ b/drivers/platform/arm64/mpam/mpam_resctrl.c @@ -186,6 +186,11 @@ static u32 get_num_reqpartid(void) return mpam_partid_max + 1; } +static u32 get_num_reqpartid_per_closid(void) +{ + return get_num_reqpartid() / resctrl_arch_get_num_closid(NULL); +} + u32 resctrl_arch_system_num_rmid_idx(void) { u8 closid_shift = fls(mpam_pmg_max); @@ -194,24 +199,73 @@ u32 resctrl_arch_system_num_rmid_idx(void) return num_reqpartid << closid_shift; } +/* + * Under MPAM driver, the rmid contains two pieces of information: one is + * req_idx, and the other is pmg. Therefore, + * closid_shift = req_shift + pmg_shift. + */ u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) { - u8 closid_shift = fls(mpam_pmg_max); + u32 rmid_mask; + u8 closid_shift; + u8 pmg_shift = fls(mpam_pmg_max); + u8 req_shift = fls(get_num_reqpartid_per_closid() - 1); + + closid_shift = req_shift + pmg_shift; + rmid_mask = ~(~0 << closid_shift); BUG_ON(closid_shift > 8); - return (closid << closid_shift) | rmid; + return (closid << closid_shift) | (rmid & rmid_mask); } void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid) { - u8 closid_shift = fls(mpam_pmg_max); - u32 pmg_mask = ~(~0 << closid_shift); + u32 rmid_mask; + u8 closid_shift; + u8 pmg_shift = fls(mpam_pmg_max); + u8 req_shift = fls(get_num_reqpartid_per_closid() - 1); + + closid_shift = req_shift + pmg_shift; + rmid_mask = ~(~0 << closid_shift); BUG_ON(closid_shift > 8); - *closid = idx >> closid_shift; - *rmid = idx & pmg_mask; + if (closid) + *closid = idx >> closid_shift; + if (rmid) + *rmid = idx & rmid_mask; +} + +static u32 closid_rmid2reqpartid(u32 closid, u32 rmid) +{ + u32 intpartid; + u8 pmg_shift = fls(mpam_pmg_max); + u32 req_idx = (rmid >> pmg_shift); + u8 intpartid_shift = fls(mpam_intpartid_max); + + if (!cdp_enabled) + intpartid = resctrl_get_config_index(closid, CDP_NONE); + else + intpartid = resctrl_get_config_index(closid, CDP_DATA); + + return (req_idx << intpartid_shift) | intpartid; +} + +static u32 rmid2pmg(u32 rmid) +{ + u8 pmg_shift = fls(mpam_pmg_max); + u32 pmg_mask = ~(~0 << pmg_shift); + + return rmid & pmg_mask; +} + +static u32 req2intpartid(u32 reqpartid) +{ + u8 intpartid_shift = fls(mpam_intpartid_max); + u32 intpartid_mask = ~(~0 << intpartid_shift); + + return reqpartid & intpartid_mask; } void resctrl_arch_sched_in(struct task_struct *tsk) @@ -223,20 +277,24 @@ void resctrl_arch_sched_in(struct task_struct *tsk) void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid) { - BUG_ON(closid > U16_MAX); - BUG_ON(rmid > U8_MAX); + u32 reqpartid = closid_rmid2reqpartid(closid, rmid); + u32 pmg = rmid2pmg(rmid); + u32 partid_d, partid_i; + + BUG_ON(reqpartid > U16_MAX); + BUG_ON(pmg > U8_MAX); if (!cdp_enabled) { - mpam_set_cpu_defaults(cpu, closid, closid, rmid, rmid); + mpam_set_cpu_defaults(cpu, reqpartid, reqpartid, pmg, pmg); } else { /* * When CDP is enabled, resctrl halves the closid range and we * use odd/even partid for one closid. */ - u32 partid_d = resctrl_get_config_index(closid, CDP_DATA); - u32 partid_i = resctrl_get_config_index(closid, CDP_CODE); + partid_d = reqpartid; + partid_i = reqpartid + 1; - mpam_set_cpu_defaults(cpu, partid_d, partid_i, rmid, rmid); + mpam_set_cpu_defaults(cpu, partid_d, partid_i, pmg, pmg); } } @@ -256,41 +314,45 @@ void resctrl_arch_sync_cpu_closid_rmid(void *info) void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid) { - BUG_ON(closid > U16_MAX); - BUG_ON(rmid > U8_MAX); + u32 reqpartid = closid_rmid2reqpartid(closid, rmid); + u32 pmg = rmid2pmg(rmid); + u32 partid_d, partid_i; + + BUG_ON(reqpartid > U16_MAX); + BUG_ON(pmg > U8_MAX); if (!cdp_enabled) { - mpam_set_task_partid_pmg(tsk, closid, closid, rmid, rmid); + mpam_set_task_partid_pmg(tsk, reqpartid, reqpartid, pmg, pmg); } else { - u32 partid_d = resctrl_get_config_index(closid, CDP_DATA); - u32 partid_i = resctrl_get_config_index(closid, CDP_CODE); + partid_d = reqpartid; + partid_i = partid_d + 1; - mpam_set_task_partid_pmg(tsk, partid_d, partid_i, rmid, rmid); + mpam_set_task_partid_pmg(tsk, partid_d, partid_i, pmg, pmg); } } bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid) { u64 regval = mpam_get_regval(tsk); - u32 tsk_closid = FIELD_GET(MPAM1_EL1_PARTID_D, regval); + u32 tsk_partid = FIELD_GET(MPAM1_EL1_PARTID_D, regval); + + tsk_partid = req2intpartid(tsk_partid); if (cdp_enabled) - tsk_closid >>= 1; + tsk_partid >>= 1; - return tsk_closid == closid; + return tsk_partid == closid; } /* The task's pmg is not unique, the partid must be considered too */ bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid) { u64 regval = mpam_get_regval(tsk); - u32 tsk_closid = FIELD_GET(MPAM1_EL1_PARTID_D, regval); - u32 tsk_rmid = FIELD_GET(MPAM1_EL1_PMG_D, regval); - - if (cdp_enabled) - tsk_closid >>= 1; + u32 tsk_pmg = FIELD_GET(MPAM1_EL1_PMG_D, regval); + u32 tsk_partid = FIELD_GET(MPAM1_EL1_PARTID_D, regval); - return (tsk_closid == closid) && (tsk_rmid == rmid); + return (tsk_partid == closid_rmid2reqpartid(closid, rmid)) && + (tsk_pmg == rmid2pmg(rmid)); } struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) @@ -412,7 +474,7 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d, cfg.mon = resctrl_arch_rmid_idx_encode(closid, rmid); cfg.match_pmg = true; - cfg.pmg = rmid; + cfg.pmg = rmid2pmg(rmid); cfg.opts = resctrl_evt_config_to_mpam(dom->mbm_local_evt_cfg); if (irqs_disabled()) { @@ -420,7 +482,7 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d, err = -EIO; } else { if (cdp_enabled) { - cfg.partid = closid << 1; + cfg.partid = closid_rmid2reqpartid(closid, rmid); err = mpam_msmon_read(dom->comp, &cfg, type, val); if (err) return err; @@ -430,7 +492,7 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d, if (!err) *val += cdp_val; } else { - cfg.partid = closid; + cfg.partid = closid_rmid2reqpartid(closid, rmid); err = mpam_msmon_read(dom->comp, &cfg, type, val); } } @@ -449,18 +511,18 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d, cfg.mon = resctrl_arch_rmid_idx_encode(closid, rmid); cfg.match_pmg = true; - cfg.pmg = rmid; + cfg.pmg = rmid2pmg(rmid); dom = container_of(d, struct mpam_resctrl_dom, resctrl_mon_dom); if (cdp_enabled) { - cfg.partid = closid << 1; + cfg.partid = closid_rmid2reqpartid(closid, rmid); mpam_msmon_reset_mbwu(dom->comp, &cfg); cfg.partid += 1; mpam_msmon_reset_mbwu(dom->comp, &cfg); } else { - cfg.partid = closid; + cfg.partid = closid_rmid2reqpartid(closid, rmid); mpam_msmon_reset_mbwu(dom->comp, &cfg); } } From patchwork Sat Jan 4 10:12:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zeng Heng X-Patchwork-Id: 13926179 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 2AD76E77197 for ; Sat, 4 Jan 2025 10:08:28 +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=P2E7xqnCjNDMrY4c8PkIGqRI88xAe9s6dstqytTnSo0=; b=eT6f/LkK8bsGQAP62diFxoco7t f6CWbTbDH6zFqKKz34hKoSN+nxGVIslZLkx0Tvn7SyIa0HG6IGciNbk3Wc4ynD/MJwVtq/J97VcW2 VyyM8gSCFFslm3P9evNKVvhKZjuU9Q6VXhT+ddveETIe3JSKcZlpG9oRNqSTR2NDwbez++5gAzX2X Cwp+Wyntdyyyb2mfKOoorsDBGtuEfBWuccfi9qroLO0KMBPTpcm/wm6dshCPtgQ+Wux2wUL/7AcPN /qWKyOMHWh2KtWoC21I0f3gR163BVIF0Yi15YyLXkmS2U7AxW4Jds/ldOKaUT9kXDlG6lF/KWqLGU YfitcmJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tU14n-0000000EqKN-4BhU; Sat, 04 Jan 2025 10:08:14 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tU0y0-0000000EpZ6-0Njd for linux-arm-kernel@lists.infradead.org; Sat, 04 Jan 2025 10:01:13 +0000 Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YQG9205cqz11RlV; Sat, 4 Jan 2025 17:58:14 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 78E9E1401F3; Sat, 4 Jan 2025 18:01:04 +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; Sat, 4 Jan 2025 18:01:03 +0800 From: Zeng Heng To: , CC: , , , Subject: [RFC PATCH mpam mpam/snapshot/v6.12-rc1 v4 4/5] arm_mpam: Set INTERNAL as needed when setting MSC controls Date: Sat, 4 Jan 2025 18:12:23 +0800 Message-ID: <20250104101224.873926-5-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250104101224.873926-1-zengheng4@huawei.com> References: <20250104101224.873926-1-zengheng4@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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-20250104_020112_470852_E33AC5D6 X-CRM114-Status: GOOD ( 13.08 ) 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 From: Dave Martin Currently, when an MSC implements PARTID narrowing, MPAMCFG_PART_SEL is left set to the reqPARTID while programming resource controls in an MSC. The MPAM architecture does not guarantee that any particular resource controls will be updated correctly in this scenario. Instead, MPAMCFG_PART_SEL must be written with the corresponding intPARTID and with the INTERNAL bit set before attempting to program resource controls. Only the PARTID->intPARTID mappings can be written without the INTERNAL bit set in MPAMCFG_PART_SEL. Fix it, by rewriting MPAMCFG_PART_SEL appropriately after setting the intPARTID mapping. The MPAMCFG_INTPARTID_INTERNAL flag is not currently accepted as input to the __mpam_part_sel() helper. In the interest of keeping the code clean, break this helper up. Signed-off-by: Dave Martin Signed-off-by: James Morse --- drivers/platform/arm64/mpam/mpam_devices.c | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/platform/arm64/mpam/mpam_devices.c b/drivers/platform/arm64/mpam/mpam_devices.c index ca621bb132e9..781c9146718d 100644 --- a/drivers/platform/arm64/mpam/mpam_devices.c +++ b/drivers/platform/arm64/mpam/mpam_devices.c @@ -205,15 +205,27 @@ static u64 mpam_msc_read_esr(struct mpam_msc *msc) return (esr_high << 32) | esr_low; } +static void __mpam_part_sel_raw(u32 partsel, struct mpam_msc *msc) +{ + lockdep_assert_held(&msc->part_sel_lock); + mpam_write_partsel_reg(msc, PART_SEL, partsel); +} + static void __mpam_part_sel(u8 ris_idx, u16 partid, struct mpam_msc *msc) { - u32 partsel; + u32 partsel = FIELD_PREP(MPAMCFG_PART_SEL_RIS, ris_idx) | + FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, partid); - lockdep_assert_held(&msc->part_sel_lock); + __mpam_part_sel_raw(partsel, msc); +} - partsel = FIELD_PREP(MPAMCFG_PART_SEL_RIS, ris_idx) | - FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, partid); - mpam_write_partsel_reg(msc, PART_SEL, partsel); +static void __mpam_intpart_sel(u8 ris_idx, u16 intpartid, struct mpam_msc *msc) +{ + u32 partsel = FIELD_PREP(MPAMCFG_PART_SEL_RIS, ris_idx) | + FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, intpartid) | + MPAMCFG_PART_SEL_INTERNAL; + + __mpam_part_sel_raw(partsel, msc); } int mpam_register_requestor(u16 partid_max, u8 pmg_max) @@ -1540,9 +1552,11 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, mutex_lock(&msc->part_sel_lock); __mpam_part_sel(ris->ris_idx, partid, msc); - if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) + if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) { mpam_write_partsel_reg(msc, INTPARTID, MPAMCFG_INTPARTID_INTERNAL | partid); + __mpam_intpart_sel(ris->ris_idx, partid, msc); + } if (mpam_has_feature(mpam_feat_cpor_part, rprops)) { if (mpam_has_feature(mpam_feat_cpor_part, cfg)) From patchwork Sat Jan 4 10:12:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zeng Heng X-Patchwork-Id: 13926176 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 EAC10E77188 for ; Sat, 4 Jan 2025 10:04:54 +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=YT202vcWMtp+2EKqxrAjO7FcKgkCVDe2nROTIesZeCA=; b=Ay4ujLWfrfCOAZqgCQhZ3TrKLd j7JDTzhfdluGQSS0RRgMCqoIzQdAP8on3YTGfd722Kn1fvVQF8ktZGSqiXhNVI9GwcWPCpoo5y5cl sR1+18K/wAlPsYYxI+5a74AvMz+/1kZcsjX/wEtkp4joAfxKfc1IoOZcCZrnyLPUM4galeHYmOOsv pV9iDQFG+P36bYyyT+4e7mqoZDDXtijE5wPLhZ3tk10mKa6SS36n7p90zfeHgQCo2mjRn/Jb0EK0x 8wjxE8NldQIIG1jaxZx5WYQBwKkL74Q0N0qfoM9hQHNNezkl6o/xdrsomreCMIh5ofm5IaUzsBOFZ i83vaBsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tU11P-0000000Eq0R-2War; Sat, 04 Jan 2025 10:04:43 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tU0xu-0000000EpXk-2rST for linux-arm-kernel@lists.infradead.org; Sat, 04 Jan 2025 10:01:10 +0000 Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YQG9p2lz3z22kPr; Sat, 4 Jan 2025 17:58:54 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 1A8F91A016C; Sat, 4 Jan 2025 18:01:05 +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; Sat, 4 Jan 2025 18:01:04 +0800 From: Zeng Heng To: , CC: , , , Subject: [RFC PATCH mpam mpam/snapshot/v6.12-rc1 v4 5/5] arm_mpam: Automatically synchronize the configuration of all sub-monitoring groups Date: Sat, 4 Jan 2025 18:12:24 +0800 Message-ID: <20250104101224.873926-6-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250104101224.873926-1-zengheng4@huawei.com> References: <20250104101224.873926-1-zengheng4@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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-20250104_020107_030775_D5B7AECF X-CRM114-Status: GOOD ( 14.62 ) 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 the system expands the narrow-partid feature and statically assigns all (req)PARTIDs to each control group, the following scenarios require configuration synchronization operations: 1. MSCs that support narrow-partid need to establish a mapping between reqPARTID and intPARTID after creating a new monitoring group. 2. MSCs that do not support narrow-partid need to synchronize the configuration of sub-monitoring groups after users update the control group configuration. In __write_config(), we synchronize a control group's configuration to each sub-monitoring group. Signed-off-by: Zeng Heng --- drivers/platform/arm64/mpam/mpam_devices.c | 25 ++++++++++++++++++--- drivers/platform/arm64/mpam/mpam_internal.h | 3 +++ drivers/platform/arm64/mpam/mpam_resctrl.c | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/platform/arm64/mpam/mpam_devices.c b/drivers/platform/arm64/mpam/mpam_devices.c index 781c9146718d..91c5849f76e3 100644 --- a/drivers/platform/arm64/mpam/mpam_devices.c +++ b/drivers/platform/arm64/mpam/mpam_devices.c @@ -1544,6 +1544,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, u32 pri_val = 0; u16 cmax = MPAMCFG_CMAX_CMAX; u16 bwa_fract = MPAMCFG_MBW_MAX_MAX; + u16 intpartid = req2intpartid(partid); struct mpam_msc *msc = ris->vmsc->msc; struct mpam_props *rprops = &ris->props; u16 dspri = GENMASK(rprops->dspri_wd, 0); @@ -1554,8 +1555,14 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) { mpam_write_partsel_reg(msc, INTPARTID, - MPAMCFG_INTPARTID_INTERNAL | partid); - __mpam_intpart_sel(ris->ris_idx, partid, msc); + MPAMCFG_INTPARTID_INTERNAL | + intpartid); + + /* Already finish mapping reqPARTID to intPARTID */ + if (partid != intpartid) + goto out; + + __mpam_intpart_sel(ris->ris_idx, intpartid, msc); } if (mpam_has_feature(mpam_feat_cpor_part, rprops)) { @@ -1615,6 +1622,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, mpam_quirk_post_config_change(ris, partid, cfg); +out: mutex_unlock(&msc->part_sel_lock); } @@ -3072,9 +3080,20 @@ struct mpam_write_config_arg { static int __write_config(void *arg) { + int closid_num = resctrl_arch_get_num_closid(NULL); struct mpam_write_config_arg *c = arg; + u32 reqpartid, req_idx; + + WARN_ON(c->partid >= closid_num); - mpam_reprogram_ris_partid(c->ris, c->partid, &c->comp->cfg[c->partid]); + /* Synchronize the configuration to each sub-monitoring group. */ + for (req_idx = 0; req_idx < get_num_reqpartid_per_closid(); + req_idx++) { + reqpartid = req_idx * closid_num + c->partid; + + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); + } return 0; } diff --git a/drivers/platform/arm64/mpam/mpam_internal.h b/drivers/platform/arm64/mpam/mpam_internal.h index 5fc9f09b6945..c02365338b21 100644 --- a/drivers/platform/arm64/mpam/mpam_internal.h +++ b/drivers/platform/arm64/mpam/mpam_internal.h @@ -773,4 +773,7 @@ static inline void mpam_resctrl_teardown_class(struct mpam_class *class) { } */ #define MSMON_CAPT_EVNT_NOW BIT(0) +u32 get_num_reqpartid_per_closid(void); +u32 req2intpartid(u32 reqpartid); + #endif /* MPAM_INTERNAL_H */ diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/arm64/mpam/mpam_resctrl.c index 064332e62c4d..62d0e0fc7fd9 100644 --- a/drivers/platform/arm64/mpam/mpam_resctrl.c +++ b/drivers/platform/arm64/mpam/mpam_resctrl.c @@ -186,7 +186,7 @@ static u32 get_num_reqpartid(void) return mpam_partid_max + 1; } -static u32 get_num_reqpartid_per_closid(void) +u32 get_num_reqpartid_per_closid(void) { return get_num_reqpartid() / resctrl_arch_get_num_closid(NULL); } @@ -260,7 +260,7 @@ static u32 rmid2pmg(u32 rmid) return rmid & pmg_mask; } -static u32 req2intpartid(u32 reqpartid) +u32 req2intpartid(u32 reqpartid) { u8 intpartid_shift = fls(mpam_intpartid_max); u32 intpartid_mask = ~(~0 << intpartid_shift);