From: Yunhui Cui <cuiyunhui@bytedance.com>
To: tony.luck@intel.com, reinette.chatre@intel.com,
ben.horgan@arm.com, Dave.Martin@arm.com, james.morse@arm.com,
babu.moger@amd.com, fustini@kernel.org, tglx@kernel.org,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
hpa@zytor.com, fenghuay@nvidia.com, shuah@kernel.org,
corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org,
x86@kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org,
kunit-dev@googlegroups.com, linux-doc@vger.kernel.org
Cc: Yunhui Cui <cuiyunhui@bytedance.com>
Subject: [RFC PATCH 05/13] arm_mpam: Select PARTID narrowing per component
Date: Mon, 30 Nov 2026 10:29:21 +0800 [thread overview]
Message-ID: <20261130022929.71748-6-cuiyunhui@bytedance.com> (raw)
In-Reply-To: <20261130022929.71748-1-cuiyunhui@bytedance.com>
A component may contain RIS from more than one MSC. It can use PARTID
narrowing only when every MSC provides internal PARTIDs; otherwise the
same request PARTID would be mapped on some paths and used directly on
others.
All RIS in an MSC share one PARTID mapping table, even when they belong
to different components. Select narrowing only when every component
connected to that MSC can use it; otherwise keep those components on
direct indexing.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 73 +++++++++++++++++++++++++++++++++
drivers/resctrl/mpam_internal.h | 2 +
2 files changed, 75 insertions(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index e2791d5368765..7cf4f4eece192 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2831,6 +2831,78 @@ static void mpam_enable_merge_class_features(struct mpam_component *comp)
mpam_clear_feature(mpam_feat_mbw_min, &class->props);
}
+static bool mpam_component_all_mscs_narrow(struct mpam_component *comp)
+{
+ struct mpam_vmsc *vmsc;
+ bool found = false;
+
+ if (comp->class->type == MPAM_CLASS_UNKNOWN)
+ return false;
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
+ if (!vmsc->msc->nr_intpartids)
+ return false;
+ found = true;
+ }
+
+ return found;
+}
+
+bool mpam_component_uses_partid_narrowing(struct mpam_component *comp)
+{
+ return comp->uses_partid_narrowing;
+}
+
+static bool mpam_component_shares_direct_msc(struct mpam_component *comp)
+{
+ struct mpam_vmsc *vmsc;
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
+ struct mpam_msc_ris *ris;
+
+ list_for_each_entry(ris, &vmsc->msc->ris, msc_list) {
+ struct mpam_component *other = ris->vmsc->comp;
+
+ if (other->class && other->class->type != MPAM_CLASS_UNKNOWN &&
+ !other->uses_partid_narrowing)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static void mpam_enable_set_partid_narrowing(struct list_head *classes)
+{
+ struct mpam_component *comp;
+ struct mpam_class *class;
+ bool changed;
+
+ lockdep_assert_held(&mpam_list_lock);
+
+ list_for_each_entry(class, classes, classes_list) {
+ list_for_each_entry(comp, &class->components, class_list)
+ comp->uses_partid_narrowing =
+ mpam_component_all_mscs_narrow(comp);
+ }
+
+ /* An MSC has one mapping table, including when components share it. */
+ do {
+ changed = false;
+ list_for_each_entry(class, classes, classes_list) {
+ if (class->type == MPAM_CLASS_UNKNOWN)
+ continue;
+ list_for_each_entry(comp, &class->components, class_list) {
+ if (!comp->uses_partid_narrowing ||
+ !mpam_component_shares_direct_msc(comp))
+ continue;
+ comp->uses_partid_narrowing = false;
+ changed = true;
+ }
+ }
+ } while (changed);
+}
+
/*
* Merge all the common resource features into class.
* vmsc features are bitwise-or'd together by mpam_enable_merge_vmsc_features()
@@ -3206,6 +3278,7 @@ static void mpam_enable_once(void)
mutex_lock(&mpam_list_lock);
do {
mpam_enable_merge_features(&mpam_classes);
+ mpam_enable_set_partid_narrowing(&mpam_classes);
err = mpam_register_irqs();
if (err) {
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 90430bd208ee8..25744cefe43f3 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -371,6 +371,7 @@ struct mpam_config {
struct mpam_component {
u32 comp_id;
+ bool uses_partid_narrowing;
/* mpam_vmsc in this component */
struct list_head vmsc;
@@ -515,6 +516,7 @@ int mpam_reset_class_locked(struct mpam_class *class);
int mpam_apply_config(struct mpam_component *comp, u16 partid,
struct mpam_config *cfg);
+bool mpam_component_uses_partid_narrowing(struct mpam_component *comp);
int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx,
enum mpam_device_features, u64 *val);
--
2.39.2 (Apple Git-143)
next prev parent reply other threads:[~2026-11-30 2:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 01/13] resctrl: Introduce interfaces " Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 02/13] resctrl: Add prepare, commit and abort hooks for control updates Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 03/13] resctrl: Add a release hook before logical control ID reuse Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 04/13] arm_mpam: Record PARTID narrowing capacity per MSC Yunhui Cui
2026-11-30 2:29 ` Yunhui Cui [this message]
2026-11-30 2:29 ` [RFC PATCH 06/13] arm_mpam: Add an internal PARTID allocator Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 07/13] arm_mpam: Add request-to-internal PARTID mapping Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 08/13] arm_mpam: Apply PARTID narrowing to resctrl control groups Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 09/13] arm_mpam: Separate request and internal PARTID limits Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 10/13] arm_mpam: Map CDP data and code defaults separately Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 11/13] arm_mpam: Add kunit tests for PARTID narrowing Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 12/13] selftests/resctrl: Add a test for control ID allocation and reuse Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 13/13] docs/resctrl: Document logical control IDs and hardware entries Yunhui Cui
2026-11-30 6:15 ` [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Jinjie Ruan
2026-11-30 6:56 ` [External] " yunhui cui
2026-11-30 7:29 ` Jinjie Ruan
2026-11-30 11:22 ` Ben Horgan
2026-11-30 12:09 ` Jinjie Ruan
2026-11-30 14:09 ` [External] " yunhui cui
2026-11-30 15:22 ` Ben Horgan
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=20261130022929.71748-6-cuiyunhui@bytedance.com \
--to=cuiyunhui@bytedance.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=fenghuay@nvidia.com \
--cc=fustini@kernel.org \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mingo@redhat.com \
--cc=rdunlap@infradead.org \
--cc=reinette.chatre@intel.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--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
all inboxes | Powered by JetHome®