From nobody Tue Apr 7 00:46:15 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