From nobody Mon Apr 6 23:20:38 2026 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 B43333CE497 for ; Tue, 17 Mar 2026 13:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753727; cv=none; b=c4wEjiVy6sQcxbyCglyG0dMpiSADLe2P3bPaqMQb+p6WT6wScDmt18fsoEWrQcRPa04/plKsZ+NGEFafR2PXf1lrQIku13SX+g74msx1UDozvznZawwFRT0PdbM8IrVb7hxBSPL/sSshnk5BkeXktyVOjGj0yV1cpAs3IDesRwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753727; c=relaxed/simple; bh=BdGjbPdpCAOMXZ0I8IaZpBNJ2HIkZmo9lRm+TDo1Zk8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=inD5//7n3iVAAmT8okN9LHbQoZqdGDJJ+K2uKrObZC3JdjwLx1exzuyJD/cflDYIu7ASFxA/cKgO8QsuAX6rhKwvaUYKKSYs+ji44V8NdLrPE+dSOlEGweX2Yoe2HRbqESXso7Unk3aSn43SXSmkqU/GROaXHz3kNvmf0ssz6Mg= 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=bi7PaieE; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=bi7PaieE; arc=none smtp.client-ip=45.249.212.187 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="bi7PaieE"; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="bi7PaieE" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=TVYTDSh3yQDioNhUgMcmHZcGJzEaoOUYB/1JgCMw++Q=; b=bi7PaieEyX+h1rLVA/1q+FZB+nDnt1713YpfnYsqO1/KiQ5otg5WwSBFgxaKUuhY6eccex7Qz EhYR7RNV4fRUVePdtbg3hhRjVWVd5/krxroYQSBb5AdRhSnTxFzZYXshmn7t+oIyaeYjDimbc/1 CYeRp6qF5wgAXm7MJZ1n4/Y= Received: from canpmsgout03.his.huawei.com (unknown [172.19.92.159]) by szxga01-in.huawei.com (SkyGuard) with ESMTPS id 4fZszN6Trsz1BG0r for ; Tue, 17 Mar 2026 21:21:04 +0800 (CST) dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=TVYTDSh3yQDioNhUgMcmHZcGJzEaoOUYB/1JgCMw++Q=; b=bi7PaieEyX+h1rLVA/1q+FZB+nDnt1713YpfnYsqO1/KiQ5otg5WwSBFgxaKUuhY6eccex7Qz EhYR7RNV4fRUVePdtbg3hhRjVWVd5/krxroYQSBb5AdRhSnTxFzZYXshmn7t+oIyaeYjDimbc/1 CYeRp6qF5wgAXm7MJZ1n4/Y= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4fZst70rYyzpSwF; Tue, 17 Mar 2026 21:16:31 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 51F7C40363; Tue, 17 Mar 2026 21:21:53 +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.36; Tue, 17 Mar 2026 21:21:52 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 1/9] fs/resctrl: Fix MPAM Partid parsing errors by preserving CDP state during umount Date: Tue, 17 Mar 2026 21:21:33 +0800 Message-ID: <20260317132141.1272506-2-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" This patch fixes a pre-existing issue in the resctrl filesystem teardown sequence where premature clearing of cdp_enabled could lead to MPAM Partid parsing errors. The closid to partid conversion logic inherently depends on the global cdp_enabled state. However, rdt_disable_ctx() clears this flag early in the umount path, while free_rmid() operations will reference after that. This creates a window where partid parsing operates with inconsistent CDP state, potentially make monitor reads with wrong partid mapping. Additionally, rmid_entry remaining in limbo between mount sessions may trigger potential partid out-of-range errors, leading to MPAM fault interrupts and subsequent MPAM disablement. Reorder rdt_kill_sb() to delay rdt_disable_ctx() until after rmdir_all_sub() and resctrl_fs_teardown() complete. This ensures all rmid-related operations finish with correct CDP state. Introduce rdt_flush_limbo() to flush and cancel limbo work before the filesystem teardown completes. An alternative approach would be to cancel limbo work on umount and restart it on remount with remaked bitmap. However, this would require substantial changes in the resctrl layer to handle CDP state transitions across mount sessions, which is beyond the scope of the reqpartid feature work this patchset focuses on. The current fix addresses the immediate correctness issue with minimal churn. Signed-off-by: Zeng Heng --- fs/resctrl/rdtgroup.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5da305bd36c9..bc0735eef92a 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3165,6 +3165,25 @@ static void resctrl_fs_teardown(void) rdtgroup_destroy_root(); } =20 +static void rdt_flush_limbo(void) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + struct rdt_l3_mon_domain *d; + + if (!IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) + return; + + if (!resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) + return; + + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (has_busy_rmid(d)) { + __check_limbo(d, true); + cancel_delayed_work(&d->cqm_limbo); + } + } +} + static void rdt_kill_sb(struct super_block *sb) { struct rdt_resource *r; @@ -3172,13 +3191,14 @@ static void rdt_kill_sb(struct super_block *sb) cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 - rdt_disable_ctx(); - /* Put everything back to default values. */ for_each_alloc_capable_rdt_resource(r) resctrl_arch_reset_all_ctrls(r); =20 resctrl_fs_teardown(); + rdt_flush_limbo(); + rdt_disable_ctx(); + if (resctrl_arch_alloc_capable()) resctrl_arch_disable_alloc(); if (resctrl_arch_mon_capable()) --=20 2.25.1 From nobody Mon Apr 6 23:20:38 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 2EF223CA4AD for ; Tue, 17 Mar 2026 13:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753720; cv=none; b=oHo0GvzD81bXwQsCoYPhx703EhKvD8vhsepWM/Pal0yTiyZZzsSX0J+JVPesbBFFzYQfs7yGAlqUhuntcYCDMkBT9qWcGXupA7EnZUKnu8q4vo2TB23PpD+eVrH0vKkhr/4raQtxnaF9m2hepFt7NtZ4uj0BfPvW8l9krtf3Zhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753720; c=relaxed/simple; bh=wGX9fTYMNAPJ32062U6t77+crc7jwci9INEjthdihPU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JatKi1cybFOoRIPVZIgc3teStVeN/r9FaNBTHGT1L4TOEbwEYrqXIQ1QkFEwUK40D3FzrQALZ/0GKNmjgXrFaLIBaBGC4mu5CsmBZa2j7c6YJuG1RSroiJQEzCZNjzyrdYsX9Kex1CAinU9n/cLP5PAvTYcvQy9GmwizDA3iw/E= 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=qiPYV10K; arc=none smtp.client-ip=113.46.200.217 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="qiPYV10K" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Iq7+yMQ8pD3OqNZ9EeJiWpULmdxFHHZcN6JObvlJ70g=; b=qiPYV10KDK9BUxFL6lkYDl6j6AejAjsDW9flgYdiO0PDfkPqbexJJ7zRxpUF6dAeT6peOrel4 xpw4pNu75bGyohDPQxSgUQc3LguTRlLFzp+gmP/IKrDeL9orYKzHTuEmfvNAx+y6+Wi89YUCpBd FQaEV+3a+W+b0w4r3KQCFgo= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4fZssr1jbWzcb4c; Tue, 17 Mar 2026 21:16:16 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id C4DB74056B; Tue, 17 Mar 2026 21:21:53 +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.36; Tue, 17 Mar 2026 21:21:53 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 2/9] arm_mpam: Add intPARTID and reqPARTID support for narrow PARTID feature Date: Tue, 17 Mar 2026 21:21:34 +0800 Message-ID: <20260317132141.1272506-3-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" Introduce narrow PARTID (partid_nrw) feature support, which enables many-to-one mapping of request PARTIDs (reqPARTID) to internal PARTIDs (intPARTID). This expands monitoring capability by allowing a single control group to track more task types through multiple reqPARTIDs per intPARTID, bypassing the PMG limit in some extent. intPARTID: Internal PARTID used for control group configuration. Configurations are synchronized to all reqPARTIDs mapped to the same intPARTID. Count is indicated by MPAMF_PARTID_NRW_IDR.INTPARTID_MAX, or defaults to PARTID count if narrow PARTID is unsupported. reqPARTID: Request PARTID used to expand monitoring groups. Enables a single control group to monitor more task types by multiple reqPARTIDs within one intPARTID, overcoming the PMG count limitation. For systems with homogeneous MSCs (all supporting Narrow-PARTID), the driver exposes the full reqPARTID range directly. For heterogeneous systems where some MSCs lack Narrow-PARTID support, the driver utilizes PARTIDs beyond the intPARTID range as reqPARTIDs to expand monitoring capacity. So, the numbers of control group and monitoring group are calculated as: n =3D min(intPARTID, PARTID) /* the number of control groups */ l =3D min(reqPARTID, PARTID) /* the number of monitoring groups */ m =3D l // n /* monitoring groups per control group */ Where: intPARTID: intPARTIDs on narrow-PARTID-capable MSCs reqPARTID: reqPARTIDs on narrow-PARTID-capable MSCs PARTID: PARTIDs on non-narrow-PARTID-capable MSCs Example: L3 cache (256 PARTIDs, without narrow PARTID feature) + MATA (32 intPARTIDs, 256 reqPARTIDs): n =3D min( 32, 256) =3D 32 intPARTIDs l =3D min(256, 256) =3D 256 reqPARTIDs m =3D 256 / 32 =3D 8 reqPARTIDs per intPARTID Implementation notes: * Handle mixed MSC systems (some support narrow PARTID, some don't) by taking minimum number of intPARTIDs across all MSCs. * resctrl_arch_get_num_closid() now returns the number of intPARTIDs (was PARTID). Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_devices.c | 30 ++++++++++++++++++++---------- drivers/resctrl/mpam_internal.h | 2 ++ drivers/resctrl/mpam_resctrl.c | 4 ++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index 924d68b86948..2634afc41c6a 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -63,6 +63,7 @@ static DEFINE_MUTEX(mpam_cpuhp_state_lock); * Generating traffic outside this range will result in screaming interrup= ts. */ 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); @@ -290,10 +291,12 @@ int mpam_register_requestor(u16 partid_max, u8 pmg_ma= x) { guard(spinlock)(&partid_max_lock); if (!partid_max_init) { + mpam_intpartid_max =3D partid_max; mpam_partid_max =3D partid_max; mpam_pmg_max =3D pmg_max; partid_max_init =3D true; } else if (!partid_max_published) { + mpam_intpartid_max =3D min(mpam_intpartid_max, partid_max); mpam_partid_max =3D min(mpam_partid_max, partid_max); mpam_pmg_max =3D min(mpam_pmg_max, pmg_max); } else { @@ -933,7 +936,9 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris) u16 partid_max =3D FIELD_GET(MPAMF_PARTID_NRW_IDR_INTPARTID_MAX, nrwidr); =20 mpam_set_feature(mpam_feat_partid_nrw, props); - msc->partid_max =3D min(msc->partid_max, partid_max); + msc->intpartid_max =3D min(msc->partid_max, partid_max); + } else { + msc->intpartid_max =3D msc->partid_max; } } =20 @@ -997,6 +1002,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc) =20 spin_lock(&partid_max_lock); mpam_partid_max =3D min(mpam_partid_max, msc->partid_max); + mpam_intpartid_max =3D min(mpam_intpartid_max, msc->intpartid_max); mpam_pmg_max =3D min(mpam_pmg_max, msc->pmg_max); spin_unlock(&partid_max_lock); =20 @@ -1722,7 +1728,7 @@ static int mpam_reset_ris(void *arg) mpam_init_reset_cfg(&reset_cfg); =20 spin_lock(&partid_max_lock); - partid_max =3D mpam_partid_max; + partid_max =3D mpam_intpartid_max; spin_unlock(&partid_max_lock); for (partid =3D 0; partid <=3D partid_max; partid++) mpam_reprogram_ris_partid(ris, partid, &reset_cfg); @@ -1778,7 +1784,7 @@ static void mpam_reprogram_msc(struct mpam_msc *msc) struct mpam_write_config_arg arg; =20 /* - * No lock for mpam_partid_max as partid_max_published has been + * No lock for mpam_intpartid_max as partid_max_published has been * set by mpam_enabled(), so the values can no longer change. */ mpam_assert_partid_sizes_fixed(); @@ -1795,7 +1801,7 @@ static void mpam_reprogram_msc(struct mpam_msc *msc) arg.comp =3D ris->vmsc->comp; arg.ris =3D ris; reset =3D true; - for (partid =3D 0; partid <=3D mpam_partid_max; partid++) { + for (partid =3D 0; partid <=3D mpam_intpartid_max; partid++) { cfg =3D &ris->vmsc->comp->cfg[partid]; if (!bitmap_empty(cfg->features, MPAM_FEATURE_LAST)) reset =3D false; @@ -2626,7 +2632,7 @@ static void mpam_reset_component_cfg(struct mpam_comp= onent *comp) if (!comp->cfg) return; =20 - for (i =3D 0; i <=3D mpam_partid_max; i++) { + for (i =3D 0; i <=3D mpam_intpartid_max; i++) { comp->cfg[i] =3D (struct mpam_config) {}; if (cprops->cpbm_wd) comp->cfg[i].cpbm =3D GENMASK(cprops->cpbm_wd - 1, 0); @@ -2646,7 +2652,7 @@ static int __allocate_component_cfg(struct mpam_compo= nent *comp) if (comp->cfg) return 0; =20 - comp->cfg =3D kzalloc_objs(*comp->cfg, mpam_partid_max + 1); + comp->cfg =3D kzalloc_objs(*comp->cfg, mpam_intpartid_max + 1); if (!comp->cfg) return -ENOMEM; =20 @@ -2809,7 +2815,7 @@ static void mpam_enable_once(void) int err; =20 /* - * Once the cpuhp callbacks have been changed, mpam_partid_max can no + * Once the cpuhp callbacks have been changed, mpam_intpartid_max can no * longer change. */ spin_lock(&partid_max_lock); @@ -2860,9 +2866,13 @@ static void mpam_enable_once(void) mpam_register_cpuhp_callbacks(mpam_cpu_online, mpam_cpu_offline, "mpam:online"); =20 - /* Use printk() to avoid the pr_fmt adding the function name. */ - printk(KERN_INFO "MPAM enabled with %u PARTIDs and %u PMGs\n", - mpam_partid_max + 1, mpam_pmg_max + 1); + if (mpam_partid_max =3D=3D mpam_intpartid_max) + /* Use printk() to avoid the pr_fmt adding the function name. */ + printk(KERN_INFO "MPAM enabled with %u PARTIDs and %u PMGs\n", + mpam_partid_max + 1, mpam_pmg_max + 1); + else + printk(KERN_INFO "MPAM enabled with %u reqPARTIDs, %u intPARTIDs and %u = PMGs\n", + mpam_partid_max + 1, mpam_intpartid_max + 1, mpam_pmg_max + 1); } =20 static void mpam_reset_component_locked(struct mpam_component *comp) diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_interna= l.h index 2a67b5f501bd..2029a5b7283e 100644 --- a/drivers/resctrl/mpam_internal.h +++ b/drivers/resctrl/mpam_internal.h @@ -82,6 +82,7 @@ struct mpam_msc { */ struct mutex probe_lock; bool probed; + u16 intpartid_max; u16 partid_max; u8 pmg_max; unsigned long ris_idxs; @@ -466,6 +467,7 @@ extern struct list_head mpam_classes; =20 /* System wide partid/pmg values */ extern u16 mpam_partid_max; +extern u16 mpam_intpartid_max; extern u8 mpam_pmg_max; =20 /* Scheduled work callback to enable mpam once all MSC have been probed */ diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 19b306017845..222ea1d199e1 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -206,7 +206,7 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level= rid, bool enable) mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable =3D tr= ue; =20 if (enable) { - if (mpam_partid_max < 1) + if (mpam_intpartid_max < 1) return -EINVAL; =20 partid_d =3D resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, CDP_DATA); @@ -237,7 +237,7 @@ static bool mpam_resctrl_hide_cdp(enum resctrl_res_leve= l rid) */ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) { - return mpam_partid_max + 1; + return mpam_intpartid_max + 1; } =20 u32 resctrl_arch_system_num_rmid_idx(void) --=20 2.25.1 From nobody Mon Apr 6 23:20:38 2026 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (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 A64293CCA0E for ; Tue, 17 Mar 2026 13:22:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753724; cv=none; b=NMVCWZvPF1apAlf2F5Lpu4a/5T6+hrxk0y1S7RCECKkQX+gL6wCMEbXf2i0STHt0JvUAFODMEe2hQ+6ArpFgIWZEbSsuZYz2terCX649BqL6BSWFjB7K2MV7Au92vl9UQyoY+pHvOMR7z0kNlEWkj/AbvuCEK+mMR+dh0sKEnDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753724; c=relaxed/simple; bh=VzUNjun2mGsk+mWNnnnzu2CwP9q6z+q/FLkq831gXT4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LK/iFNAmHS61f7q7gyxFPlBirvdK4QINXcso4XAt/9jD4Fbn7deW6M8TOTUULEN/26ZGrogluuadDeekQynGH2pw8dmyQM7mgXpTEFBPM8NNguL2Cjbn3hzeaKwR8lSZs7pceEQYpYE/Tyn5Jrf149c2OFgMAt+n5LvuiwFlKeg= 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=c98MqViX; arc=none smtp.client-ip=113.46.200.220 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="c98MqViX" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=OTG6reFSOo8g9T3aBO/Up0qn8cWllWtbqfq9bTXfeAg=; b=c98MqViXz/3wh52VuIwEmtJ6A4eizPSTyHIA8DCWk8Bgb/8R7eT9AWVJUWK/O19+L1iFCZ55N +lLvJB+QuHVKXmg4oMN28oRK8lMeI3tUKuZ0qbhwC+u3ufuK0+CQTmbSkt77BfngsIjwS9w39wR fvis+iT4Tr9ywrQMkr9hL5Y= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4fZssy2w04z12LD2; Tue, 17 Mar 2026 21:16:22 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 45AF340567; Tue, 17 Mar 2026 21:21:54 +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.36; Tue, 17 Mar 2026 21:21:53 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 3/9] arm_mpam: Disable Narrow-PARTID when MBA lacks support Date: Tue, 17 Mar 2026 21:21:35 +0800 Message-ID: <20260317132141.1272506-4-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" MPAM supports mixed systems with MSCs that may or may not implement Narrow-PARTID. However, when the MBA MSC uses percentage-based throttling (non-bitmap partition control) and lacks Narrow-PARTID support, resctrl cannot correctly apply control group configurations across multiple PARTIDs. Since there is no straightforward way to program compatible control values in this scenario, disable Narrow-PARTID system-wide when detected. The detection occurs at initialization time on the first call to get_num_reqpartid() from mpam_resctrl_pick_counters(), which is guaranteed to occur after mpam_resctrl_pick_mba() has set up the MBA resource class. If MBA MSCs lack Narrow-PARTID support, get_num_reqpartid() falls back to returning the number of internal PARTIDs (mpam_intpartid_max). Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_resctrl.c | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 222ea1d199e1..1b18c095cfce 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -240,9 +240,45 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *i= gnored) return mpam_intpartid_max + 1; } =20 +/* + * Determine the effective number of PARTIDs available for resctrl. + * + * This function performs a one-time check to determine if Narrow-PARTID + * can be used. It must be called after mpam_resctrl_pick_mba() has + * initialized the MBA resource, as the MBA class properties are used + * to detect Narrow-PARTID support. + * + * The first call occurs in mpam_resctrl_pick_counters(), ensuring the + * prerequisite initialization is complete. + */ +static u32 get_num_reqpartid(void) +{ + struct mpam_resctrl_res *res; + struct rdt_resource *r_mba; + struct mpam_props *cprops; + static bool first =3D true; + + if (first) { + r_mba =3D resctrl_arch_get_resource(RDT_RESOURCE_MBA); + res =3D container_of(r_mba, struct mpam_resctrl_res, resctrl_res); + if (!res->class) + goto out; + + /* If MBA MSCs lack Narrow-PARTID support, roll back. */ + cprops =3D &res->class->props; + if (!mpam_has_feature(mpam_feat_partid_nrw, cprops)) + mpam_partid_max =3D mpam_intpartid_max; + + } + +out: + first =3D false; + return mpam_partid_max + 1; +} + u32 resctrl_arch_system_num_rmid_idx(void) { - return (mpam_pmg_max + 1) * (mpam_partid_max + 1); + return (mpam_pmg_max + 1) * get_num_reqpartid(); } =20 u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) --=20 2.25.1 From nobody Mon Apr 6 23:20:38 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 331C03C8732 for ; Tue, 17 Mar 2026 13:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753720; cv=none; b=iQ8SWmdtK/6Rim3wP6PYRgsKsptpt0KtNk5rY8f+aIX8J4sMTRyYD14CkHz6kq9D+XX1jMX4fKBOPL5XemZUZTmdFnOwRHP6I1/UvdDuZZ39Td+uKdLpPvf1svI+qKJFHsTlHn5zcqx6o2NlcR3PAlTGMI4ViSPLSkjxn2Gs1M8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753720; c=relaxed/simple; bh=0xCqg9lIC4OW7lIXaR3iXeBsiM5D4USv4IXKX+eRVqc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mPoCSF6x42L2C++xlXrcm8wsDI7X3x2ZChTiVEe9Cea+awHhBNctqWFlGfq5d+cvzwwamBRV3CsfvY5hzZVF7KVnytSn/2+IZBst9CUfVgA2Kd+KThCPW+FijbnhNLAxm0BdFWMf2vF5OTAzcWKEU0dlrThkG81LjoZimUxovVg= 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=Tp8wUND/; arc=none smtp.client-ip=113.46.200.226 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="Tp8wUND/" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=ugR49d+K65L65FuW+6Ux7gyn32iXb7uO61a36mt8wwE=; b=Tp8wUND/uoem3e/NDmrZfF1IiQUoo2wQ+WpJwZMGXV7PzrqA71o/BgKeXBQnVKeelYIK4W4KR nLGEu/Vgl0M5h71XHmQcJRkSZ38Wz55hq6ywoNiVI09954R/yzfIG3VXMfHnzSxzJV4SWjODt6Z +Z0FdjiRtEc4848I1cmit/Q= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fZstb0bn4zKm72; Tue, 17 Mar 2026 21:16:55 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id BFB9E402AB; Tue, 17 Mar 2026 21:21:54 +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.36; Tue, 17 Mar 2026 21:21:54 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 4/9] arm_mpam: Refactor rmid to reqPARTID/PMG mapping Date: Tue, 17 Mar 2026 21:21:36 +0800 Message-ID: <20260317132141.1272506-5-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) The Narrow PARTID feature allows the MPAM driver to statically or dynamically allocate request PARTIDs (reqPARTIDs) to internal PARTIDs (intPARTIDs). This enables expanding the number of monitoring groups beyond the hardware PMG limit. For systems with mixed MSCs (Memory System Components), MSCs that do not support narrow PARTID use PARTIDs exceeding the minimum number of intPARTIDs as reqPARTIDs to expand monitoring groups. Expand RMID to include reqPARTID information: RMID =3D reqPARTID * NUM_PMG + PMG To maintain compatibility with the existing resctrl layer, reqPARTIDs are allocated statically with a linear mapping to intPARTIDs via req2intpartid(). Mapping relationships (n =3D intPARTID count, m =3D reqPARTIDs per intPARTI= D): P - Partition group M - Monitoring group Group closid rmid.reqPARTID MSCs w/ narrow-PARTID MSCs w/o narrow-PARTID P1 0 intPARTID_1 PARTID_1 M1_1 0 0 =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_1_1 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_1 M1_2 0 0+n =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_1_2 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_1_2 M1_3 0 0+n*2 =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_1_3 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_1_3 ... =E2=94=9C=E2=94=80=E2=94=80 ... = =E2=94=9C=E2=94=80=E2=94=80 ... M1_m 0 0+n*(m-1) =E2=94=94=E2=94=80=E2=94=80 reqPARTID_1_m = =E2=94=94=E2=94=80=E2=94=80 PARTID_1_m P2 1 intPARTID_2 PARTID_2 M2_1 1 1 =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_2_1 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_2 M2_2 1 1+n =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_2_2 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_2_2 M2_3 1 1+n*2 =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_2_3 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_2_3 ... =E2=94=9C=E2=94=80=E2=94=80 ... = =E2=94=9C=E2=94=80=E2=94=80 ... M2_m 1 1+n*(m-1) =E2=94=94=E2=94=80=E2=94=80 reqPARTID_2_m = =E2=94=94=E2=94=80=E2=94=80 PARTID_2_m Pn n-1 intPARTID_n PARTID_n Mn_1 n-1 n-1 =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_n_1 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_n Mn_2 n-1 n-1+n =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_n_2 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_n_2 Mn_3 n-1 n-1+n*2 =E2=94=9C=E2=94=80=E2=94=80 reqPARTID_n_3 = =E2=94=9C=E2=94=80=E2=94=80 PARTID_n_3 ... =E2=94=9C=E2=94=80=E2=94=80 ... = =E2=94=9C=E2=94=80=E2=94=80 ... Mn_m n-1 n*m-1 =E2=94=94=E2=94=80=E2=94=80 reqPARTID_n_m = =E2=94=94=E2=94=80=E2=94=80 PARTID_n_m Refactor the glue layer between resctrl abstractions (rmid) and MPAM hardware registers (reqPARTID/PMG) to support narrow PARTID. The resctrl layer uses rmid2reqpartid() and rmid2pmg() to extract components from rmid. The closid-to-intPARTID translation remains unchanged via resctrl_get_config_index(). Since narrow PARTID is a monitoring enhancement, reqPARTID is only used in monitoring paths while configuration paths maintain original semantics of closid. Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_resctrl.c | 101 +++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 30 deletions(-) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 1b18c095cfce..15e8cf7d8f1f 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -281,15 +281,60 @@ u32 resctrl_arch_system_num_rmid_idx(void) return (mpam_pmg_max + 1) * get_num_reqpartid(); } =20 +static u16 rmid2reqpartid(u32 rmid) +{ + rmid /=3D (mpam_pmg_max + 1); + + if (cdp_enabled) + return resctrl_get_config_index(rmid, CDP_DATA); + + return resctrl_get_config_index(rmid, CDP_NONE); +} + +static u8 rmid2pmg(u32 rmid) +{ + return rmid % (mpam_pmg_max + 1); +} + +static u16 req2intpartid(u16 reqpartid) +{ + return reqpartid % (mpam_intpartid_max + 1); +} + +/* + * To avoid the reuse of rmid across multiple control groups, check + * the incoming closid to prevent rmid from being reallocated by + * resctrl_find_free_rmid(). + * + * If the closid and rmid do not match upon inspection, immediately + * returns an invalid rmid. A valid rmid must not exceed 24 bits. + */ u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) { - return closid * (mpam_pmg_max + 1) + rmid; + u32 reqpartid =3D rmid2reqpartid(rmid); + u32 intpartid =3D req2intpartid(reqpartid); + + if (cdp_enabled) + intpartid >>=3D 1; + + if (closid !=3D intpartid) + return U32_MAX; + + return rmid; } =20 void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid) { - *closid =3D idx / (mpam_pmg_max + 1); - *rmid =3D idx % (mpam_pmg_max + 1); + u32 reqpartid =3D rmid2reqpartid(idx); + u32 intpartid =3D req2intpartid(reqpartid); + + if (rmid) + *rmid =3D idx; + if (closid) { + if (cdp_enabled) + intpartid >>=3D 1; + *closid =3D intpartid; + } } =20 void resctrl_arch_sched_in(struct task_struct *tsk) @@ -301,21 +346,17 @@ void resctrl_arch_sched_in(struct task_struct *tsk) =20 void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmi= d) { - WARN_ON_ONCE(closid > U16_MAX); - WARN_ON_ONCE(rmid > U8_MAX); + u32 reqpartid =3D rmid2reqpartid(rmid); + u8 pmg =3D rmid2pmg(rmid); =20 - if (!cdp_enabled) { - mpam_set_cpu_defaults(cpu, closid, closid, rmid, rmid); - } else { + if (!cdp_enabled) + 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 =3D resctrl_get_config_index(closid, CDP_DATA); - u32 partid_i =3D resctrl_get_config_index(closid, CDP_CODE); - - mpam_set_cpu_defaults(cpu, partid_d, partid_i, rmid, rmid); - } + mpam_set_cpu_defaults(cpu, reqpartid, reqpartid + 1, pmg, pmg); } =20 void resctrl_arch_sync_cpu_closid_rmid(void *info) @@ -334,17 +375,16 @@ void resctrl_arch_sync_cpu_closid_rmid(void *info) =20 void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32= rmid) { - WARN_ON_ONCE(closid > U16_MAX); - WARN_ON_ONCE(rmid > U8_MAX); + u32 reqpartid =3D rmid2reqpartid(rmid); + u8 pmg =3D rmid2pmg(rmid); =20 - if (!cdp_enabled) { - mpam_set_task_partid_pmg(tsk, closid, closid, rmid, rmid); - } else { - u32 partid_d =3D resctrl_get_config_index(closid, CDP_DATA); - u32 partid_i =3D resctrl_get_config_index(closid, CDP_CODE); + WARN_ON_ONCE(reqpartid > U16_MAX); + WARN_ON_ONCE(pmg > U8_MAX); =20 - mpam_set_task_partid_pmg(tsk, partid_d, partid_i, rmid, rmid); - } + if (!cdp_enabled) + mpam_set_task_partid_pmg(tsk, reqpartid, reqpartid, pmg, pmg); + else + mpam_set_task_partid_pmg(tsk, reqpartid, reqpartid + 1, pmg, pmg); } =20 bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid) @@ -352,6 +392,8 @@ bool resctrl_arch_match_closid(struct task_struct *tsk,= u32 closid) u64 regval =3D mpam_get_regval(tsk); u32 tsk_closid =3D FIELD_GET(MPAM0_EL1_PARTID_D, regval); =20 + tsk_closid =3D req2intpartid(tsk_closid); + if (cdp_enabled) tsk_closid >>=3D 1; =20 @@ -362,13 +404,11 @@ bool resctrl_arch_match_closid(struct task_struct *ts= k, u32 closid) bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid) { u64 regval =3D mpam_get_regval(tsk); - u32 tsk_closid =3D FIELD_GET(MPAM0_EL1_PARTID_D, regval); - u32 tsk_rmid =3D FIELD_GET(MPAM0_EL1_PMG_D, regval); - - if (cdp_enabled) - tsk_closid >>=3D 1; + u32 tsk_partid =3D FIELD_GET(MPAM0_EL1_PARTID_D, regval); + u32 tsk_pmg =3D FIELD_GET(MPAM0_EL1_PMG_D, regval); =20 - return (tsk_closid =3D=3D closid) && (tsk_rmid =3D=3D rmid); + return (tsk_partid =3D=3D rmid2reqpartid(rmid)) && + (tsk_pmg =3D=3D rmid2pmg(rmid)); } =20 struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) @@ -456,6 +496,7 @@ static int __read_mon(struct mpam_resctrl_mon *mon, str= uct mpam_component *mon_c enum resctrl_conf_type cdp_type, u32 closid, u32 rmid, u64 *val) { struct mon_cfg cfg; + u32 reqpartid =3D rmid2reqpartid(rmid); =20 if (!mpam_is_enabled()) return -EINVAL; @@ -479,8 +520,8 @@ static int __read_mon(struct mpam_resctrl_mon *mon, str= uct mpam_component *mon_c cfg =3D (struct mon_cfg) { .mon =3D mon_idx, .match_pmg =3D true, - .partid =3D closid, - .pmg =3D rmid, + .partid =3D (cdp_type =3D=3D CDP_CODE) ? reqpartid + 1 : reqpartid, + .pmg =3D rmid2pmg(rmid), }; =20 return mpam_msmon_read(mon_comp, &cfg, mon_type, val); --=20 2.25.1 From nobody Mon Apr 6 23:20:38 2026 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 827F13C9EF0 for ; Tue, 17 Mar 2026 13:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753720; cv=none; b=CLBsZYvSD3+CaHusWoEp600FKuVUeWKDiKkO/LvY8QdCfKx6H+4XDHyK8Wpsa8GYTPUILWDfQkpFp75bFXQN6xYzARaOG0pQ7armXz4uPlx1UpTHYK2UbpAjR7GCVEtu1Z4pV1tKP8nMMEChzRDcPyKZ7zMOljz4vHSsfqWuIR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753720; c=relaxed/simple; bh=ZKJ+CgXseAbTEqkgxYiS+xQFEi1ERPzGXJBiG5hXbTM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AT3hSxmzIlJGpudnAApnllSFmpBTSmIp6quuf0UnrFTa1LpNRD4w58lxYIupQl80cM5uO0HiMplz5xz9Wd4QFWpN85BXTAEJoW8ErnuME1dP9Mkjynvsx4DlzWTQoEvS++I6kIWb3KFc+ooReKBFDj2T0glkvm5RygVm8binQeE= 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=X1Nqfcz7; arc=none smtp.client-ip=113.46.200.216 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="X1Nqfcz7" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=iSOBj8/Jd1Zci3ArXUSNCj25VXpoCU1bLushjGxvgCY=; b=X1Nqfcz7WAqJCSl5T7FNAt/uwX82CXl3tMpPz9Gien7jw29kyeFEr4xnPnd3TK2Q2BV7AGRl+ DF4t7bmSMcHoEpQl1lSNZAlFgkGNkco0O2z/tHuM//HN+7nfcX7mfaXnVu2V+1uOuBTJ1lrawrX YIBf9Zzo14dc/L/NaQgOc7s= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4fZstC1Z5yz1T4Ft; Tue, 17 Mar 2026 21:16:35 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 47495404AD; Tue, 17 Mar 2026 21:21:55 +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.36; Tue, 17 Mar 2026 21:21:54 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 5/9] arm_mpam: Propagate control group config to sub-monitoring groups Date: Tue, 17 Mar 2026 21:21:37 +0800 Message-ID: <20260317132141.1272506-6-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" With the narrow PARTID feature, each control group is assigned multiple (req)PARTIDs to expand monitoring capacity. When a control group's configuration is updated, all associated sub-monitoring groups (each identified by a unique reqPARTID) should be synchronized. In __write_config(), iterate over all reqPARTIDs belonging to the control group and propagate the configuration to each sub-monitoring group: * For MSCs supporting narrow PARTID, establish the reqPARTID to intPARTID mapping. * For MSCs without narrow PARTID support, synchronize the configuration to new PARTIDs directly. Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_devices.c | 33 +++++++++++++++++++++++++++------ drivers/resctrl/mpam_internal.h | 2 ++ drivers/resctrl/mpam_resctrl.c | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index 2634afc41c6a..d98f81621be1 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -1543,6 +1543,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc= _ris *ris, u16 partid, { u32 pri_val =3D 0; u16 cmax =3D MPAMCFG_CMAX_CMAX; + u16 intpartid =3D req2intpartid(partid); struct mpam_msc *msc =3D ris->vmsc->msc; struct mpam_props *rprops =3D &ris->props; u16 dspri =3D GENMASK(rprops->dspri_wd, 0); @@ -1552,15 +1553,17 @@ static void mpam_reprogram_ris_partid(struct mpam_m= sc_ris *ris, u16 partid, __mpam_part_sel(ris->ris_idx, partid, msc); =20 if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) { - /* Update the intpartid mapping */ mpam_write_partsel_reg(msc, INTPARTID, - MPAMCFG_INTPARTID_INTERNAL | partid); + MPAMCFG_INTPARTID_INTERNAL | intpartid); =20 /* - * Then switch to the 'internal' partid to update the - * configuration. + * Mapping from reqpartid to intpartid already established. + * Sub-monitoring groups share the parent's configuration. */ - __mpam_intpart_sel(ris->ris_idx, partid, msc); + if (partid !=3D intpartid) + goto out; + + __mpam_intpart_sel(ris->ris_idx, intpartid, msc); } =20 if (mpam_has_feature(mpam_feat_cpor_part, rprops) && @@ -1632,6 +1635,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc= _ris *ris, u16 partid, =20 mpam_quirk_post_config_change(ris, partid, cfg); =20 +out: mutex_unlock(&msc->part_sel_lock); } =20 @@ -1766,11 +1770,28 @@ struct mpam_write_config_arg { u16 partid; }; =20 +static u32 get_num_reqpartid_per_intpartid(void) +{ + return (mpam_partid_max + 1) / (mpam_intpartid_max + 1); +} + static int __write_config(void *arg) { + int closid_num =3D resctrl_arch_get_num_closid(NULL); struct mpam_write_config_arg *c =3D arg; + u32 reqpartid, req_idx; =20 - mpam_reprogram_ris_partid(c->ris, c->partid, &c->comp->cfg[c->partid]); + /* c->partid should be within the range of intPARTIDs */ + WARN_ON_ONCE(c->partid >=3D closid_num); + + /* Synchronize the configuration to each sub-monitoring group. */ + for (req_idx =3D 0; req_idx < get_num_reqpartid_per_intpartid(); + req_idx++) { + reqpartid =3D req_idx * closid_num + c->partid; + + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); + } =20 return 0; } diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_interna= l.h index 2029a5b7283e..9069e2314d77 100644 --- a/drivers/resctrl/mpam_internal.h +++ b/drivers/resctrl/mpam_internal.h @@ -487,6 +487,8 @@ void mpam_msmon_reset_mbwu(struct mpam_component *comp,= struct mon_cfg *ctx); int mpam_get_cpumask_from_cache_id(unsigned long cache_id, u32 cache_level, cpumask_t *affinity); =20 +u16 req2intpartid(u16 reqpartid); + #ifdef CONFIG_RESCTRL_FS int mpam_resctrl_setup(void); void mpam_resctrl_exit(void); diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 15e8cf7d8f1f..725583d7bd07 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -296,7 +296,7 @@ static u8 rmid2pmg(u32 rmid) return rmid % (mpam_pmg_max + 1); } =20 -static u16 req2intpartid(u16 reqpartid) +u16 req2intpartid(u16 reqpartid) { return reqpartid % (mpam_intpartid_max + 1); } --=20 2.25.1 From nobody Mon Apr 6 23:20:38 2026 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (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 F0AFA3CBE8C for ; Tue, 17 Mar 2026 13:22:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753730; cv=none; b=XtM1viMhghWRk//NfOKVxFfmJNg3jbym6QcTP+uP4P1xONJWKsesAicbTPXXbcOAfwAxA1HsnAdReyPp2Oz/CrOwXgUPmWoIFPsnN/uVYlZCJnLQiRXk4VKlY++ECXo1REbl+HvHFcHzP513P6+JZj6FQQGsK3nSFpEd6fXDKgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753730; c=relaxed/simple; bh=LtwnklN1pBjW74fASEgjie0JHthdiIDNPBU7yqemrNo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=spatnU8i1VRMxacNMANheAStSoWo+Csum7ptvMzOcOxozLTA3/cRRLSuJDFAGfQyVFK+omhKO44QEDu7vJDekqaYmM39SBLF8R9UpEZ1luvbhbYvET4qJIM8NJhI5rR9J6gNbBTOFIraWMc4zS5JwSdfk0vkx3fTf/BM41ut/T8= 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=es5wp5jx; arc=none smtp.client-ip=113.46.200.222 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="es5wp5jx" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=+v2BBENAq9TPpo0HOdE/veZnsoXu31S3Qt7RH3ZdPes=; b=es5wp5jxl+4UpERrW1dVqGAGTKdlZwRDr0hLPx9Mwnj3u6IttP+07egHGBNsttdQxO0sDQefA ZqVoXRhIjJq/u3/4qEs119p6I+1rTl29pGKCSWskr2jXA3SsphuAyuGePnWF/XraDr1ev1BLJA4 FZRb82ACd3TByUtJsslK4mQ= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4fZstc6Jy2zLlSF; Tue, 17 Mar 2026 21:16:56 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id CA76940562; Tue, 17 Mar 2026 21:21:55 +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.36; Tue, 17 Mar 2026 21:21:55 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 6/9] fs/resctrl: Add rmid_entry state helpers Date: Tue, 17 Mar 2026 21:21:38 +0800 Message-ID: <20260317132141.1272506-7-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" Introduce helper functions for rmid_entry management, in preparation for upcoming patches supporting dynamic monitoring group allocation: * rmid_is_occupied(): Query whether a rmid_entry is currently allocated by checking if its list node has been removed from the free list. * rmid_entry_reassign_closid(): Update the closid associated with a rmid entry. Fix list node initialization in alloc_rmid() and dom_data_init() by using list_del_init() instead of list_del(). This ensures list_empty() checks in rmid_is_occupied() work correctly without encountering LIST_POISON values. Signed-off-by: Zeng Heng --- fs/resctrl/monitor.c | 18 ++++++++++++++++-- include/linux/resctrl.h | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 49f3f6b846b2..4e78fb194c16 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -284,7 +284,7 @@ int alloc_rmid(u32 closid) if (IS_ERR(entry)) return PTR_ERR(entry); =20 - list_del(&entry->list); + list_del_init(&entry->list); return entry->rmid; } =20 @@ -344,6 +344,20 @@ void free_rmid(u32 closid, u32 rmid) list_add_tail(&entry->list, &rmid_free_lru); } =20 +bool rmid_is_occupied(u32 closid, u32 rmid) +{ + u32 idx =3D resctrl_arch_rmid_idx_encode(closid, rmid); + + return list_empty(&rmid_ptrs[idx].list); +} + +void rmid_entry_reassign_closid(u32 closid, u32 rmid) +{ + u32 idx =3D resctrl_arch_rmid_idx_encode(closid, rmid); + + rmid_ptrs[idx].closid =3D closid; +} + static struct mbm_state *get_mbm_state(struct rdt_l3_mon_domain *d, u32 cl= osid, u32 rmid, enum resctrl_event_id evtid) { @@ -943,7 +957,7 @@ int setup_rmid_lru_list(void) idx =3D resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, RESCTRL_RESERVED_RMID); entry =3D __rmid_entry(idx); - list_del(&entry->list); + list_del_init(&entry->list); =20 return 0; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57fd7ca5..b636e7250c20 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -702,6 +702,27 @@ bool resctrl_arch_get_io_alloc_enabled(struct rdt_reso= urce *r); extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 +/** + * rmid_is_occupied() - Check whether the specified rmid has been + * allocated. + * @closid: Specify the closid that matches the rmid. + * @rmid: Specify the rmid entry to check status. + * + * This function checks if the rmid_entry is currently allocated by testing + * whether its list node is empty (removed from the free list). + * + * Return: + * True if the specified rmid is still in use. + */ +bool rmid_is_occupied(u32 closid, u32 rmid); + +/** + * rmid_entry_reassign_closid() - Update the closid field of a rmid_entry. + * @closid: Specify the reassigned closid. + * @rmid: Specify the rmid entry to update closid. + */ +void rmid_entry_reassign_closid(u32 closid, u32 rmid); + int resctrl_init(void); void resctrl_exit(void); =20 --=20 2.25.1 From nobody Mon Apr 6 23:20:38 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 EF6953CB2C3 for ; Tue, 17 Mar 2026 13:21:58 +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=1773753721; cv=none; b=e0VghvvkEoTcoHJz3/J3AJInipzy2JyJ9eUYevFjNhW+ixxH4xlhYWvc2Ch9XyjnC4CMLplQoVMjRyikCgw4pwhecSZ+da1gFcHFejNSdaKXEV6wnF2LjNliUBsIARyOepBDLbNs/BzPV8QBK3nNaEPNbf4c0krE0R5RQmj3a2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753721; c=relaxed/simple; bh=Oh8bLHdSqT3lIzvtzc4SB/N5rqyyJ9J2wTKSxIHcdLs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ihUkHfLhlieLrDk/FlDEn6E55Au6QXb+QANb2Ii+lz9agmR1vx3/+lNKHvAl7w2o1BHClNzUVbj9ZWiBvkLK/KEyed/AG1y346vn5hY8shanFxLpLqzRsGMRj+RvfoBz6Y7Qiawxp+nCEXfL2wVy+3YbR2uGHkqtQY4qyUqZzes= 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=GTXD9PNZ; 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="GTXD9PNZ" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=qbfGnpDPrfirGZE9+//FmnYi/LSQeqd94n1FMvxAG4E=; b=GTXD9PNZmCUPTRqKPbfHAuaytU16UJNCsWTySBGzAgbEmHk12RLrdaoJi6bYvzKLhAp5XIihA VcDi96H+Pkt2Acf0G/drhcgPZQ2ubByCgETVDom1jD4M/+EMok97l3R0qvTZOL4b9z9AiTbxPJl 2gXcfdX4JKMJs4rC4l97+JA= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4fZstb03j5z1prKL; Tue, 17 Mar 2026 21:16:55 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 4D00B40561; Tue, 17 Mar 2026 21:21:56 +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.36; Tue, 17 Mar 2026 21:21:55 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 7/9] arm_mpam: Implement dynamic reqPARTID allocation for monitoring groups Date: Tue, 17 Mar 2026 21:21:39 +0800 Message-ID: <20260317132141.1272506-8-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" Replace static reqPARTID allocation with dynamic binding to maximize monitoring group utilization. Static allocation wastes resources when control groups create fewer sub-groups than the pre-allocated limit. Add a lookup table (reqpartid_map) to dynamically bind reqPARTIDs to control groups needing extended monitoring capacity: * resctrl_arch_rmid_expand(): Find and bind a free reqPARTID to the specified closid when creating monitoring groups. * resctrl_arch_rmid_reclaim(): Unbind reqPARTID when all monitoring groups associated with pmg are freed, making it available for reuse. Update conversion helpers for dynamic mapping: * req2intpartid() switches to lookup table for dynamic allocation. * Add partid2closid() and req_pmg2rmid() helpers. Refactor __write_config() to iterate over all reqPARTIDs that match by intPARTID, removing fixed per-closid slot assumption. Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_devices.c | 21 ++--- drivers/resctrl/mpam_internal.h | 1 + drivers/resctrl/mpam_resctrl.c | 141 +++++++++++++++++++++++++++++--- include/linux/arm_mpam.h | 17 ++++ 4 files changed, 156 insertions(+), 24 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index d98f81621be1..20ad06f66b88 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -1770,27 +1770,24 @@ struct mpam_write_config_arg { u16 partid; }; =20 -static u32 get_num_reqpartid_per_intpartid(void) -{ - return (mpam_partid_max + 1) / (mpam_intpartid_max + 1); -} - static int __write_config(void *arg) { int closid_num =3D resctrl_arch_get_num_closid(NULL); struct mpam_write_config_arg *c =3D arg; - u32 reqpartid, req_idx; + u32 reqpartid; =20 /* c->partid should be within the range of intPARTIDs */ WARN_ON_ONCE(c->partid >=3D closid_num); =20 - /* Synchronize the configuration to each sub-monitoring group. */ - for (req_idx =3D 0; req_idx < get_num_reqpartid_per_intpartid(); - req_idx++) { - reqpartid =3D req_idx * closid_num + c->partid; + mpam_reprogram_ris_partid(c->ris, c->partid, + &c->comp->cfg[c->partid]); =20 - mpam_reprogram_ris_partid(c->ris, reqpartid, - &c->comp->cfg[c->partid]); + /* Synchronize the configuration to each sub-monitoring group. */ + for (reqpartid =3D closid_num; + reqpartid < get_num_reqpartid(); reqpartid++) { + if (req2intpartid(reqpartid) =3D=3D c->partid) + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); } =20 return 0; diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_interna= l.h index 9069e2314d77..91f6d5f14a9e 100644 --- a/drivers/resctrl/mpam_internal.h +++ b/drivers/resctrl/mpam_internal.h @@ -488,6 +488,7 @@ int mpam_get_cpumask_from_cache_id(unsigned long cache_= id, u32 cache_level, cpumask_t *affinity); =20 u16 req2intpartid(u16 reqpartid); +u32 get_num_reqpartid(void); =20 #ifdef CONFIG_RESCTRL_FS int mpam_resctrl_setup(void); diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 725583d7bd07..a91c0e22ef6b 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -251,7 +251,7 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ig= nored) * The first call occurs in mpam_resctrl_pick_counters(), ensuring the * prerequisite initialization is complete. */ -static u32 get_num_reqpartid(void) +u32 get_num_reqpartid(void) { struct mpam_resctrl_res *res; struct rdt_resource *r_mba; @@ -296,9 +296,36 @@ static u8 rmid2pmg(u32 rmid) return rmid % (mpam_pmg_max + 1); } =20 +static u32 req_pmg2rmid(u32 reqpartid, u8 pmg) +{ + if (cdp_enabled) + reqpartid >>=3D 1; + + return reqpartid * (mpam_pmg_max + 1) + pmg; +} + +static u32 *reqpartid_map; + u16 req2intpartid(u16 reqpartid) { - return reqpartid % (mpam_intpartid_max + 1); + WARN_ON_ONCE(reqpartid >=3D get_num_reqpartid()); + + /* + * Directly return intPartid in case that mpam_reset_ris() access + * NULL pointer. + */ + if (reqpartid < (mpam_intpartid_max + 1)) + return reqpartid; + + return reqpartid_map[reqpartid]; +} + +static u32 partid2closid(u32 partid) +{ + if (cdp_enabled) + partid >>=3D 1; + + return partid; } =20 /* @@ -312,12 +339,12 @@ u16 req2intpartid(u16 reqpartid) u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) { u32 reqpartid =3D rmid2reqpartid(rmid); - u32 intpartid =3D req2intpartid(reqpartid); =20 - if (cdp_enabled) - intpartid >>=3D 1; + /* When enable CDP mode, needs to filter invalid rmid entry out */ + if (reqpartid >=3D get_num_reqpartid()) + return U32_MAX; =20 - if (closid !=3D intpartid) + if (closid !=3D partid2closid(req2intpartid(reqpartid))) return U32_MAX; =20 return rmid; @@ -330,11 +357,9 @@ void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid= , u32 *rmid) =20 if (rmid) *rmid =3D idx; - if (closid) { - if (cdp_enabled) - intpartid >>=3D 1; - *closid =3D intpartid; - } + + if (closid) + *closid =3D partid2closid(intpartid); } =20 void resctrl_arch_sched_in(struct task_struct *tsk) @@ -1822,6 +1847,91 @@ void mpam_resctrl_offline_cpu(unsigned int cpu) } } =20 +static int reqpartid_init(void) +{ + int req_num, idx; + + req_num =3D get_num_reqpartid(); + reqpartid_map =3D kcalloc(req_num, sizeof(u32), GFP_KERNEL); + if (!reqpartid_map) + return -ENOMEM; + + for (idx =3D 0; idx < req_num; idx++) + reqpartid_map[idx] =3D idx; + + return 0; +} + +static void reqpartid_exit(void) +{ + kfree(reqpartid_map); +} + +static void update_rmid_entries_for_reqpartid(u32 reqpartid) +{ + int pmg; + u32 intpartid =3D reqpartid_map[reqpartid]; + u32 closid =3D partid2closid(intpartid); + + for (pmg =3D 0; pmg <=3D mpam_pmg_max; pmg++) + rmid_entry_reassign_closid(closid, req_pmg2rmid(reqpartid, pmg)); +} + +int resctrl_arch_rmid_expand(u32 closid) +{ + int i; + + for (i =3D resctrl_arch_get_num_closid(NULL); + i < get_num_reqpartid(); i++) { + /* + * If reqpartid_map[i] > mpam_intpartid_max, + * it means the reqpartid 'i' is free. + */ + if (reqpartid_map[i] >=3D resctrl_arch_get_num_closid(NULL)) { + if (cdp_enabled) { + reqpartid_map[i] =3D resctrl_get_config_index(closid, CDP_DATA); + reqpartid_map[i + 1] =3D resctrl_get_config_index(closid, CDP_CODE); + } else { + reqpartid_map[i] =3D resctrl_get_config_index(closid, CDP_NONE); + } + update_rmid_entries_for_reqpartid(i); + return i; + } + } + + return -ENOSPC; +} + +void resctrl_arch_rmid_reclaim(u32 closid, u32 rmid) +{ + int pmg; + u32 intpartid; + int reqpartid =3D rmid2reqpartid(rmid); + + if (reqpartid < resctrl_arch_get_num_closid(NULL)) + return; + + if (cdp_enabled) + intpartid =3D resctrl_get_config_index(closid, CDP_DATA); + else + intpartid =3D resctrl_get_config_index(closid, CDP_NONE); + + WARN_ON_ONCE(intpartid !=3D req2intpartid(reqpartid)); + + for (pmg =3D 0; pmg <=3D mpam_pmg_max; pmg++) { + if (rmid_is_occupied(closid, req_pmg2rmid(reqpartid, pmg))) + break; + } + + if (pmg > mpam_pmg_max) { + reqpartid_map[reqpartid] =3D reqpartid; + if (cdp_enabled) + reqpartid_map[reqpartid + 1] =3D reqpartid + 1; + + update_rmid_entries_for_reqpartid(reqpartid); + } +} + int mpam_resctrl_setup(void) { int err =3D 0; @@ -1877,10 +1987,16 @@ int mpam_resctrl_setup(void) return -EOPNOTSUPP; } =20 - err =3D resctrl_init(); + err =3D reqpartid_init(); if (err) return err; =20 + err =3D resctrl_init(); + if (err) { + reqpartid_exit(); + return err; + } + WRITE_ONCE(resctrl_enabled, true); =20 return 0; @@ -1898,6 +2014,7 @@ void mpam_resctrl_exit(void) =20 WRITE_ONCE(resctrl_enabled, false); resctrl_exit(); + reqpartid_exit(); } =20 static void mpam_resctrl_teardown_mon(struct mpam_resctrl_mon *mon, struct= mpam_class *class) diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index f92a36187a52..d45422965907 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -59,6 +59,23 @@ void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u= 32 closid, u32 rmid); void resctrl_arch_sched_in(struct task_struct *tsk); bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid); bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid= ); + +/** + * resctrl_arch_rmid_expand() - Expand the RMID resources for the specifie= d closid. + * @closid: closid that matches the rmid. + * + * Return: + * 0 on success, or -ENOSPC etc on error. + */ +int resctrl_arch_rmid_expand(u32 closid); + +/** + * resctrl_arch_rmid_reclaim() - Reclaim the rmid resources for the specif= ied closid. + * @closid: closid that matches the rmid. + * @rmid: Reclaim the rmid specified. + */ +void resctrl_arch_rmid_reclaim(u32 closid, u32 rmid); + u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid); void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid); u32 resctrl_arch_system_num_rmid_idx(void); --=20 2.25.1 From nobody Mon Apr 6 23:20:38 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 A9AD73CB2E4 for ; Tue, 17 Mar 2026 13:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753722; cv=none; b=lC1cV7o5nGARQILleK0BthLeZnqFjEyCM6KTt28KeGWhVtP98fmo6yOMZwRJuiEmnvLwhjb9bOloxXCP9xjK/GN1Se4wIQ3WLuVlxjRGNr3399lHsx+FXVWR68hioMicsx9jtQp68BKqEDFFAICi/26GawB1V+BhJ34unCr/pM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753722; c=relaxed/simple; bh=+yFc+ApwwYuHmwbMlK/VTOFrbDxxd2l8YSrtwq+NH4U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FiHgKFn5YhS6eZBUmDT2d4V+6ESW411yL2Uk7mccNqwTBCtBFKZV3JACV6DPdMjcghjF9fP/t54Objplw6zoK+bjQDl+oPOzGnk17OMhGFKyGDlci3MyTQgeXMfQNQlk6e7VEhrLnnAwMtyFYLgfZty4TN6X04TqGmz5qc7rlGc= 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=mFnevj9R; arc=none smtp.client-ip=113.46.200.227 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="mFnevj9R" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=tDxYO41ssbPQ9d6hnkQIYtmLEz+3UCNl10f9cbj2TcM=; b=mFnevj9RkzxWzzRrMpaTBtCHJG17NxWdw7d7Ny7wl3sMQy3igy5g5lCK1cUGBL1+SCjZ8YpIQ 7CCVCgqrkWPlOoBwGmxLK4Nx1qQZqSvIruh9gsFniFWL0hXyPL2818UEh5vJAjs/ftXXn5sKxow yOReBF0NQmU5Uut+Ye/B3kg= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4fZst042LtznTXd; Tue, 17 Mar 2026 21:16:24 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id BC8E340565; Tue, 17 Mar 2026 21:21:56 +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.36; Tue, 17 Mar 2026 21:21:56 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 8/9] fs/resctrl: Wire up rmid expansion and reclaim functions Date: Tue, 17 Mar 2026 21:21:40 +0800 Message-ID: <20260317132141.1272506-9-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" The previous patch implemented resctrl_arch_rmid_expand() and resctrl_arch_rmid_reclaim() for ARM MPAM. This patch integrates these architecture-specific functions into the generic resctrl layer. Refactor resctrl_find_free_rmid() to support dynamic rmid expansion. If no free rmid is available for the current closid, attempt to expand via resctrl_arch_expand_rmid(). On success, retry the rmid allocation. As this capability is architecture-specific, x86 maintains existing behavior by returning -ENOSPC when rmid resources are exhausted. Additionally, invoke resctrl_arch_rmid_reclaim() when rmids are released to enable architecture-specific resource cleanup. Signed-off-by: Zeng Heng --- arch/x86/include/asm/resctrl.h | 7 +++++++ fs/resctrl/monitor.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 575f8408a9e7..7f8c8d84f2a0 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -167,6 +167,13 @@ static inline void resctrl_arch_sched_in(struct task_s= truct *tsk) __resctrl_sched_in(tsk); } =20 +static inline int resctrl_arch_rmid_expand(u32 closid) +{ + return -ENOSPC; +} + +static inline void resctrl_arch_rmid_reclaim(u32 closid, u32 rmid) {} + static inline void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 = *rmid) { *rmid =3D idx; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 4e78fb194c16..c58440eb7cc9 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -122,6 +122,8 @@ static void limbo_release_entry(struct rmid_entry *entr= y) =20 if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) closid_num_dirty_rmid[entry->closid]--; + + resctrl_arch_rmid_reclaim(entry->closid, entry->rmid); } =20 /* @@ -197,7 +199,7 @@ bool has_busy_rmid(struct rdt_l3_mon_domain *d) return find_first_bit(d->rmid_busy_llc, idx_limit) !=3D idx_limit; } =20 -static struct rmid_entry *resctrl_find_free_rmid(u32 closid) +static struct rmid_entry *__resctrl_find_free_rmid(u32 closid) { struct rmid_entry *itr; u32 itr_idx, cmp_idx; @@ -214,7 +216,12 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 c= losid) * very first entry will be returned. */ itr_idx =3D resctrl_arch_rmid_idx_encode(itr->closid, itr->rmid); + if (itr_idx =3D=3D U32_MAX) + continue; + cmp_idx =3D resctrl_arch_rmid_idx_encode(closid, itr->rmid); + if (cmp_idx =3D=3D U32_MAX) + continue; =20 if (itr_idx =3D=3D cmp_idx) return itr; @@ -223,6 +230,25 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 c= losid) return ERR_PTR(-ENOSPC); } =20 +static struct rmid_entry *resctrl_find_free_rmid(u32 closid) +{ + struct rmid_entry *err; + int ret; + + err =3D __resctrl_find_free_rmid(closid); + if (err =3D=3D ERR_PTR(-ENOSPC)) { + ret =3D resctrl_arch_rmid_expand(closid); + if (ret < 0) + /* Out of rmid */ + goto out; + + /* Try it again */ + return __resctrl_find_free_rmid(closid); + } +out: + return err; +} + /** * resctrl_find_cleanest_closid() - Find a CLOSID where all the associated * RMID are clean, or the CLOSID that has @@ -340,8 +366,10 @@ void free_rmid(u32 closid, u32 rmid) =20 if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) add_rmid_to_limbo(entry); - else + else { list_add_tail(&entry->list, &rmid_free_lru); + resctrl_arch_rmid_reclaim(closid, rmid); + } } =20 bool rmid_is_occupied(u32 closid, u32 rmid) --=20 2.25.1 From nobody Mon Apr 6 23:20:38 2026 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 5B9963CE49A for ; Tue, 17 Mar 2026 13:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753730; cv=none; b=JCC7iu5TQKKLiXaQvGbtdeAdY+bqhcQTBjxUSI+vGngUgCUy+6hOCqvfXPjmUBGJzXrV/ApKRQEYEUTPlzeEAoYzquQZrmo7886ptjxF+UOidhBCo/8QSpOvNl2JRoE36HKfcEibaXWUk9KNEwn6b8RmOZufvadNVDlHggftcu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753730; c=relaxed/simple; bh=gXKc6xiGrOQDe2rE4ZW/Iq7WjmdBTNcJFRnSUx7/Klw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OJaSFgI+qg7q1EOmnwc+yMHJOQxcjjCLVxBkUiGkvTcXjLXcKHwMCvGOKXTOkSW6DIyBsCaMlhaO9OP7PcjEFvp4Dfz0ZGbsoP/aapRScjbK/rd9lchDOc0saVfUqTbz3Z1sDPw7zA0kfB4sthUAJpPuy71TGrkl6EBBy6F5Vj4= 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=djga2MJ+; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=djga2MJ+; arc=none smtp.client-ip=45.249.212.187 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="djga2MJ+"; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="djga2MJ+" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=8Ibjo/AQobb5yHN47S0iXLZ9KLOAjQV8jMQfFXm9LQw=; b=djga2MJ+Jqy/mxs1KhNiW4nSdq7ppMaitLMdK/bImLEn2sje0z3+K2rc1ojEhMSNQg72XCn9+ DQMcbdfmu/3e28wYVzcaXXGZCrQ6u3r3ctiZvsvNGQF9US6iyJkBe5QiaqAvRpxdMWiCwagv5k2 pWZkndUB4Y+w7G3VU1YJD1o= Received: from canpmsgout03.his.huawei.com (unknown [172.19.92.159]) by szxga01-in.huawei.com (SkyGuard) with ESMTPS id 4fZszR5VPNz1BG50 for ; Tue, 17 Mar 2026 21:21:07 +0800 (CST) dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=8Ibjo/AQobb5yHN47S0iXLZ9KLOAjQV8jMQfFXm9LQw=; b=djga2MJ+Jqy/mxs1KhNiW4nSdq7ppMaitLMdK/bImLEn2sje0z3+K2rc1ojEhMSNQg72XCn9+ DQMcbdfmu/3e28wYVzcaXXGZCrQ6u3r3ctiZvsvNGQF9US6iyJkBe5QiaqAvRpxdMWiCwagv5k2 pWZkndUB4Y+w7G3VU1YJD1o= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4fZstC0lK7zpSwr; Tue, 17 Mar 2026 21:16:35 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 500DA404AD; Tue, 17 Mar 2026 21:21:57 +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.36; Tue, 17 Mar 2026 21:21:56 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 9/9] arm64/mpam: Add mpam_sync_config() for dynamic rmid expansion Date: Tue, 17 Mar 2026 21:21:41 +0800 Message-ID: <20260317132141.1272506-10-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" Add mpam_sync_config() to synchronize configuration when dynamically expanding rmid resources. When binding a new reqpartid to a control group, the driver maps the reqpartid to the corresponding intpartid or applies the control group's existing configuration to new partid if without Narrow partid feature. Extend mpam_apply_config() with 'sync' work mode: * Sync mode: mpam_sync_config() calls this to apply existing configuration without updating config. * Update(Non-sync) mode: resctrl_arch_update_one() calls this to compare, update, and apply configuration. This mode retains the original behavior. Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_devices.c | 23 ++++++++++++++++++----- drivers/resctrl/mpam_internal.h | 2 +- drivers/resctrl/mpam_resctrl.c | 29 ++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index 20ad06f66b88..b9a9c92a6367 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -1768,6 +1768,7 @@ struct mpam_write_config_arg { struct mpam_msc_ris *ris; struct mpam_component *comp; u16 partid; + bool sync; }; =20 static int __write_config(void *arg) @@ -1776,6 +1777,15 @@ static int __write_config(void *arg) struct mpam_write_config_arg *c =3D arg; u32 reqpartid; =20 + if (c->sync) { + /* c->partid should be within the range of reqPARTIDs */ + WARN_ON_ONCE(c->partid < closid_num); + + mpam_reprogram_ris_partid(c->ris, c->partid, + &c->comp->cfg[req2intpartid(c->partid)]); + return 0; + } + /* c->partid should be within the range of intPARTIDs */ WARN_ON_ONCE(c->partid >=3D closid_num); =20 @@ -3039,7 +3049,7 @@ static bool mpam_update_config(struct mpam_config *cf= g, } =20 int mpam_apply_config(struct mpam_component *comp, u16 partid, - struct mpam_config *cfg) + struct mpam_config *cfg, bool sync) { struct mpam_write_config_arg arg; struct mpam_msc_ris *ris; @@ -3048,14 +3058,17 @@ int mpam_apply_config(struct mpam_component *comp, = u16 partid, =20 lockdep_assert_cpus_held(); =20 - /* Don't pass in the current config! */ - WARN_ON_ONCE(&comp->cfg[partid] =3D=3D cfg); + if (!sync) { + /* The partid is within the range of intPARTIDs */ + WARN_ON_ONCE(partid >=3D resctrl_arch_get_num_closid(NULL)); =20 - if (!mpam_update_config(&comp->cfg[partid], cfg)) - return 0; + if (!mpam_update_config(&comp->cfg[partid], cfg)) + return 0; + } =20 arg.comp =3D comp; arg.partid =3D partid; + arg.sync =3D sync; =20 guard(srcu)(&mpam_srcu); list_for_each_entry_srcu(vmsc, &comp->vmsc, comp_list, diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_interna= l.h index 91f6d5f14a9e..321f60e909ba 100644 --- a/drivers/resctrl/mpam_internal.h +++ b/drivers/resctrl/mpam_internal.h @@ -478,7 +478,7 @@ void mpam_disable(struct work_struct *work); void mpam_reset_class_locked(struct mpam_class *class); =20 int mpam_apply_config(struct mpam_component *comp, u16 partid, - struct mpam_config *cfg); + struct mpam_config *cfg, bool sync); =20 int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx, enum mpam_device_features, u64 *val); diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index a91c0e22ef6b..0c6c97a0386f 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -1488,15 +1488,15 @@ int resctrl_arch_update_one(struct rdt_resource *r,= struct rdt_ctrl_domain *d, */ if (mpam_resctrl_hide_cdp(r->rid)) { partid =3D resctrl_get_config_index(closid, CDP_CODE); - err =3D mpam_apply_config(dom->ctrl_comp, partid, &cfg); + err =3D mpam_apply_config(dom->ctrl_comp, partid, &cfg, false); if (err) return err; =20 partid =3D resctrl_get_config_index(closid, CDP_DATA); - return mpam_apply_config(dom->ctrl_comp, partid, &cfg); + return mpam_apply_config(dom->ctrl_comp, partid, &cfg, false); } =20 - return mpam_apply_config(dom->ctrl_comp, partid, &cfg); + return mpam_apply_config(dom->ctrl_comp, partid, &cfg, false); } =20 int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) @@ -1877,6 +1877,23 @@ static void update_rmid_entries_for_reqpartid(u32 re= qpartid) rmid_entry_reassign_closid(closid, req_pmg2rmid(reqpartid, pmg)); } =20 +static int mpam_sync_config(u32 reqpartid) +{ + struct mpam_component *comp; + struct mpam_class *class; + int err; + + list_for_each_entry(class, &mpam_classes, classes_list) { + list_for_each_entry(comp, &class->components, class_list) { + err =3D mpam_apply_config(comp, reqpartid, NULL, true); + if (err) + return err; + } + } + + return 0; +} + int resctrl_arch_rmid_expand(u32 closid) { int i; @@ -1890,10 +1907,16 @@ int resctrl_arch_rmid_expand(u32 closid) if (reqpartid_map[i] >=3D resctrl_arch_get_num_closid(NULL)) { if (cdp_enabled) { reqpartid_map[i] =3D resctrl_get_config_index(closid, CDP_DATA); + mpam_sync_config(i); + reqpartid_map[i + 1] =3D resctrl_get_config_index(closid, CDP_CODE); + mpam_sync_config(i + 1); + } else { reqpartid_map[i] =3D resctrl_get_config_index(closid, CDP_NONE); + mpam_sync_config(i); } + update_rmid_entries_for_reqpartid(i); return i; } --=20 2.25.1