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