public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Zeng Heng <zengheng4@huawei.com>
To: <ben.horgan@arm.com>, <Dave.Martin@arm.com>,
	<james.morse@arm.com>, <tan.shaopeng@jp.fujitsu.com>,
	<reinette.chatre@intel.com>, <fenghuay@nvidia.com>,
	<tglx@kernel.org>, <will@kernel.org>, <hpa@zytor.com>,
	<bp@alien8.de>, <babu.moger@amd.com>,
	<dave.hansen@linux.intel.com>, <mingo@redhat.com>,
	<tony.luck@intel.com>, <gshan@redhat.com>,
	<catalin.marinas@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>, <wangkefeng.wang@huawei.com>
Subject: [PATCH v8 next 10/10] arm_mpam: Add mpam_sync_config() for dynamic rmid expansion
Date: Mon, 13 Apr 2026 16:54:05 +0800	[thread overview]
Message-ID: <20260413085405.1166412-11-zengheng4@huawei.com> (raw)
In-Reply-To: <20260413085405.1166412-1-zengheng4@huawei.com>

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 the '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 <zengheng4@huawei.com>
---
 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 cf94b45b4f9e..47345b8add3c 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1762,6 +1762,7 @@ struct mpam_write_config_arg {
 	struct mpam_msc_ris *ris;
 	struct mpam_component *comp;
 	u16 partid;
+	bool sync;
 };
 
 static int __write_config(void *arg)
@@ -1770,6 +1771,15 @@ static int __write_config(void *arg)
 	struct mpam_write_config_arg *c = arg;
 	u32 reqpartid;
 
+	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 >= closid_num);
 
@@ -2942,7 +2952,7 @@ static bool mpam_update_config(struct mpam_config *cfg,
 }
 
 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;
@@ -2951,14 +2961,17 @@ int mpam_apply_config(struct mpam_component *comp, u16 partid,
 
 	lockdep_assert_cpus_held();
 
-	/* Don't pass in the current config! */
-	WARN_ON_ONCE(&comp->cfg[partid] == cfg);
+	if (!sync) {
+		/* The partid is within the range of intPARTIDs */
+		WARN_ON_ONCE(partid >= resctrl_arch_get_num_closid(NULL));
 
-	if (!mpam_update_config(&comp->cfg[partid], cfg))
-		return 0;
+		if (!mpam_update_config(&comp->cfg[partid], cfg))
+			return 0;
+	}
 
 	arg.comp = comp;
 	arg.partid = partid;
+	arg.sync = sync;
 
 	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_internal.h
index 16ce968344d0..90c8f8d16c79 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -464,7 +464,7 @@ void mpam_disable(struct work_struct *work);
 void mpam_reset_class_locked(struct mpam_class *class);
 
 int mpam_apply_config(struct mpam_component *comp, u16 partid,
-		      struct mpam_config *cfg);
+		      struct mpam_config *cfg, bool sync);
 
 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 2762462d80e5..5a97a7f18670 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1329,15 +1329,15 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
 	 */
 	if (mpam_resctrl_hide_cdp(r->rid)) {
 		partid = resctrl_get_config_index(closid, CDP_CODE);
-		err = mpam_apply_config(dom->ctrl_comp, partid, &cfg);
+		err = mpam_apply_config(dom->ctrl_comp, partid, &cfg, false);
 		if (err)
 			return err;
 
 		partid = 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);
 	}
 
-	return mpam_apply_config(dom->ctrl_comp, partid, &cfg);
+	return mpam_apply_config(dom->ctrl_comp, partid, &cfg, false);
 }
 
 int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
@@ -1718,6 +1718,23 @@ static void update_rmid_entries_for_reqpartid(u32 reqpartid)
 		rmid_entry_reassign_closid(closid, req_pmg2rmid(reqpartid, pmg));
 }
 
+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 = mpam_apply_config(comp, reqpartid, NULL, true);
+			if (err)
+				return err;
+		}
+	}
+
+	return 0;
+}
+
 int resctrl_arch_rmid_expand(u32 closid)
 {
 	int i;
@@ -1729,14 +1746,20 @@ int resctrl_arch_rmid_expand(u32 closid)
 		if (reqpartid_map[i] >= resctrl_arch_get_num_closid(NULL)) {
 			if (cdp_enabled) {
 				reqpartid_map[i] = resctrl_get_config_index(closid, CDP_DATA);
+				mpam_sync_config(i);
+
 				/*
 				 * Reqpartids are always allocated in
 				 * pairs, never out-of-bounds access.
 				 */
 				reqpartid_map[i + 1] = resctrl_get_config_index(closid, CDP_CODE);
+				mpam_sync_config(i + 1);
+
 			} else {
 				reqpartid_map[i] = resctrl_get_config_index(closid, CDP_NONE);
+				mpam_sync_config(i);
 			}
+
 			update_rmid_entries_for_reqpartid(i);
 			return i;
 		}
-- 
2.25.1



  parent reply	other threads:[~2026-04-13  8:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  8:53 [PATCH v8 next 00/10] arm_mpam: Introduce Narrow-PARTID feature Zeng Heng
2026-04-13  8:53 ` [PATCH v8 next 01/10] fs/resctrl: Fix MPAM Partid parsing errors by preserving CDP state during umount Zeng Heng
2026-04-13  8:53 ` [PATCH v8 next 02/10] arm_mpam: Add intPARTID and reqPARTID support for Narrow-PARTID feature Zeng Heng
2026-04-13  8:53 ` [PATCH v8 next 03/10] arm_mpam: Disable reqPARTID expansion when Narrow-PARTID is unavailable Zeng Heng
2026-04-13  8:53 ` [PATCH v8 next 04/10] arm_mpam: Refactor rmid to reqPARTID/PMG mapping Zeng Heng
2026-04-13  8:54 ` [PATCH v8 next 05/10] arm_mpam: Propagate control group config to sub-monitoring groups Zeng Heng
2026-04-13  8:54 ` [PATCH v8 next 06/10] arm_mpam: Add boot parameter to limit mpam_intpartid_max Zeng Heng
2026-04-13  8:54 ` [PATCH v8 next 07/10] fs/resctrl: Add rmid_entry state helpers Zeng Heng
2026-04-13  8:54 ` [PATCH v8 next 08/10] arm_mpam: Implement dynamic reqPARTID allocation for monitoring groups Zeng Heng
2026-04-13  8:54 ` [PATCH v8 next 09/10] fs/resctrl: Wire up rmid expansion and reclaim functions Zeng Heng
2026-04-13  8:54 ` Zeng Heng [this message]
2026-04-16  6:29 ` [PATCH v8 next 00/10] arm_mpam: Introduce Narrow-PARTID feature Shaopeng Tan (Fujitsu)
2026-04-20  7:31 ` Zeng Heng
2026-04-28  4:20   ` Shaopeng Tan (Fujitsu)
2026-04-29  9:47     ` Zeng Heng
2026-04-29 10:59 ` Zeng Heng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260413085405.1166412-11-zengheng4@huawei.com \
    --to=zengheng4@huawei.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=ben.horgan@arm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghuay@nvidia.com \
    --cc=gshan@redhat.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=tan.shaopeng@jp.fujitsu.com \
    --cc=tglx@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox