* [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs
@ 2026-11-30 2:29 Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 01/13] resctrl: Introduce interfaces " Yunhui Cui
` (13 more replies)
0 siblings, 14 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
Some resource controllers can accept a wider request-ID namespace than
the number of configuration entries they provide. Arm MPAM PARTID
narrowing is one example: requests carry a PARTID, while an MSC maps it
to a smaller internal PARTID table. A future RISC-V CBQRI backend is
expected to need a similar mapping from request RCIDs to controller-local
entries. Resctrl currently uses one ID both to identify a control group
and to select its hardware entry, so the smallest table limits the number
of groups exposed to user space.
The framework uses a logical control ID in generic resctrl while each
architecture selects a hardware entry according to its own model:
generic resctrl
logical control ID
|
+------------------+------------------+
| | |
x86 arm64 MPAM RISC-V CBQRI
direct index MSC mapping mapping (proposed)
| | |
hardware entry internal PARTID controller entry
Without controller-local request-ID mapping, the same request ID directly
indexes every controller. If g1 configures only A and g2 only B, g1
cannot select its private entry in A and B's root entry while g2 makes
the opposite selection. Each group therefore consumes an entry in both
controllers. Controller-local mapping makes these selections independent,
so A needs entries only for the root group and g1 while B needs only the
root group and g2.
This series gives control groups logical IDs. A new group initially
selects the root policy and consumes no private entry on a narrowing
controller. Its first explicit policy write allocates and programs an
entry only on the affected controllers, then publishes the
request-to-internal ID mapping. Controllers that have not been configured
continue to follow the root policy. A same-value write still creates a
private policy, so a later root update does not change it.
Entry reservation is completed before a multi-controller policy update
and mapping changes are published only after the entries are programmed.
Group removal maps requests back to the root entry before an internal
entry or logical ID can be reused. CDP keeps separate data and code root
entries so the default policies remain distinct.
Identity-mapped architectures retain their current behavior, and I/O
allocation continues to address a hardware entry directly. The generic
framework supports both direct-index and mapped controllers. The RISC-V
backend itself is outside this series.
Base: next-20261127
Yunhui Cui (13):
resctrl: Introduce interfaces for logical control IDs
resctrl: Add prepare, commit and abort hooks for control updates
resctrl: Add a release hook before logical control ID reuse
arm_mpam: Record PARTID narrowing capacity per MSC
arm_mpam: Select PARTID narrowing per component
arm_mpam: Add an internal PARTID allocator
arm_mpam: Add request-to-internal PARTID mapping
arm_mpam: Apply PARTID narrowing to resctrl control groups
arm_mpam: Separate request and internal PARTID limits
arm_mpam: Map CDP data and code defaults separately
arm_mpam: Add kunit tests for PARTID narrowing
selftests/resctrl: Add a test for control ID allocation and reuse
docs/resctrl: Document logical control IDs and hardware entries
Documentation/filesystems/resctrl.rst | 88 ++
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 38 +-
drivers/resctrl/mpam_devices.c | 857 +++++++++++++++++-
drivers/resctrl/mpam_internal.h | 25 +-
drivers/resctrl/mpam_resctrl.c | 288 +++++-
drivers/resctrl/test_mpam_devices.c | 619 ++++++++++++-
drivers/resctrl/test_mpam_resctrl.c | 172 ++++
fs/resctrl/ctrlmondata.c | 28 +-
fs/resctrl/rdtgroup.c | 18 +-
include/linux/resctrl.h | 17 +-
.../testing/selftests/resctrl/ctrl_id_test.c | 380 ++++++++
tools/testing/selftests/resctrl/resctrl.h | 1 +
.../testing/selftests/resctrl/resctrl_tests.c | 1 +
13 files changed, 2470 insertions(+), 62 deletions(-)
create mode 100644 tools/testing/selftests/resctrl/ctrl_id_test.c
--
2.39.2 (Apple Git-143)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [RFC PATCH 01/13] resctrl: Introduce interfaces for logical control IDs
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
@ 2026-11-30 2:29 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 02/13] resctrl: Add prepare, commit and abort hooks for control updates Yunhui Cui
` (12 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
resctrl currently uses a control group ID both to identify the group and
to select a hardware entry. Request-ID mapping allows these IDs to
differ, while I/O allocation continues to identify a physical entry.
Introduce separate architecture interfaces for control-group
initialization, policy updates and I/O allocation. The x86 and MPAM
backends retain their existing identity behavior.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 +++++++++++++++++--
drivers/resctrl/mpam_resctrl.c | 19 +++++++++++++++++--
fs/resctrl/ctrlmondata.c | 4 ++--
fs/resctrl/rdtgroup.c | 2 +-
include/linux/resctrl.h | 7 ++++++-
5 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 46ec3fa368ebf..1c2b20f623a37 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -47,7 +47,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
return 0;
}
-int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
+static int resctrl_arch_update_domains_id(struct rdt_resource *r, u32 id)
{
struct resctrl_staged_config *cfg;
struct rdt_hw_ctrl_domain *hw_dom;
@@ -67,7 +67,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
if (!cfg->have_new_ctrl)
continue;
- idx = resctrl_get_config_index(closid, t);
+ idx = resctrl_get_config_index(id, t);
if (cfg->new_ctrl == hw_dom->ctrl_val[idx])
continue;
hw_dom->ctrl_val[idx] = cfg->new_ctrl;
@@ -89,6 +89,21 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
return 0;
}
+int resctrl_arch_init_ctrl_domains(struct rdt_resource *r, u32 logical_ctrl_id)
+{
+ return resctrl_arch_update_domains_id(r, logical_ctrl_id);
+}
+
+int resctrl_arch_update_domains(struct rdt_resource *r, u32 logical_ctrl_id)
+{
+ return resctrl_arch_update_domains_id(r, logical_ctrl_id);
+}
+
+int resctrl_arch_update_io_alloc(struct rdt_resource *r, u32 physical_ctrl_id)
+{
+ return resctrl_arch_update_domains_id(r, physical_ctrl_id);
+}
+
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type type)
{
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 5468367776e26..2cb098eaf22a1 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1505,7 +1505,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
return mpam_apply_config(dom->ctrl_comp, partid, &cfg);
}
-int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
+static int resctrl_arch_update_domains_id(struct rdt_resource *r, u32 id)
{
int err;
struct rdt_ctrl_domain *d;
@@ -1523,7 +1523,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
if (!cfg->have_new_ctrl)
continue;
- err = resctrl_arch_update_one(r, d, closid, t,
+ err = resctrl_arch_update_one(r, d, id, t,
cfg->new_ctrl);
if (err)
return err;
@@ -1533,6 +1533,21 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
return 0;
}
+int resctrl_arch_init_ctrl_domains(struct rdt_resource *r, u32 logical_ctrl_id)
+{
+ return resctrl_arch_update_domains_id(r, logical_ctrl_id);
+}
+
+int resctrl_arch_update_domains(struct rdt_resource *r, u32 logical_ctrl_id)
+{
+ return resctrl_arch_update_domains_id(r, logical_ctrl_id);
+}
+
+int resctrl_arch_update_io_alloc(struct rdt_resource *r, u32 physical_ctrl_id)
+{
+ return resctrl_arch_update_domains_id(r, physical_ctrl_id);
+}
+
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
{
struct mpam_resctrl_res *res;
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index a37b245fd02a0..eb3248350254b 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -827,7 +827,7 @@ static int resctrl_io_alloc_init_cbm(struct resctrl_schema *s, u32 closid)
sizeof(d->staged_config[0]));
}
- ret = resctrl_arch_update_domains(r, closid);
+ ret = resctrl_arch_update_io_alloc(r, closid);
out:
rdt_staged_configs_clear();
return ret;
@@ -1058,7 +1058,7 @@ ssize_t resctrl_io_alloc_cbm_write(struct kernfs_open_file *of, char *buf,
if (ret)
goto out_clear_configs;
- ret = resctrl_arch_update_domains(r, io_alloc_closid);
+ ret = resctrl_arch_update_io_alloc(r, io_alloc_closid);
out_clear_configs:
rdt_staged_configs_clear();
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index c56cc1507c917..caa9fe68308e5 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -3861,7 +3861,7 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
goto out;
}
- ret = resctrl_arch_update_domains(r, rdtgrp->closid);
+ ret = resctrl_arch_init_ctrl_domains(r, rdtgrp->closid);
if (ret < 0) {
rdt_last_cmd_puts("Failed to initialize allocations\n");
goto out;
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index b6b4519a51908..a5e3e4b3fd836 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -410,7 +410,12 @@ static inline u32 resctrl_get_default_ctrl(struct rdt_resource *r)
/* The number of closid supported by this resource regardless of CDP */
u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
u32 resctrl_arch_system_num_rmid_idx(void);
-int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
+
+int resctrl_arch_init_ctrl_domains(struct rdt_resource *r, u32 logical_ctrl_id);
+
+int resctrl_arch_update_domains(struct rdt_resource *r, u32 logical_ctrl_id);
+
+int resctrl_arch_update_io_alloc(struct rdt_resource *r, u32 physical_ctrl_id);
bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,
unsigned int binary_bits, void *arch_priv);
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 02/13] resctrl: Add prepare, commit and abort hooks for control updates
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 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 03/13] resctrl: Add a release hook before logical control ID reuse Yunhui Cui
` (11 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
A schemata write may update several controllers, and allocating entries
while each controller is programmed can leave a partial update if a
later allocation fails. Add prepare, commit and abort hooks so mapping
backends can reserve all required entries before programming policies,
publish mappings after the updates succeed, and discard reservations on
failure. Identity backends use no-op hooks.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 14 +++++++++++++
drivers/resctrl/mpam_resctrl.c | 14 +++++++++++++
fs/resctrl/ctrlmondata.c | 24 +++++++++++++++++++++--
include/linux/resctrl.h | 7 +++++++
4 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 1c2b20f623a37..f6ecbf10ca700 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -104,6 +104,20 @@ int resctrl_arch_update_io_alloc(struct rdt_resource *r, u32 physical_ctrl_id)
return resctrl_arch_update_domains_id(r, physical_ctrl_id);
}
+int resctrl_arch_prepare_ctrl_update(u32 logical_ctrl_id)
+{
+ return 0;
+}
+
+int resctrl_arch_commit_ctrl_update(u32 logical_ctrl_id)
+{
+ return 0;
+}
+
+void resctrl_arch_abort_ctrl_update(u32 logical_ctrl_id)
+{
+}
+
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type type)
{
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 2cb098eaf22a1..9d34b1c214d32 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1548,6 +1548,20 @@ int resctrl_arch_update_io_alloc(struct rdt_resource *r, u32 physical_ctrl_id)
return resctrl_arch_update_domains_id(r, physical_ctrl_id);
}
+int resctrl_arch_prepare_ctrl_update(u32 logical_ctrl_id)
+{
+ return 0;
+}
+
+int resctrl_arch_commit_ctrl_update(u32 logical_ctrl_id)
+{
+ return 0;
+}
+
+void resctrl_arch_abort_ctrl_update(u32 logical_ctrl_id)
+{
+}
+
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
{
struct mpam_resctrl_res *res;
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index eb3248350254b..4e95f5ded87cb 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -349,6 +349,12 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
goto out_clear_staged;
}
+ ret = resctrl_arch_prepare_ctrl_update(rdtgrp->closid);
+ if (ret) {
+ rdt_last_cmd_printf("Failed to prepare control update: %d\n", ret);
+ goto out_clear_staged;
+ }
+
list_for_each_entry(s, &resctrl_schema_all, list) {
r = s->res;
@@ -360,8 +366,17 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
continue;
ret = resctrl_arch_update_domains(r, rdtgrp->closid);
- if (ret)
- goto out_clear_staged;
+ if (ret) {
+ rdt_last_cmd_printf("Failed to update resource %s: %d\n",
+ r->name, ret);
+ goto out_abort_update;
+ }
+ }
+
+ ret = resctrl_arch_commit_ctrl_update(rdtgrp->closid);
+ if (ret) {
+ rdt_last_cmd_printf("Failed to commit control update: %d\n", ret);
+ goto out_abort_update;
}
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
@@ -374,6 +389,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
ret = rdtgroup_pseudo_lock_create(rdtgrp);
}
+ goto out_clear_staged;
+
+out_abort_update:
+ resctrl_arch_abort_ctrl_update(rdtgrp->closid);
+
out_clear_staged:
rdt_staged_configs_clear();
out_unlock:
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index a5e3e4b3fd836..db6558a8f47eb 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -417,6 +417,13 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 logical_ctrl_id);
int resctrl_arch_update_io_alloc(struct rdt_resource *r, u32 physical_ctrl_id);
+/* Failed prepare unwinds its reservations; later failures call abort. */
+int resctrl_arch_prepare_ctrl_update(u32 logical_ctrl_id);
+
+int resctrl_arch_commit_ctrl_update(u32 logical_ctrl_id);
+
+void resctrl_arch_abort_ctrl_update(u32 logical_ctrl_id);
+
bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,
unsigned int binary_bits, void *arch_priv);
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 03/13] resctrl: Add a release hook before logical control ID reuse
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 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 04/13] arm_mpam: Record PARTID narrowing capacity per MSC Yunhui Cui
` (10 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
A logical control ID may be reused after its group is removed, but any
remaining controller mapping would make the new group select the old
policy. Add a release hook after tasks and CPUs leave the group and
before the logical ID is freed. If release fails, keep the group and ID
for retry; apply the same rule to failed group creation by quarantining
an ID whose entries cannot be released.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 5 +++++
drivers/resctrl/mpam_resctrl.c | 5 +++++
fs/resctrl/rdtgroup.c | 16 ++++++++++++++--
include/linux/resctrl.h | 3 +++
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index f6ecbf10ca700..4635069df6174 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -118,6 +118,11 @@ void resctrl_arch_abort_ctrl_update(u32 logical_ctrl_id)
{
}
+int resctrl_arch_release_ctrl_entries(u32 logical_ctrl_id)
+{
+ return 0;
+}
+
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type type)
{
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 9d34b1c214d32..72b4f2b2e4b6e 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1562,6 +1562,11 @@ void resctrl_arch_abort_ctrl_update(u32 logical_ctrl_id)
{
}
+int resctrl_arch_release_ctrl_entries(u32 logical_ctrl_id)
+{
+ return 0;
+}
+
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
{
struct mpam_resctrl_res *res;
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index caa9fe68308e5..30dfdc1edbf00 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4125,7 +4125,11 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
out_rmid_free:
mkdir_rdt_prepare_rmid_free(rdtgrp);
out_closid_free:
- closid_free(closid);
+ if (resctrl_arch_release_ctrl_entries(closid))
+ rdt_last_cmd_printf("Control ID %u quarantined after failed creation\n",
+ closid);
+ else
+ closid_free(closid);
out_common_fail:
mkdir_rdt_prepare_clean(rdtgrp);
out_unlock:
@@ -4209,7 +4213,7 @@ static int rdtgroup_ctrl_remove(struct rdtgroup *rdtgrp)
static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
{
u32 closid, rmid;
- int cpu;
+ int cpu, ret;
/* Give any tasks back to the default group */
rdt_move_group_tasks(rdtgrp, &rdtgroup_default, tmpmask);
@@ -4231,6 +4235,14 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask);
update_closid_rmid(tmpmask, NULL);
+ ret = resctrl_arch_release_ctrl_entries(rdtgrp->closid);
+ cpumask_clear(&rdtgrp->cpu_mask);
+ if (ret) {
+ rdt_last_cmd_printf("Failed to release control ID %u: %d\n",
+ rdtgrp->closid, ret);
+ return ret;
+ }
+
rdtgroup_unassign_cntrs(rdtgrp);
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index db6558a8f47eb..495acf2f83ce6 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -424,6 +424,9 @@ int resctrl_arch_commit_ctrl_update(u32 logical_ctrl_id);
void resctrl_arch_abort_ctrl_update(u32 logical_ctrl_id);
+/* Retire entries before ID reuse; partial cleanup must be retryable. */
+int resctrl_arch_release_ctrl_entries(u32 logical_ctrl_id);
+
bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,
unsigned int binary_bits, void *arch_priv);
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 04/13] arm_mpam: Record PARTID narrowing capacity per MSC
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (2 preceding siblings ...)
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 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 05/13] arm_mpam: Select PARTID narrowing per component Yunhui Cui
` (9 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
PARTID_NRW_IDR reports the number of internal PARTIDs provided by an MSC
and is not selected by RIS, so every RIS in an MSC sees the same
capacity. Record the internal PARTID count when the first usable
narrowing RIS is probed and use it for the existing request PARTID limit
instead of reading the same register for each RIS. No functional change
is intended.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 25 +++++++++++--------------
drivers/resctrl/mpam_internal.h | 1 +
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 27abf60f4d675..e2791d5368765 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1131,25 +1131,22 @@ static int mpam_ris_hw_probe(struct mpam_msc_ris *ris)
}
}
- /*
- * RIS with PARTID narrowing don't have enough storage for one
- * configuration per PARTID. If these are in a class we could use,
- * reduce the supported partid_max to match the number of intpartid.
- * If the class is unknown, just ignore it.
- */
+ /* Cache the MSC-wide limit without probing unused resource classes. */
if (FIELD_GET(MPAMF_IDR_HAS_PARTID_NRW, ris->idr) &&
class->type != MPAM_CLASS_UNKNOWN) {
- u16 partid_max;
u32 nrwidr;
- err = mpam_read_partsel_reg(msc, PARTID_NRW_IDR, &nrwidr);
- if (err)
- return err;
-
- partid_max = FIELD_GET(MPAMF_PARTID_NRW_IDR_INTPARTID_MAX, nrwidr);
-
+ if (!msc->nr_intpartids) {
+ err = mpam_read_partsel_reg(msc, PARTID_NRW_IDR, &nrwidr);
+ if (err)
+ return err;
+ msc->nr_intpartids =
+ FIELD_GET(MPAMF_PARTID_NRW_IDR_INTPARTID_MAX,
+ nrwidr) + 1;
+ }
mpam_set_feature(mpam_feat_partid_nrw, props);
- msc->partid_max = min(msc->partid_max, partid_max);
+ msc->partid_max = min_t(u32, msc->partid_max,
+ msc->nr_intpartids - 1);
}
return 0;
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 1f86cc158100b..90430bd208ee8 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -94,6 +94,7 @@ struct mpam_msc {
struct mutex probe_lock;
bool probed;
u16 partid_max;
+ u32 nr_intpartids;
u8 pmg_max;
unsigned long ris_idxs;
u32 ris_max;
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 05/13] arm_mpam: Select PARTID narrowing per component
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (3 preceding siblings ...)
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
2026-11-30 2:29 ` [RFC PATCH 06/13] arm_mpam: Add an internal PARTID allocator Yunhui Cui
` (8 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
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)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 06/13] arm_mpam: Add an internal PARTID allocator
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (4 preceding siblings ...)
2026-11-30 2:29 ` [RFC PATCH 05/13] arm_mpam: Select PARTID narrowing per component Yunhui Cui
@ 2026-11-30 2:29 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 07/13] arm_mpam: Add request-to-internal PARTID mapping Yunhui Cui
` (7 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
PARTID narrowing allows an MSC to accept more request PARTIDs than it
has internal configuration entries. A logical PARTID only needs its own
internal PARTID when it requires a private policy, and different MSCs
may choose different internal PARTIDs for the same logical PARTID.
Allocate internal PARTIDs at MSC scope because all RIS in an MSC share
one mapping table. Reserve internal PARTID 0 for the root policy and
check every MSC serving a component before making any reservation, so
running out of entries cannot leave a partial allocation.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 176 +++++++++++++++++++++++++++++++-
drivers/resctrl/mpam_internal.h | 9 +-
2 files changed, 181 insertions(+), 4 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 7cf4f4eece192..b4ee5a0354bfa 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -153,6 +153,7 @@ u16 mpam_partid_max;
u8 mpam_pmg_max;
static bool partid_max_init, partid_max_published;
static DEFINE_SPINLOCK(partid_max_lock);
+static DEFINE_MUTEX(partid_map_lock);
/*
* mpam is enabled once all devices have been probed from CPU online callbacks,
@@ -2853,6 +2854,132 @@ bool mpam_component_uses_partid_narrowing(struct mpam_component *comp)
return comp->uses_partid_narrowing;
}
+static bool __mpam_component_has_partid_entries(struct mpam_component *comp,
+ u16 logical_partid)
+{
+ struct mpam_vmsc *vmsc;
+
+ if (!comp->uses_partid_narrowing || logical_partid == 0)
+ return true;
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list)
+ if (!test_bit(logical_partid, vmsc->msc->partid_has_entry))
+ return false;
+
+ return true;
+}
+
+bool mpam_component_has_partid_entries(struct mpam_component *comp,
+ u16 logical_partid)
+{
+ guard(mutex)(&partid_map_lock);
+
+ return __mpam_component_has_partid_entries(comp, logical_partid);
+}
+
+static bool mpam_partid_seen(const u16 *logical_partids, size_t nr_partids,
+ u16 logical_partid)
+{
+ size_t i;
+
+ for (i = 0; i < nr_partids; i++) {
+ if (logical_partids[i] == logical_partid)
+ return true;
+ }
+
+ return false;
+}
+
+static unsigned int mpam_count_new_partid_entries(struct mpam_msc *msc,
+ const u16 *logical_partids,
+ size_t nr_partids)
+{
+ unsigned int needed = 0;
+ size_t i;
+
+ for (i = 0; i < nr_partids; i++) {
+ u16 logical_partid = logical_partids[i];
+
+ if (!logical_partid ||
+ test_bit(logical_partid, msc->partid_has_entry) ||
+ mpam_partid_seen(logical_partids, i, logical_partid))
+ continue;
+ needed++;
+ }
+
+ return needed;
+}
+
+static int mpam_preflight_partid_entries(struct mpam_component *comp,
+ const u16 *logical_partids,
+ size_t nr_partids)
+{
+ struct mpam_vmsc *vmsc;
+
+ lockdep_assert_held(&partid_map_lock);
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
+ struct mpam_msc *msc = vmsc->msc;
+ unsigned int free, needed;
+
+ needed = mpam_count_new_partid_entries(msc, logical_partids,
+ nr_partids);
+ free = msc->nr_intpartids -
+ bitmap_weight(msc->intpartid_allocated,
+ msc->nr_intpartids);
+ if (free < needed)
+ return -ENOSPC;
+ }
+
+ return 0;
+}
+
+static void mpam_allocate_partid_entries(struct mpam_component *comp,
+ const u16 *logical_partids,
+ size_t nr_partids)
+{
+ struct mpam_vmsc *vmsc;
+ size_t i;
+
+ lockdep_assert_held(&partid_map_lock);
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
+ struct mpam_msc *msc = vmsc->msc;
+
+ for (i = 0; i < nr_partids; i++) {
+ u16 logical_partid = logical_partids[i];
+ u16 intpartid;
+
+ if (!logical_partid ||
+ test_bit(logical_partid, msc->partid_has_entry))
+ continue;
+ intpartid = find_next_zero_bit(msc->intpartid_allocated,
+ msc->nr_intpartids, 1);
+ __set_bit(intpartid, msc->intpartid_allocated);
+ msc->partid_to_intpartid[logical_partid] = intpartid;
+ __set_bit(logical_partid, msc->partid_has_entry);
+ }
+ }
+}
+
+int mpam_prepare_partid_entries(struct mpam_component *comp,
+ const u16 *logical_partids, size_t nr_partids)
+{
+ int ret;
+
+ guard(mutex)(&partid_map_lock);
+
+ if (!comp->uses_partid_narrowing)
+ return 0;
+
+ ret = mpam_preflight_partid_entries(comp, logical_partids, nr_partids);
+ if (ret)
+ return ret;
+ mpam_allocate_partid_entries(comp, logical_partids, nr_partids);
+
+ return 0;
+}
+
static bool mpam_component_shares_direct_msc(struct mpam_component *comp)
{
struct mpam_vmsc *vmsc;
@@ -3186,6 +3313,42 @@ static void mpam_reset_component_cfg(struct mpam_component *comp)
}
}
+static int mpam_alloc_msc_partid_state(struct mpam_msc *msc)
+{
+ struct device *dev = &msc->pdev->dev;
+ size_t nr_partids = mpam_partid_max + 1;
+ unsigned long *intpartids, *entries;
+
+ u16 *map;
+
+ if (msc->partid_to_intpartid)
+ return 0;
+
+ map = devm_kcalloc(dev, nr_partids, sizeof(*map), GFP_KERNEL);
+ if (!map)
+ return -ENOMEM;
+ intpartids = devm_bitmap_zalloc(dev, msc->nr_intpartids, GFP_KERNEL);
+ if (!intpartids)
+ goto out_free_map;
+ entries = devm_bitmap_zalloc(dev, nr_partids, GFP_KERNEL);
+ if (!entries)
+ goto out_free_intpartids;
+
+ __set_bit(0, intpartids);
+ __set_bit(0, entries);
+ msc->partid_to_intpartid = map;
+ msc->intpartid_allocated = intpartids;
+ msc->partid_has_entry = entries;
+
+ return 0;
+
+out_free_intpartids:
+ devm_kfree(dev, intpartids);
+out_free_map:
+ devm_kfree(dev, map);
+ return -ENOMEM;
+}
+
static int __allocate_component_cfg(struct mpam_component *comp)
{
struct mpam_vmsc *vmsc;
@@ -3212,10 +3375,17 @@ static int __allocate_component_cfg(struct mpam_component *comp)
struct mpam_msc_ris *ris;
struct msmon_mbwu_state *mbwu_state;
- if (!vmsc->props.num_mbwu_mon)
- continue;
-
msc = vmsc->msc;
+
+ if (comp->uses_partid_narrowing) {
+ int ret = mpam_alloc_msc_partid_state(msc);
+
+ if (ret) {
+ __destroy_component_cfg(comp);
+ return ret;
+ }
+ }
+
list_for_each_entry(ris, &vmsc->ris, vmsc_list) {
if (!ris->props.num_mbwu_mon)
continue;
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 25744cefe43f3..f45a129689301 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -95,6 +95,9 @@ struct mpam_msc {
bool probed;
u16 partid_max;
u32 nr_intpartids;
+ u16 *partid_to_intpartid;
+ unsigned long *intpartid_allocated;
+ unsigned long *partid_has_entry;
u8 pmg_max;
unsigned long ris_idxs;
u32 ris_max;
@@ -514,9 +517,13 @@ void mpam_fb_disable_mpam(int err, int mpam_fb_err);
/* Reset all the RIS in a class under cpus_read_lock() */
int mpam_reset_class_locked(struct mpam_class *class);
-int mpam_apply_config(struct mpam_component *comp, u16 partid,
+int mpam_apply_config(struct mpam_component *comp, u16 logical_partid,
struct mpam_config *cfg);
bool mpam_component_uses_partid_narrowing(struct mpam_component *comp);
+bool mpam_component_has_partid_entries(struct mpam_component *comp,
+ u16 logical_partid);
+int mpam_prepare_partid_entries(struct mpam_component *comp,
+ const u16 *logical_partids, size_t nr_partids);
int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx,
enum mpam_device_features, u64 *val);
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 07/13] arm_mpam: Add request-to-internal PARTID mapping
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (5 preceding siblings ...)
2026-11-30 2:29 ` [RFC PATCH 06/13] arm_mpam: Add an internal PARTID allocator Yunhui Cui
@ 2026-11-30 2:29 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 08/13] arm_mpam: Apply PARTID narrowing to resctrl control groups Yunhui Cui
` (6 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
PARTID narrowing separates the request PARTID carried by a request from
the internal PARTID containing its policy. A newly allocated internal
entry must be configured on every RIS in the MSC before requests are
mapped to it, otherwise requests may observe an uninitialized or partial
policy.
Add the mapping lifecycle for allocated internal PARTIDs. Publish the
request-to-internal mapping only after configuration succeeds, map the
request PARTID back to the root entry before releasing an entry, and
keep new allocations pending until all MSC updates complete so a failure
can undo mappings that were already published.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 262 ++++++++++++++++++++++++++++++--
drivers/resctrl/mpam_internal.h | 10 ++
2 files changed, 261 insertions(+), 11 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index b4ee5a0354bfa..f2abb69914959 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1838,31 +1838,43 @@ static u16 mpam_wa_t241_calc_min_from_max(struct mpam_props *props,
}
/* Called via IPI. Call while holding an SRCU reference */
-static int mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
- struct mpam_config *cfg)
+static int __mpam_reprogram_ris_partid(struct mpam_msc_ris *ris,
+ u16 logical_partid,
+ struct mpam_config *cfg,
+ bool use_internal)
{
u16 cmax = MPAMCFG_CMAX_CMAX;
struct mpam_msc *msc = ris->vmsc->msc;
struct mpam_props *rprops = &ris->props;
+ u16 intpartid = logical_partid;
int ret;
guard(mutex)(&msc->part_sel_lock);
- ret = __mpam_part_sel(ris->ris_idx, partid, msc);
- if (ret)
- return ret;
+ if (use_internal) {
+ if (!test_bit(logical_partid, msc->partid_has_entry))
+ return -EINVAL;
+ intpartid = msc->partid_to_intpartid[logical_partid];
+ ret = __mpam_intpart_sel(ris->ris_idx, intpartid, msc);
+ if (ret)
+ return ret;
+ } else {
+ ret = __mpam_part_sel(ris->ris_idx, logical_partid, msc);
+ if (ret)
+ return ret;
+ }
- if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) {
+ if (!use_internal && mpam_has_feature(mpam_feat_partid_nrw, rprops)) {
/* Update the intpartid mapping */
ret = mpam_write_partsel_reg(msc, INTPARTID,
- MPAMCFG_INTPARTID_INTERNAL | partid);
+ MPAMCFG_INTPARTID_INTERNAL | logical_partid);
if (ret)
return ret;
/*
- * Then switch to the 'internal' partid to update the
+ * Then switch to the 'internal' logical_partid to update the
* configuration.
*/
- ret = __mpam_intpart_sel(ris->ris_idx, partid, msc);
+ ret = __mpam_intpart_sel(ris->ris_idx, logical_partid, msc);
if (ret)
return ret;
}
@@ -1972,11 +1984,24 @@ static int mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
return ret;
}
- mpam_quirk_post_config_change(ris, partid, cfg);
+ mpam_quirk_post_config_change(ris, intpartid, cfg);
return 0;
}
+static int mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
+ struct mpam_config *cfg)
+{
+ return __mpam_reprogram_ris_partid(ris, partid, cfg, false);
+}
+
+static int mpam_reprogram_ris_mapped_partid(struct mpam_msc_ris *ris,
+ u16 logical_partid,
+ struct mpam_config *cfg)
+{
+ return __mpam_reprogram_ris_partid(ris, logical_partid, cfg, true);
+}
+
/* Call with msc cfg_lock held */
static int mpam_restore_mbwu_state(void *_ris)
{
@@ -2158,6 +2183,14 @@ static int __write_config(void *arg)
&c->comp->cfg[c->partid]);
}
+static int __write_internal_config(void *arg)
+{
+ struct mpam_write_config_arg *c = arg;
+
+ return mpam_reprogram_ris_mapped_partid(c->ris, c->partid,
+ &c->comp->cfg[c->partid]);
+}
+
static void mpam_reprogram_msc(struct mpam_msc *msc)
{
bool reset;
@@ -2958,6 +2991,7 @@ static void mpam_allocate_partid_entries(struct mpam_component *comp,
__set_bit(intpartid, msc->intpartid_allocated);
msc->partid_to_intpartid[logical_partid] = intpartid;
__set_bit(logical_partid, msc->partid_has_entry);
+ __set_bit(logical_partid, msc->partid_pending);
}
}
}
@@ -2980,6 +3014,205 @@ int mpam_prepare_partid_entries(struct mpam_component *comp,
return 0;
}
+struct mpam_partid_map_arg {
+ struct mpam_msc *msc;
+ u16 partid;
+ u16 intpartid;
+};
+
+static int __mpam_set_partid_map(void *_arg)
+{
+ struct mpam_partid_map_arg *arg = _arg;
+ struct mpam_msc *msc = arg->msc;
+ u32 partsel;
+ int ret;
+
+ guard(mutex)(&msc->part_sel_lock);
+
+ /* MPAMCFG_INTPARTID is selected by PARTID, but not by RIS. */
+ partsel = FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, arg->partid);
+ ret = __mpam_part_sel_raw(partsel, msc);
+ if (ret)
+ return ret;
+
+ return mpam_write_partsel_reg(msc, INTPARTID,
+ MPAMCFG_INTPARTID_INTERNAL | arg->intpartid);
+}
+
+static int mpam_set_msc_partid_map(struct mpam_msc *msc, u16 logical_partid,
+ u16 intpartid)
+{
+ struct mpam_partid_map_arg arg = {
+ .msc = msc,
+ .partid = logical_partid,
+ .intpartid = intpartid,
+ };
+
+ guard(mutex)(&msc->cfg_lock);
+
+ return mpam_touch_msc(msc, __mpam_set_partid_map, &arg);
+}
+
+static void mpam_copy_partid_config(struct mpam_config *dst,
+ const struct mpam_config *src)
+{
+ bitmap_copy(dst->features, src->features, MPAM_FEATURE_LAST);
+ dst->cpbm = src->cpbm;
+ dst->mbw_pbm = src->mbw_pbm;
+ dst->mbw_max = src->mbw_max;
+}
+
+static int mpam_configure_msc_partid(struct mpam_msc *msc, u16 logical_partid,
+ u16 root_partid)
+{
+ struct mpam_msc_ris *ris;
+ int ret;
+
+ guard(mutex)(&msc->cfg_lock);
+ list_for_each_entry_srcu(ris, &msc->ris, msc_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ struct mpam_component *comp = ris->vmsc->comp;
+ struct mpam_write_config_arg arg = {
+ .ris = ris,
+ .comp = comp,
+ .partid = logical_partid,
+ };
+
+ mpam_copy_partid_config(&comp->cfg[logical_partid], &comp->cfg[root_partid]);
+
+ ret = mpam_touch_msc(msc, __write_internal_config, &arg);
+ if (ret)
+ return ret;
+ ris->in_reset_state = false;
+ }
+
+ return 0;
+}
+
+int mpam_configure_pending_partid(struct mpam_component *comp,
+ u16 logical_partid, u16 root_partid)
+{
+ struct mpam_vmsc *vmsc;
+ int ret;
+
+ guard(mutex)(&partid_map_lock);
+ guard(srcu)(&mpam_srcu);
+
+ if (!comp->uses_partid_narrowing || !logical_partid)
+ return 0;
+ if (!__mpam_component_has_partid_entries(comp, logical_partid))
+ return -EINVAL;
+
+ list_for_each_entry_srcu(vmsc, &comp->vmsc, comp_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ struct mpam_msc *msc = vmsc->msc;
+
+ if (!test_bit(logical_partid, msc->partid_pending))
+ continue;
+ ret = mpam_configure_msc_partid(msc, logical_partid, root_partid);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+int mpam_commit_partid(struct mpam_component *comp, u16 logical_partid)
+{
+ struct mpam_vmsc *vmsc;
+ int ret;
+
+ guard(mutex)(&partid_map_lock);
+ guard(srcu)(&mpam_srcu);
+
+ if (!comp->uses_partid_narrowing || !logical_partid)
+ return 0;
+
+ list_for_each_entry_srcu(vmsc, &comp->vmsc, comp_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ struct mpam_msc *msc = vmsc->msc;
+ u16 intpartid;
+
+ if (!test_bit(logical_partid, msc->partid_pending))
+ continue;
+ intpartid = msc->partid_to_intpartid[logical_partid];
+ ret = mpam_set_msc_partid_map(msc, logical_partid, intpartid);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+void mpam_finish_partid(struct mpam_component *comp, u16 logical_partid)
+{
+ struct mpam_vmsc *vmsc;
+
+ guard(mutex)(&partid_map_lock);
+
+ if (!comp->uses_partid_narrowing || !logical_partid)
+ return;
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list)
+ __clear_bit(logical_partid, vmsc->msc->partid_pending);
+}
+
+static int __mpam_unmap_partid(struct mpam_component *comp, u16 logical_partid,
+ u16 root_partid, bool pending_only)
+{
+ struct mpam_vmsc *vmsc;
+ int ret;
+
+ if (!comp->uses_partid_narrowing || !logical_partid)
+ return 0;
+
+ guard(mutex)(&partid_map_lock);
+ guard(srcu)(&mpam_srcu);
+
+ list_for_each_entry_srcu(vmsc, &comp->vmsc, comp_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ struct mpam_msc *msc = vmsc->msc;
+ u16 intpartid;
+
+ if (!test_bit(logical_partid, msc->partid_has_entry) ||
+ (pending_only && !test_bit(logical_partid, msc->partid_pending)))
+ continue;
+ intpartid = msc->partid_to_intpartid[root_partid];
+ ret = mpam_set_msc_partid_map(msc, logical_partid, intpartid);
+ if (ret)
+ return ret;
+ }
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
+ struct mpam_msc *msc = vmsc->msc;
+ u16 intpartid;
+
+ if (!test_bit(logical_partid, msc->partid_has_entry) ||
+ (pending_only && !test_bit(logical_partid, msc->partid_pending)))
+ continue;
+ intpartid = msc->partid_to_intpartid[logical_partid];
+ msc->partid_to_intpartid[logical_partid] =
+ msc->partid_to_intpartid[root_partid];
+ __clear_bit(logical_partid, msc->partid_pending);
+ __clear_bit(logical_partid, msc->partid_has_entry);
+ __clear_bit(intpartid, msc->intpartid_allocated);
+ }
+
+ return 0;
+}
+
+int mpam_abort_partid(struct mpam_component *comp, u16 logical_partid,
+ u16 root_partid)
+{
+ return __mpam_unmap_partid(comp, logical_partid, root_partid, true);
+}
+
+int mpam_release_partid(struct mpam_component *comp, u16 logical_partid,
+ u16 root_partid)
+{
+ return __mpam_unmap_partid(comp, logical_partid, root_partid, false);
+}
+
static bool mpam_component_shares_direct_msc(struct mpam_component *comp)
{
struct mpam_vmsc *vmsc;
@@ -3318,7 +3551,7 @@ static int mpam_alloc_msc_partid_state(struct mpam_msc *msc)
struct device *dev = &msc->pdev->dev;
size_t nr_partids = mpam_partid_max + 1;
unsigned long *intpartids, *entries;
-
+ unsigned long *pending;
u16 *map;
if (msc->partid_to_intpartid)
@@ -3334,14 +3567,21 @@ static int mpam_alloc_msc_partid_state(struct mpam_msc *msc)
if (!entries)
goto out_free_intpartids;
+ pending = devm_bitmap_zalloc(dev, nr_partids, GFP_KERNEL);
+ if (!pending)
+ goto out_free_entries;
+
__set_bit(0, intpartids);
__set_bit(0, entries);
msc->partid_to_intpartid = map;
msc->intpartid_allocated = intpartids;
msc->partid_has_entry = entries;
+ msc->partid_pending = pending;
return 0;
+out_free_entries:
+ devm_kfree(dev, entries);
out_free_intpartids:
devm_kfree(dev, intpartids);
out_free_map:
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index f45a129689301..6055cf52972a5 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -98,6 +98,8 @@ struct mpam_msc {
u16 *partid_to_intpartid;
unsigned long *intpartid_allocated;
unsigned long *partid_has_entry;
+ /* New reservations stay pending until the entire update finishes. */
+ unsigned long *partid_pending;
u8 pmg_max;
unsigned long ris_idxs;
u32 ris_max;
@@ -524,6 +526,14 @@ bool mpam_component_has_partid_entries(struct mpam_component *comp,
u16 logical_partid);
int mpam_prepare_partid_entries(struct mpam_component *comp,
const u16 *logical_partids, size_t nr_partids);
+int mpam_configure_pending_partid(struct mpam_component *comp,
+ u16 logical_partid, u16 root_partid);
+int mpam_commit_partid(struct mpam_component *comp, u16 logical_partid);
+void mpam_finish_partid(struct mpam_component *comp, u16 logical_partid);
+int mpam_abort_partid(struct mpam_component *comp, u16 logical_partid,
+ u16 root_partid);
+int mpam_release_partid(struct mpam_component *comp, u16 logical_partid,
+ u16 root_partid);
int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx,
enum mpam_device_features, u64 *val);
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 08/13] arm_mpam: Apply PARTID narrowing to resctrl control groups
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (6 preceding siblings ...)
2026-11-30 2:29 ` [RFC PATCH 07/13] arm_mpam: Add request-to-internal PARTID mapping Yunhui Cui
@ 2026-11-30 2:29 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 09/13] arm_mpam: Separate request and internal PARTID limits Yunhui Cui
` (5 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
For a component using PARTID narrowing, creating a group does not
require a private entry. Its logical PARTID initially selects the root
entry. A schemata write allocates entries on the affected MSCs, programs
the group policy and maps the logical PARTID to those entries, including
for same-value writes.
Initialize the root entry before installing the default mappings.
Direct-index components still initialize group entries at creation, so
ID reuse cannot expose an old policy when other components use
narrowing. Abort reservations on every affected component even if
cleanup fails on one of them, and restore entry configuration before
restoring mappings during recovery.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 180 ++++++++++++++++++++----
drivers/resctrl/mpam_internal.h | 2 +
drivers/resctrl/mpam_resctrl.c | 241 ++++++++++++++++++++++++++++++--
3 files changed, 384 insertions(+), 39 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index f2abb69914959..d0b8f4c3f0c2c 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -154,6 +154,9 @@ u8 mpam_pmg_max;
static bool partid_max_init, partid_max_published;
static DEFINE_SPINLOCK(partid_max_lock);
static DEFINE_MUTEX(partid_map_lock);
+static bool partid_narrowing_enabled;
+static bool partid_mapping_failed;
+static void mpam_fail_partid_mapping(void);
/*
* mpam is enabled once all devices have been probed from CPU online callbacks,
@@ -2116,6 +2119,31 @@ static int mpam_save_mbwu_state(void *arg)
return 0;
}
+struct mpam_partid_map_arg {
+ struct mpam_msc *msc;
+ u16 partid;
+ u16 intpartid;
+};
+
+static int __mpam_set_partid_map(void *_arg)
+{
+ struct mpam_partid_map_arg *arg = _arg;
+ struct mpam_msc *msc = arg->msc;
+ u32 partsel;
+ int ret;
+
+ guard(mutex)(&msc->part_sel_lock);
+
+ /* MPAMCFG_INTPARTID is selected by PARTID, but not by RIS. */
+ partsel = FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, arg->partid);
+ ret = __mpam_part_sel_raw(partsel, msc);
+ if (ret)
+ return ret;
+
+ return mpam_write_partsel_reg(msc, INTPARTID,
+ MPAMCFG_INTPARTID_INTERNAL | arg->intpartid);
+}
+
/*
* Called via smp_call_on_cpu() to prevent migration, while still being
* pre-emptible. Caller must hold mpam_srcu.
@@ -2125,6 +2153,7 @@ static int mpam_reset_ris(void *arg)
u16 partid_max;
struct mpam_config reset_cfg = {};
struct mpam_msc_ris *ris = arg;
+ struct mpam_msc *msc = ris->vmsc->msc;
int ret;
if (ris->in_reset_state)
@@ -2134,7 +2163,16 @@ static int mpam_reset_ris(void *arg)
partid_max = mpam_partid_max;
spin_unlock(&partid_max_lock);
for (u32 partid = 0; partid <= partid_max; partid++) {
- ret = mpam_reprogram_ris_partid(ris, partid, &reset_cfg);
+ if (!msc->partid_to_intpartid) {
+ ret = mpam_reprogram_ris_partid(ris, partid, &reset_cfg);
+ if (ret)
+ return ret;
+ continue;
+ }
+
+ if (!test_bit(partid, msc->partid_has_entry))
+ continue;
+ ret = mpam_reprogram_ris_mapped_partid(ris, partid, &reset_cfg);
if (ret)
return ret;
}
@@ -2194,6 +2232,7 @@ static int __write_internal_config(void *arg)
static void mpam_reprogram_msc(struct mpam_msc *msc)
{
bool reset;
+ int ret = 0;
struct mpam_config *cfg;
struct mpam_msc_ris *ris;
struct mpam_write_config_arg arg;
@@ -2208,7 +2247,9 @@ static void mpam_reprogram_msc(struct mpam_msc *msc)
list_for_each_entry_srcu(ris, &msc->ris, msc_list,
srcu_read_lock_held(&mpam_srcu)) {
if (!mpam_is_enabled() && !ris->in_reset_state) {
- mpam_touch_msc(msc, &mpam_reset_ris, ris);
+ ret = mpam_touch_msc(msc, &mpam_reset_ris, ris);
+ if (ret)
+ goto out_unlock;
ris->in_reset_state = true;
continue;
}
@@ -2217,19 +2258,48 @@ static void mpam_reprogram_msc(struct mpam_msc *msc)
arg.ris = ris;
reset = true;
for (u32 partid = 0; partid <= mpam_partid_max; partid++) {
+ if (msc->partid_to_intpartid &&
+ !test_bit(partid, msc->partid_has_entry))
+ continue;
+
cfg = &ris->vmsc->comp->cfg[partid];
if (!bitmap_empty(cfg->features, MPAM_FEATURE_LAST))
reset = false;
arg.partid = partid;
- mpam_touch_msc(msc, __write_config, &arg);
+ if (msc->partid_to_intpartid)
+ ret = mpam_touch_msc(msc, __write_internal_config, &arg);
+ else
+ ret = mpam_touch_msc(msc, __write_config, &arg);
+ if (ret)
+ goto out_unlock;
}
ris->in_reset_state = reset;
if (mpam_has_feature(mpam_feat_msmon_mbwu, &ris->props))
mpam_touch_msc(msc, &mpam_restore_mbwu_state, ris);
}
+
+ if (msc->partid_to_intpartid) {
+ for (u32 partid = 0; partid <= mpam_partid_max; partid++) {
+ struct mpam_partid_map_arg map_arg = {
+ .msc = msc,
+ .partid = partid,
+ .intpartid = msc->partid_to_intpartid[0],
+ };
+
+ if (test_bit(partid, msc->partid_has_entry))
+ map_arg.intpartid =
+ msc->partid_to_intpartid[partid];
+ ret = mpam_touch_msc(msc, __mpam_set_partid_map, &map_arg);
+ if (ret)
+ goto out_unlock;
+ }
+ }
+out_unlock:
mutex_unlock(&msc->cfg_lock);
+ if (ret)
+ mpam_fail_partid_mapping();
}
static int mpam_enable_msc_ecr(void *_msc)
@@ -2887,6 +2957,23 @@ bool mpam_component_uses_partid_narrowing(struct mpam_component *comp)
return comp->uses_partid_narrowing;
}
+bool mpam_has_partid_narrowing(void)
+{
+ return partid_narrowing_enabled;
+}
+
+bool mpam_partid_mapping_failed(void)
+{
+ return READ_ONCE(partid_mapping_failed);
+}
+
+static void mpam_fail_partid_mapping(void)
+{
+ WRITE_ONCE(partid_mapping_failed, true);
+ mpam_disable_reason = "Failed to restore MPAM controller state.";
+ schedule_work(&mpam_broken_work);
+}
+
static bool __mpam_component_has_partid_entries(struct mpam_component *comp,
u16 logical_partid)
{
@@ -3014,31 +3101,6 @@ int mpam_prepare_partid_entries(struct mpam_component *comp,
return 0;
}
-struct mpam_partid_map_arg {
- struct mpam_msc *msc;
- u16 partid;
- u16 intpartid;
-};
-
-static int __mpam_set_partid_map(void *_arg)
-{
- struct mpam_partid_map_arg *arg = _arg;
- struct mpam_msc *msc = arg->msc;
- u32 partsel;
- int ret;
-
- guard(mutex)(&msc->part_sel_lock);
-
- /* MPAMCFG_INTPARTID is selected by PARTID, but not by RIS. */
- partsel = FIELD_PREP(MPAMCFG_PART_SEL_PARTID_SEL, arg->partid);
- ret = __mpam_part_sel_raw(partsel, msc);
- if (ret)
- return ret;
-
- return mpam_write_partsel_reg(msc, INTPARTID,
- MPAMCFG_INTPARTID_INTERNAL | arg->intpartid);
-}
-
static int mpam_set_msc_partid_map(struct mpam_msc *msc, u16 logical_partid,
u16 intpartid)
{
@@ -3078,7 +3140,9 @@ static int mpam_configure_msc_partid(struct mpam_msc *msc, u16 logical_partid,
.partid = logical_partid,
};
- mpam_copy_partid_config(&comp->cfg[logical_partid], &comp->cfg[root_partid]);
+ if (logical_partid != root_partid)
+ mpam_copy_partid_config(&comp->cfg[logical_partid],
+ &comp->cfg[root_partid]);
ret = mpam_touch_msc(msc, __write_internal_config, &arg);
if (ret)
@@ -3239,11 +3303,15 @@ static void mpam_enable_set_partid_narrowing(struct list_head *classes)
bool changed;
lockdep_assert_held(&mpam_list_lock);
+ partid_narrowing_enabled = false;
list_for_each_entry(class, classes, classes_list) {
- list_for_each_entry(comp, &class->components, class_list)
+ if (class->type == MPAM_CLASS_UNKNOWN)
+ continue;
+ 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. */
@@ -3261,6 +3329,50 @@ static void mpam_enable_set_partid_narrowing(struct list_head *classes)
}
}
} while (changed);
+
+ list_for_each_entry(class, classes, classes_list) {
+ list_for_each_entry(comp, &class->components, class_list)
+ partid_narrowing_enabled |= comp->uses_partid_narrowing;
+ }
+}
+
+static int mpam_init_msc_partid_mappings(struct mpam_msc *msc)
+{
+ u32 partid;
+ int ret;
+
+ if (!msc->partid_to_intpartid)
+ return 0;
+
+ ret = mpam_configure_msc_partid(msc, 0, 0);
+ if (ret)
+ return ret;
+
+ for (partid = 0; partid <= mpam_partid_max; partid++) {
+ u16 intpartid = msc->partid_to_intpartid[0];
+
+ ret = mpam_set_msc_partid_map(msc, partid, intpartid);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int mpam_init_partid_mappings(void)
+{
+ struct mpam_msc *msc;
+
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ int ret = mpam_init_msc_partid_mappings(msc);
+
+ if (ret)
+ return ret;
+ }
+
+ return 0;
}
/*
@@ -3703,6 +3815,8 @@ static void mpam_enable_once(void)
}
} while (0);
mutex_unlock(&mpam_list_lock);
+ if (!err)
+ err = mpam_init_partid_mappings();
cpus_read_unlock();
if (!err) {
@@ -3918,7 +4032,11 @@ int mpam_apply_config(struct mpam_component *comp, u16 partid,
list_for_each_entry_srcu(ris, &vmsc->ris, vmsc_list,
srcu_read_lock_held(&mpam_srcu)) {
arg.ris = ris;
- ret = mpam_touch_msc(msc, __write_config, &arg);
+ if (comp->uses_partid_narrowing)
+ ret = mpam_touch_msc(msc,
+ __write_internal_config, &arg);
+ else
+ ret = mpam_touch_msc(msc, __write_config, &arg);
if (ret)
return ret;
ris->in_reset_state = false;
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 6055cf52972a5..d0c501ab94aae 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -522,6 +522,8 @@ int mpam_reset_class_locked(struct mpam_class *class);
int mpam_apply_config(struct mpam_component *comp, u16 logical_partid,
struct mpam_config *cfg);
bool mpam_component_uses_partid_narrowing(struct mpam_component *comp);
+bool mpam_has_partid_narrowing(void);
+bool mpam_partid_mapping_failed(void);
bool mpam_component_has_partid_entries(struct mpam_component *comp,
u16 logical_partid);
int mpam_prepare_partid_entries(struct mpam_component *comp,
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 72b4f2b2e4b6e..528159a48da4b 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -206,6 +206,8 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
pr_warn("CDP not supported\n");
return -EOPNOTSUPP;
}
+ if (enable && mpam_has_partid_narrowing())
+ return -EOPNOTSUPP;
if (enable)
pr_warn("CDP is an expert feature and may cause MPAM to malfunction.\n");
@@ -1401,6 +1403,10 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
type = CDP_DATA;
partid = resctrl_get_config_index(closid, type);
+ if (mpam_component_uses_partid_narrowing(dom->ctrl_comp) &&
+ !mpam_component_has_partid_entries(dom->ctrl_comp, partid))
+ partid = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID,
+ type);
cfg = &dom->ctrl_comp->cfg[partid];
switch (r->rid) {
@@ -1436,7 +1442,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type t, u32 cfg_val)
{
int err;
- u32 partid;
+ u32 partid, root_partid;
struct mpam_config cfg;
struct mpam_props *cprops;
struct mpam_resctrl_res *res;
@@ -1460,6 +1466,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
t = CDP_DATA;
partid = resctrl_get_config_index(closid, t);
+ root_partid = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, t);
if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r)) {
pr_debug("Not alloc capable or computed PARTID out of range\n");
return -EINVAL;
@@ -1469,7 +1476,11 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
* Copy the current config to avoid clearing other resources when the
* same component is exposed multiple times through resctrl.
*/
- cfg = dom->ctrl_comp->cfg[partid];
+ if (mpam_component_uses_partid_narrowing(dom->ctrl_comp) &&
+ !mpam_component_has_partid_entries(dom->ctrl_comp, partid))
+ cfg = dom->ctrl_comp->cfg[root_partid];
+ else
+ cfg = dom->ctrl_comp->cfg[partid];
switch (r->rid) {
case RDT_RESOURCE_L2:
@@ -1505,7 +1516,8 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
return mpam_apply_config(dom->ctrl_comp, partid, &cfg);
}
-static int resctrl_arch_update_domains_id(struct rdt_resource *r, u32 id)
+static int resctrl_arch_update_domains_id(struct rdt_resource *r, u32 id,
+ bool group_init)
{
int err;
struct rdt_ctrl_domain *d;
@@ -1515,8 +1527,17 @@ static int resctrl_arch_update_domains_id(struct rdt_resource *r, u32 id)
if (!mpam_is_enabled())
return -EINVAL;
+ if (mpam_partid_mapping_failed())
+ return -EIO;
list_for_each_entry_rcu(d, &r->ctrl_domains, hdr.list) {
+ struct mpam_resctrl_dom *dom;
+
+ dom = container_of(d, struct mpam_resctrl_dom,
+ resctrl_ctrl_dom);
+ if (group_init && id &&
+ mpam_component_uses_partid_narrowing(dom->ctrl_comp))
+ continue;
for (enum resctrl_conf_type t = 0; t < CDP_NUM_TYPES; t++) {
struct resctrl_staged_config *cfg = &d->staged_config[t];
@@ -1535,36 +1556,240 @@ static int resctrl_arch_update_domains_id(struct rdt_resource *r, u32 id)
int resctrl_arch_init_ctrl_domains(struct rdt_resource *r, u32 logical_ctrl_id)
{
- return resctrl_arch_update_domains_id(r, logical_ctrl_id);
+ return resctrl_arch_update_domains_id(r, logical_ctrl_id, true);
}
int resctrl_arch_update_domains(struct rdt_resource *r, u32 logical_ctrl_id)
{
- return resctrl_arch_update_domains_id(r, logical_ctrl_id);
+ return resctrl_arch_update_domains_id(r, logical_ctrl_id, false);
}
int resctrl_arch_update_io_alloc(struct rdt_resource *r, u32 physical_ctrl_id)
{
- return resctrl_arch_update_domains_id(r, physical_ctrl_id);
+ if (mpam_has_partid_narrowing())
+ return -EOPNOTSUPP;
+
+ return resctrl_arch_update_domains_id(r, physical_ctrl_id, false);
+}
+
+static bool mpam_domain_has_staged_config(struct rdt_ctrl_domain *d)
+{
+ enum resctrl_conf_type type;
+
+ for (type = 0; type < CDP_NUM_TYPES; type++) {
+ if (d->staged_config[type].have_new_ctrl)
+ return true;
+ }
+
+ return false;
+}
+
+static int mpam_prepare_ctrl_partids(struct rdt_resource *r,
+ u32 logical_ctrl_id)
+{
+ struct rdt_ctrl_domain *d;
+
+ list_for_each_entry_rcu(d, &r->ctrl_domains, hdr.list) {
+ struct mpam_resctrl_dom *dom;
+ u16 partids[CDP_NUM_TYPES];
+ u16 root_partids[CDP_NUM_TYPES];
+ size_t i, nr_partids = 0;
+ enum resctrl_conf_type type;
+ int ret;
+
+ if (!mpam_domain_has_staged_config(d))
+ continue;
+ dom = container_of(d, struct mpam_resctrl_dom,
+ resctrl_ctrl_dom);
+ if (!mpam_component_uses_partid_narrowing(dom->ctrl_comp))
+ continue;
+
+ if (mpam_resctrl_hide_cdp(r->rid)) {
+ partids[nr_partids] =
+ resctrl_get_config_index(logical_ctrl_id, CDP_CODE);
+ root_partids[nr_partids++] =
+ resctrl_get_config_index(RESCTRL_RESERVED_CLOSID,
+ CDP_CODE);
+ partids[nr_partids] =
+ resctrl_get_config_index(logical_ctrl_id, CDP_DATA);
+ root_partids[nr_partids++] =
+ resctrl_get_config_index(RESCTRL_RESERVED_CLOSID,
+ CDP_DATA);
+ } else {
+ for (type = 0; type < CDP_NUM_TYPES; type++) {
+ if (!d->staged_config[type].have_new_ctrl)
+ continue;
+ partids[nr_partids] =
+ resctrl_get_config_index(logical_ctrl_id, type);
+ root_partids[nr_partids++] =
+ resctrl_get_config_index(RESCTRL_RESERVED_CLOSID,
+ type);
+ }
+ }
+
+ ret = mpam_prepare_partid_entries(dom->ctrl_comp, partids, nr_partids);
+ if (ret)
+ return ret;
+ for (i = 0; i < nr_partids; i++) {
+ ret = mpam_configure_pending_partid(dom->ctrl_comp,
+ partids[i],
+ root_partids[i]);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+enum mpam_partid_op {
+ MPAM_PARTID_COMMIT,
+ MPAM_PARTID_FINISH,
+ MPAM_PARTID_ABORT,
+ MPAM_PARTID_RELEASE,
+};
+
+static int mpam_component_partid_op(struct mpam_component *comp, u32 logical_ctrl_id,
+ enum mpam_partid_op op)
+{
+ u16 partids[CDP_NUM_TYPES];
+ u16 root_partids[CDP_NUM_TYPES];
+ size_t i, nr_partids = 0;
+ int error = 0;
+
+ if (!mpam_component_uses_partid_narrowing(comp))
+ return 0;
+
+ if (cdp_enabled) {
+ partids[nr_partids++] =
+ resctrl_get_config_index(logical_ctrl_id, CDP_CODE);
+ root_partids[0] =
+ resctrl_get_config_index(RESCTRL_RESERVED_CLOSID,
+ CDP_CODE);
+ partids[nr_partids++] =
+ resctrl_get_config_index(logical_ctrl_id, CDP_DATA);
+ root_partids[1] =
+ resctrl_get_config_index(RESCTRL_RESERVED_CLOSID,
+ CDP_DATA);
+ } else {
+ partids[nr_partids++] = logical_ctrl_id;
+ root_partids[0] = RESCTRL_RESERVED_CLOSID;
+ }
+
+ for (i = 0; i < nr_partids; i++) {
+ int ret;
+
+ switch (op) {
+ case MPAM_PARTID_COMMIT:
+ ret = mpam_commit_partid(comp, partids[i]);
+ break;
+ case MPAM_PARTID_FINISH:
+ mpam_finish_partid(comp, partids[i]);
+ ret = 0;
+ break;
+ case MPAM_PARTID_ABORT:
+ ret = mpam_abort_partid(comp, partids[i],
+ root_partids[i]);
+ break;
+ case MPAM_PARTID_RELEASE:
+ ret = mpam_release_partid(comp, partids[i],
+ root_partids[i]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ if (ret) {
+ if (op != MPAM_PARTID_ABORT)
+ return ret;
+ if (!error)
+ error = ret;
+ }
+ }
+
+ return error;
+}
+
+static int mpam_all_components_partid_op(u32 logical_ctrl_id,
+ enum mpam_partid_op op)
+{
+ struct mpam_resctrl_res *res;
+ enum resctrl_res_level rid;
+ int error = 0;
+
+ for_each_mpam_resctrl_control(res, rid) {
+ struct mpam_component *comp;
+ int ret;
+
+ if (!res->class || !res->resctrl_res.alloc_capable)
+ continue;
+ list_for_each_entry(comp, &res->class->components, class_list) {
+ ret = mpam_component_partid_op(comp, logical_ctrl_id, op);
+ if (ret) {
+ if (op != MPAM_PARTID_ABORT)
+ return ret;
+ if (!error)
+ error = ret;
+ }
+ }
+ }
+
+ return error;
}
int resctrl_arch_prepare_ctrl_update(u32 logical_ctrl_id)
{
+ struct mpam_resctrl_res *res;
+ enum resctrl_res_level rid;
+ int ret;
+
+ if (mpam_partid_mapping_failed())
+ return -EIO;
+ if (!logical_ctrl_id)
+ return 0;
+
+ for_each_mpam_resctrl_control(res, rid) {
+ struct rdt_resource *r = &res->resctrl_res;
+
+ if (!r->alloc_capable)
+ continue;
+ ret = mpam_prepare_ctrl_partids(r, logical_ctrl_id);
+ if (ret)
+ goto abort;
+ }
+
return 0;
+
+abort:
+ if (mpam_all_components_partid_op(logical_ctrl_id, MPAM_PARTID_ABORT))
+ pr_warn("Failed to abort partially prepared CLOSID %u\n",
+ logical_ctrl_id);
+ return ret;
}
int resctrl_arch_commit_ctrl_update(u32 logical_ctrl_id)
{
- return 0;
+ int ret;
+
+ ret = mpam_all_components_partid_op(logical_ctrl_id, MPAM_PARTID_COMMIT);
+ if (ret)
+ return ret;
+
+ return mpam_all_components_partid_op(logical_ctrl_id, MPAM_PARTID_FINISH);
}
void resctrl_arch_abort_ctrl_update(u32 logical_ctrl_id)
{
+ int ret;
+
+ ret = mpam_all_components_partid_op(logical_ctrl_id, MPAM_PARTID_ABORT);
+ if (ret)
+ pr_warn("Failed to abort CLOSID %u mapping: %d\n", logical_ctrl_id,
+ ret);
}
int resctrl_arch_release_ctrl_entries(u32 logical_ctrl_id)
{
- return 0;
+ return mpam_all_components_partid_op(logical_ctrl_id, MPAM_PARTID_RELEASE);
}
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 09/13] arm_mpam: Separate request and internal PARTID limits
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (7 preceding siblings ...)
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 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 10/13] arm_mpam: Map CDP data and code defaults separately Yunhui Cui
` (4 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
PARTID narrowing allows an MSC to accept more request PARTIDs than it
has internal configuration entries. Treat the request and internal
PARTID limits separately: use the full request PARTID range for
components using narrowing, while direct-index components remain limited
by their internal entry count because the request PARTID directly
selects the configuration entry.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 46 ++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index d0b8f4c3f0c2c..4925b61be162c 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1149,8 +1149,6 @@ static int mpam_ris_hw_probe(struct mpam_msc_ris *ris)
nrwidr) + 1;
}
mpam_set_feature(mpam_feat_partid_nrw, props);
- msc->partid_max = min_t(u32, msc->partid_max,
- msc->nr_intpartids - 1);
}
return 0;
@@ -2952,6 +2950,24 @@ static bool mpam_component_all_mscs_narrow(struct mpam_component *comp)
return found;
}
+static u16 mpam_component_safe_partid_max(struct mpam_component *comp,
+ u16 partid_max)
+{
+ struct mpam_vmsc *vmsc;
+
+ if (comp->uses_partid_narrowing)
+ return partid_max;
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
+ struct mpam_msc *msc = vmsc->msc;
+
+ if (msc->nr_intpartids)
+ partid_max = min_t(u32, partid_max, msc->nr_intpartids - 1);
+ }
+
+ return partid_max;
+}
+
bool mpam_component_uses_partid_narrowing(struct mpam_component *comp)
{
return comp->uses_partid_narrowing;
@@ -3300,9 +3316,12 @@ static void mpam_enable_set_partid_narrowing(struct list_head *classes)
{
struct mpam_component *comp;
struct mpam_class *class;
+ u16 partid_max;
bool changed;
lockdep_assert_held(&mpam_list_lock);
+ guard(spinlock)(&partid_max_lock);
+ partid_max = mpam_partid_max;
partid_narrowing_enabled = false;
list_for_each_entry(class, classes, classes_list) {
@@ -3334,6 +3353,16 @@ static void mpam_enable_set_partid_narrowing(struct list_head *classes)
list_for_each_entry(comp, &class->components, class_list)
partid_narrowing_enabled |= comp->uses_partid_narrowing;
}
+
+ list_for_each_entry(class, classes, classes_list) {
+ if (class->type == MPAM_CLASS_UNKNOWN)
+ continue;
+ list_for_each_entry(comp, &class->components, class_list)
+ partid_max = mpam_component_safe_partid_max(comp,
+ partid_max);
+ }
+
+ mpam_partid_max = partid_max;
}
static int mpam_init_msc_partid_mappings(struct mpam_msc *msc)
@@ -3783,14 +3812,6 @@ static void mpam_enable_once(void)
{
int err;
- /*
- * Once the cpuhp callbacks have been changed, mpam_partid_max can no
- * longer change.
- */
- spin_lock(&partid_max_lock);
- partid_max_published = true;
- spin_unlock(&partid_max_lock);
-
/*
* If all the MSC have been probed, enabling the IRQs happens next.
* That involves cross-calling to a CPU that can reach the MSC, and
@@ -3802,6 +3823,11 @@ static void mpam_enable_once(void)
mpam_enable_merge_features(&mpam_classes);
mpam_enable_set_partid_narrowing(&mpam_classes);
+ /* All request and internal PARTID limits are now known. */
+ spin_lock(&partid_max_lock);
+ partid_max_published = true;
+ spin_unlock(&partid_max_lock);
+
err = mpam_register_irqs();
if (err) {
pr_warn("Failed to register irqs: %d\n", err);
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 10/13] arm_mpam: Map CDP data and code defaults separately
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (8 preceding siblings ...)
2026-11-30 2:29 ` [RFC PATCH 09/13] arm_mpam: Separate request and internal PARTID limits Yunhui Cui
@ 2026-11-30 2:29 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 11/13] arm_mpam: Add kunit tests for PARTID narrowing Yunhui Cui
` (3 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
PARTID mapping initially sends all unconfigured request PARTIDs to a
single root entry, but CDP requires separate default policies for data
and code. Allocate a code-root entry and map unconfigured even and odd
request PARTIDs to the data and code roots. Before disabling CDP or
rolling back a failed enable, restore all default mappings to the data
root before releasing the code-root entry; retain it if restoration
fails because hardware may still select it.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 179 +++++++++++++++++++++++++++++---
drivers/resctrl/mpam_internal.h | 1 +
drivers/resctrl/mpam_resctrl.c | 16 +--
3 files changed, 175 insertions(+), 21 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 4925b61be162c..f67bcda8209c9 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -155,9 +155,15 @@ static bool partid_max_init, partid_max_published;
static DEFINE_SPINLOCK(partid_max_lock);
static DEFINE_MUTEX(partid_map_lock);
static bool partid_narrowing_enabled;
+static unsigned int default_partid_count = 1;
static bool partid_mapping_failed;
static void mpam_fail_partid_mapping(void);
+static u16 mpam_default_partid(u16 partid, bool cdp)
+{
+ return cdp ? partid & 1 : 0;
+}
+
/*
* mpam is enabled once all devices have been probed from CPU online callbacks,
* scheduled via this work_struct. If access to an MSC depends on a CPU that
@@ -2280,10 +2286,12 @@ static void mpam_reprogram_msc(struct mpam_msc *msc)
if (msc->partid_to_intpartid) {
for (u32 partid = 0; partid <= mpam_partid_max; partid++) {
+ bool cdp = READ_ONCE(default_partid_count) == 2;
+ u16 root = mpam_default_partid(partid, cdp);
struct mpam_partid_map_arg map_arg = {
.msc = msc,
.partid = partid,
- .intpartid = msc->partid_to_intpartid[0],
+ .intpartid = msc->partid_to_intpartid[root],
};
if (test_bit(partid, msc->partid_has_entry))
@@ -2978,18 +2986,6 @@ bool mpam_has_partid_narrowing(void)
return partid_narrowing_enabled;
}
-bool mpam_partid_mapping_failed(void)
-{
- return READ_ONCE(partid_mapping_failed);
-}
-
-static void mpam_fail_partid_mapping(void)
-{
- WRITE_ONCE(partid_mapping_failed, true);
- mpam_disable_reason = "Failed to restore MPAM controller state.";
- schedule_work(&mpam_broken_work);
-}
-
static bool __mpam_component_has_partid_entries(struct mpam_component *comp,
u16 logical_partid)
{
@@ -3293,6 +3289,159 @@ int mpam_release_partid(struct mpam_component *comp, u16 logical_partid,
return __mpam_unmap_partid(comp, logical_partid, root_partid, false);
}
+bool mpam_partid_mapping_failed(void)
+{
+ return READ_ONCE(partid_mapping_failed);
+}
+
+static int mpam_update_default_msc_mappings(struct mpam_msc *msc)
+{
+ u32 partid;
+
+ if (!msc->partid_to_intpartid)
+ return 0;
+
+ for (partid = 0; partid <= mpam_partid_max; partid++) {
+ bool cdp = READ_ONCE(default_partid_count) == 2;
+ u16 root = mpam_default_partid(partid, cdp);
+ u16 intpartid;
+ int ret;
+
+ if (partid >= default_partid_count &&
+ test_bit(partid, msc->partid_has_entry))
+ continue;
+ intpartid = msc->partid_to_intpartid[root];
+ ret = mpam_set_msc_partid_map(msc, partid, intpartid);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
+static int mpam_update_default_partid_mappings(void)
+{
+ struct mpam_msc *msc;
+
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ int ret = mpam_update_default_msc_mappings(msc);
+
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
+static int mpam_remove_code_root(bool pending_only)
+{
+ struct mpam_class *class;
+ struct mpam_component *comp;
+ int error = 0;
+
+ list_for_each_entry(class, &mpam_classes, classes_list) {
+ list_for_each_entry(comp, &class->components, class_list) {
+ int ret;
+
+ if (!comp->uses_partid_narrowing)
+ continue;
+ if (pending_only)
+ ret = mpam_abort_partid(comp, 1, 0);
+ else
+ ret = mpam_release_partid(comp, 1, 0);
+ if (ret && !error)
+ error = ret;
+ }
+ }
+ return error;
+}
+
+static void mpam_fail_partid_mapping(void)
+{
+ WRITE_ONCE(partid_mapping_failed, true);
+ mpam_disable_reason = "Failed to restore MPAM controller state.";
+ schedule_work(&mpam_broken_work);
+}
+
+/*
+ * CDP has separate data and code defaults. Reserve the code root before
+ * publishing the odd-PARTID default mappings. Callers have moved all tasks
+ * and CPUs back to the data root before removing the code root.
+ */
+int mpam_set_cdp_mapping(bool enable)
+{
+ struct mpam_class *class;
+ struct mpam_component *comp;
+ unsigned int count = enable ? 2 : 1;
+ u16 code_partid = 1;
+ int ret, rollback_ret;
+
+ lockdep_assert_cpus_held();
+ if (mpam_partid_mapping_failed())
+ return -EIO;
+ if (!partid_narrowing_enabled || count == default_partid_count)
+ return 0;
+
+ if (!enable) {
+ WRITE_ONCE(default_partid_count, 1);
+ ret = mpam_update_default_partid_mappings();
+ if (!ret)
+ ret = mpam_remove_code_root(false);
+ if (ret)
+ mpam_fail_partid_mapping();
+ return ret;
+ }
+
+ list_for_each_entry(class, &mpam_classes, classes_list) {
+ list_for_each_entry(comp, &class->components, class_list) {
+ if (!comp->uses_partid_narrowing)
+ continue;
+ if (mpam_component_has_partid_entries(comp, 1))
+ return -EBUSY;
+ }
+ }
+ list_for_each_entry(class, &mpam_classes, classes_list) {
+ list_for_each_entry(comp, &class->components, class_list) {
+ if (!comp->uses_partid_narrowing)
+ continue;
+ ret = mpam_prepare_partid_entries(comp, &code_partid, 1);
+ if (ret)
+ goto abort;
+ ret = mpam_configure_pending_partid(comp, 1, 0);
+ if (ret)
+ goto abort;
+ }
+ }
+ list_for_each_entry(class, &mpam_classes, classes_list) {
+ list_for_each_entry(comp, &class->components, class_list) {
+ if (!comp->uses_partid_narrowing)
+ continue;
+ ret = mpam_commit_partid(comp, 1);
+ if (ret)
+ goto abort;
+ }
+ }
+
+ WRITE_ONCE(default_partid_count, 2);
+ ret = mpam_update_default_partid_mappings();
+ if (ret)
+ goto abort;
+ list_for_each_entry(class, &mpam_classes, classes_list) {
+ list_for_each_entry(comp, &class->components, class_list)
+ mpam_finish_partid(comp, 1);
+ }
+ return 0;
+
+abort:
+ WRITE_ONCE(default_partid_count, 1);
+ rollback_ret = mpam_update_default_partid_mappings();
+ if (!rollback_ret)
+ rollback_ret = mpam_remove_code_root(true);
+ if (rollback_ret)
+ mpam_fail_partid_mapping();
+ return ret;
+}
+
static bool mpam_component_shares_direct_msc(struct mpam_component *comp)
{
struct mpam_vmsc *vmsc;
@@ -3378,7 +3527,9 @@ static int mpam_init_msc_partid_mappings(struct mpam_msc *msc)
return ret;
for (partid = 0; partid <= mpam_partid_max; partid++) {
- u16 intpartid = msc->partid_to_intpartid[0];
+ bool cdp = READ_ONCE(default_partid_count) == 2;
+ u16 root = mpam_default_partid(partid, cdp);
+ u16 intpartid = msc->partid_to_intpartid[root];
ret = mpam_set_msc_partid_map(msc, partid, intpartid);
if (ret)
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index d0c501ab94aae..8c5a5e5f9312b 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -523,6 +523,7 @@ int mpam_apply_config(struct mpam_component *comp, u16 logical_partid,
struct mpam_config *cfg);
bool mpam_component_uses_partid_narrowing(struct mpam_component *comp);
bool mpam_has_partid_narrowing(void);
+int mpam_set_cdp_mapping(bool enable);
bool mpam_partid_mapping_failed(void);
bool mpam_component_has_partid_entries(struct mpam_component *comp,
u16 logical_partid);
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 528159a48da4b..c470594807953 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -196,7 +196,7 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
u32 partid_i = RESCTRL_RESERVED_CLOSID, partid_d = RESCTRL_RESERVED_CLOSID;
struct mpam_resctrl_res *res = &mpam_resctrl_controls[RDT_RESOURCE_L3];
struct rdt_resource *l3 = &res->resctrl_res;
- int cpu;
+ int cpu, ret;
if (!IS_ENABLED(CONFIG_EXPERT) && enable) {
/*
@@ -206,8 +206,13 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
pr_warn("CDP not supported\n");
return -EOPNOTSUPP;
}
- if (enable && mpam_has_partid_narrowing())
- return -EOPNOTSUPP;
+ if (enable) {
+ if (mpam_partid_max < 1)
+ return -EINVAL;
+ ret = mpam_set_cdp_mapping(true);
+ if (ret)
+ return ret;
+ }
if (enable)
pr_warn("CDP is an expert feature and may cause MPAM to malfunction.\n");
@@ -241,9 +246,6 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = true;
if (enable) {
- if (mpam_partid_max < 1)
- return -EINVAL;
-
partid_d = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, CDP_DATA);
partid_i = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, CDP_CODE);
}
@@ -258,7 +260,7 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
mpam_set_cpu_defaults(cpu, partid_d, partid_i, 0, 0);
on_each_cpu(resctrl_arch_sync_cpu_closid_rmid, NULL, 1);
- return 0;
+ return enable ? 0 : mpam_set_cdp_mapping(false);
}
static bool mpam_resctrl_hide_cdp(enum resctrl_res_level rid)
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 11/13] arm_mpam: Add kunit tests for PARTID narrowing
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (9 preceding siblings ...)
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 ` Yunhui Cui
2026-11-30 2:29 ` [RFC PATCH 12/13] selftests/resctrl: Add a test for control ID allocation and reuse Yunhui Cui
` (2 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
PARTID narrowing shares allocation state across RIS and may update
several MSCs before a control change completes. Add KUnit coverage for
component mode selection, request and internal PARTID limits, per-MSC
allocation and mapping, CDP defaults, and failure paths that must keep
entries reserved until hardware mappings can be restored.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
drivers/resctrl/mpam_devices.c | 4 +
drivers/resctrl/mpam_resctrl.c | 9 +
drivers/resctrl/test_mpam_devices.c | 619 +++++++++++++++++++++++++++-
drivers/resctrl/test_mpam_resctrl.c | 172 ++++++++
4 files changed, 801 insertions(+), 3 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index f67bcda8209c9..665ac4f8fc546 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -5,6 +5,7 @@
#include <linux/acpi.h>
#include <linux/atomic.h>
+#include <kunit/static_stub.h>
#include <linux/arm_mpam.h>
#include <linux/bitfield.h>
#include <linux/bitmap.h>
@@ -2201,6 +2202,7 @@ static int mpam_get_msc_preferred_cpu(struct mpam_msc *msc)
static int mpam_touch_msc(struct mpam_msc *msc, int (*fn)(void *a), void *arg)
{
+ KUNIT_STATIC_STUB_REDIRECT(mpam_touch_msc, msc, fn, arg);
if (msc->iface != MPAM_IFACE_MMIO)
return fn(arg);
@@ -2983,6 +2985,7 @@ bool mpam_component_uses_partid_narrowing(struct mpam_component *comp)
bool mpam_has_partid_narrowing(void)
{
+ KUNIT_STATIC_STUB_REDIRECT(mpam_has_partid_narrowing);
return partid_narrowing_enabled;
}
@@ -3358,6 +3361,7 @@ static int mpam_remove_code_root(bool pending_only)
static void mpam_fail_partid_mapping(void)
{
+ KUNIT_STATIC_STUB_REDIRECT(mpam_fail_partid_mapping);
WRITE_ONCE(partid_mapping_failed, true);
mpam_disable_reason = "Failed to restore MPAM controller state.";
schedule_work(&mpam_broken_work);
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index c470594807953..1bd1035506fbc 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -3,6 +3,7 @@
#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
+#include <kunit/static_stub.h>
#include <linux/arm_mpam.h>
#include <linux/cacheinfo.h>
#include <linux/cpu.h>
@@ -1450,6 +1451,9 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
struct mpam_resctrl_res *res;
struct mpam_resctrl_dom *dom;
+ KUNIT_STATIC_STUB_REDIRECT(resctrl_arch_update_one, r, d, closid, t,
+ cfg_val);
+
lockdep_assert_cpus_held();
lockdep_assert_irqs_enabled();
@@ -1524,6 +1528,9 @@ static int resctrl_arch_update_domains_id(struct rdt_resource *r, u32 id,
int err;
struct rdt_ctrl_domain *d;
+ KUNIT_STATIC_STUB_REDIRECT(resctrl_arch_update_domains_id, r, id,
+ group_init);
+
lockdep_assert_cpus_held();
lockdep_assert_irqs_enabled();
@@ -1659,6 +1666,8 @@ static int mpam_component_partid_op(struct mpam_component *comp, u32 logical_ctr
size_t i, nr_partids = 0;
int error = 0;
+ KUNIT_STATIC_STUB_REDIRECT(mpam_component_partid_op, comp, logical_ctrl_id, op);
+
if (!mpam_component_uses_partid_narrowing(comp))
return 0;
diff --git a/drivers/resctrl/test_mpam_devices.c b/drivers/resctrl/test_mpam_devices.c
index 31871f5197299..06364229510bf 100644
--- a/drivers/resctrl/test_mpam_devices.c
+++ b/drivers/resctrl/test_mpam_devices.c
@@ -65,6 +65,17 @@ static inline void reset_fake_hierarchy(void)
INIT_LIST_HEAD(&fake_vmsc2.comp_list);
fake_vmsc2.msc = &fake_msc2;
+ memset(&fake_msc1, 0, sizeof(fake_msc1));
+ memset(&fake_msc2, 0, sizeof(fake_msc2));
+ INIT_LIST_HEAD(&fake_msc1.ris);
+ INIT_LIST_HEAD(&fake_msc2.ris);
+ mutex_init(&fake_msc1.cfg_lock);
+ mutex_init(&fake_msc2.cfg_lock);
+ mutex_init(&fake_msc1.part_sel_lock);
+ mutex_init(&fake_msc2.part_sel_lock);
+ fake_msc1.pdev = &fake_pdev;
+ fake_msc2.pdev = &fake_pdev;
+
memset(&fake_ris1, 0, sizeof(fake_ris1));
memset(&fake_ris2, 0, sizeof(fake_ris2));
fake_ris1.ris_idx = 1;
@@ -72,9 +83,6 @@ static inline void reset_fake_hierarchy(void)
fake_ris2.ris_idx = 2;
INIT_LIST_HEAD(&fake_ris2.msc_list);
- fake_msc1.pdev = &fake_pdev;
- fake_msc2.pdev = &fake_pdev;
-
list_add(&fake_class.classes_list, &fake_classes_list);
}
@@ -382,9 +390,614 @@ static void test_mpam_reset_msc_bitmap(struct kunit *test)
mutex_unlock(&fake_msc.part_sel_lock);
}
+static void test_mpam_component_partid_narrowing(struct kunit *test)
+{
+ reset_fake_hierarchy();
+ fake_comp1.class = &fake_class;
+ list_add(&fake_comp1.class_list, &fake_class.components);
+ fake_vmsc1.comp = &fake_comp1;
+ list_add(&fake_vmsc1.comp_list, &fake_comp1.vmsc);
+ fake_ris1.vmsc = &fake_vmsc1;
+ fake_ris2.vmsc = &fake_vmsc1;
+ list_add(&fake_ris1.vmsc_list, &fake_vmsc1.ris);
+ list_add(&fake_ris2.vmsc_list, &fake_vmsc1.ris);
+
+ fake_msc1.nr_intpartids = 4;
+ KUNIT_EXPECT_TRUE(test, mpam_component_all_mscs_narrow(&fake_comp1));
+
+ fake_msc1.nr_intpartids = 0;
+ KUNIT_EXPECT_FALSE(test, mpam_component_all_mscs_narrow(&fake_comp1));
+
+ fake_class.type = MPAM_CLASS_UNKNOWN;
+ fake_msc1.nr_intpartids = 4;
+ KUNIT_EXPECT_FALSE(test, mpam_component_all_mscs_narrow(&fake_comp1));
+}
+
+static void test_mpam_component_safe_partid_max(struct kunit *test)
+{
+ reset_fake_hierarchy();
+ fake_comp1.class = &fake_class;
+ list_add(&fake_comp1.class_list, &fake_class.components);
+ fake_vmsc1.comp = &fake_comp1;
+ list_add(&fake_vmsc1.comp_list, &fake_comp1.vmsc);
+ fake_vmsc2.comp = &fake_comp1;
+ list_add(&fake_vmsc2.comp_list, &fake_comp1.vmsc);
+ fake_msc1.nr_intpartids = 4;
+ fake_msc2.nr_intpartids = 4;
+ fake_msc1.nr_intpartids = 4;
+ fake_msc2.nr_intpartids = 8;
+
+ fake_comp1.uses_partid_narrowing = true;
+ KUNIT_EXPECT_EQ(test, mpam_component_safe_partid_max(&fake_comp1, 255),
+ 255);
+
+ fake_comp1.uses_partid_narrowing = false;
+ KUNIT_EXPECT_EQ(test, mpam_component_safe_partid_max(&fake_comp1, 255),
+ 3);
+
+ fake_msc1.nr_intpartids = 0;
+ fake_msc2.nr_intpartids = 0;
+ KUNIT_EXPECT_EQ(test, mpam_component_safe_partid_max(&fake_comp1, 255),
+ 255);
+}
+
+static void test_mpam_components_choose_partid_mode(struct kunit *test)
+{
+ u16 saved_partid_max;
+
+ reset_fake_hierarchy();
+ fake_comp1.class = &fake_class;
+ fake_comp2.class = &fake_class;
+ list_add(&fake_comp1.class_list, &fake_class.components);
+ list_add(&fake_comp2.class_list, &fake_class.components);
+
+ fake_vmsc1.comp = &fake_comp1;
+ fake_vmsc2.comp = &fake_comp2;
+ list_add(&fake_vmsc1.comp_list, &fake_comp1.vmsc);
+ list_add(&fake_vmsc2.comp_list, &fake_comp2.vmsc);
+ fake_msc1.nr_intpartids = 4;
+ fake_msc1.nr_intpartids = 32;
+ fake_msc2.nr_intpartids = 0;
+ fake_msc2.partid_max = 255;
+
+ mutex_lock(&mpam_list_lock);
+ spin_lock(&partid_max_lock);
+ saved_partid_max = mpam_partid_max;
+ mpam_partid_max = 255;
+ spin_unlock(&partid_max_lock);
+
+ mpam_enable_set_partid_narrowing(&fake_classes_list);
+
+ KUNIT_EXPECT_TRUE(test, mpam_has_partid_narrowing());
+ KUNIT_EXPECT_TRUE(test, fake_comp1.uses_partid_narrowing);
+ KUNIT_EXPECT_FALSE(test, fake_comp2.uses_partid_narrowing);
+ KUNIT_EXPECT_EQ(test, mpam_partid_max, 255);
+
+ spin_lock(&partid_max_lock);
+ mpam_partid_max = saved_partid_max;
+ spin_unlock(&partid_max_lock);
+ partid_narrowing_enabled = false;
+ mutex_unlock(&mpam_list_lock);
+}
+
+static void test_mpam_logical_partid_allocator(struct kunit *test)
+{
+ unsigned long entries[BITS_TO_LONGS(8)] = {};
+ unsigned long pending[BITS_TO_LONGS(8)] = {};
+ unsigned long intpartids[BITS_TO_LONGS(4)] = {};
+ u16 map[8] = {};
+ u16 pair[] = { 1, 2 };
+ u16 partid;
+ int ret;
+
+ reset_fake_hierarchy();
+ fake_comp1.class = &fake_class;
+ fake_comp1.uses_partid_narrowing = true;
+ list_add(&fake_comp1.class_list, &fake_class.components);
+ fake_vmsc1.comp = &fake_comp1;
+ list_add(&fake_vmsc1.comp_list, &fake_comp1.vmsc);
+ fake_ris1.vmsc = &fake_vmsc1;
+ fake_ris2.vmsc = &fake_vmsc1;
+ list_add(&fake_ris1.vmsc_list, &fake_vmsc1.ris);
+ list_add(&fake_ris2.vmsc_list, &fake_vmsc1.ris);
+
+ fake_msc1.nr_intpartids = 4;
+ fake_msc1.partid_to_intpartid = map;
+ fake_msc1.intpartid_allocated = intpartids;
+ fake_msc1.partid_has_entry = entries;
+ fake_msc1.partid_pending = pending;
+ __set_bit(0, intpartids);
+ __set_bit(0, entries);
+
+ ret = mpam_prepare_partid_entries(&fake_comp1, pair, ARRAY_SIZE(pair));
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, map[1], 1);
+ KUNIT_EXPECT_EQ(test, map[2], 2);
+ KUNIT_EXPECT_TRUE(test,
+ mpam_component_has_partid_entries(&fake_comp1, 1));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, pending));
+ KUNIT_EXPECT_EQ(test, bitmap_weight(intpartids, 4), 3);
+
+ partid = 3;
+ KUNIT_ASSERT_EQ(test, mpam_prepare_partid_entries(&fake_comp1, &partid, 1), 0);
+ partid = 4;
+ KUNIT_EXPECT_EQ(test, mpam_prepare_partid_entries(&fake_comp1, &partid, 1),
+ -ENOSPC);
+}
+
+struct test_partid_maps {
+ DECLARE_BITMAP(entries1, 8);
+ DECLARE_BITMAP(entries2, 8);
+ DECLARE_BITMAP(pending1, 8);
+ DECLARE_BITMAP(pending2, 8);
+ DECLARE_BITMAP(intpartids1, 4);
+ DECLARE_BITMAP(intpartids2, 4);
+ u16 map1[8];
+ u16 map2[8];
+};
+
+static struct test_partid_maps *setup_test_partid_maps(struct kunit *test)
+{
+ struct test_partid_maps *maps;
+
+ maps = kunit_kzalloc(test, sizeof(*maps), GFP_KERNEL);
+ if (!maps)
+ return NULL;
+
+ reset_fake_hierarchy();
+ fake_comp1.class = &fake_class;
+ fake_comp1.uses_partid_narrowing = true;
+ list_add(&fake_comp1.class_list, &fake_class.components);
+ fake_vmsc1.comp = &fake_comp1;
+ fake_vmsc2.comp = &fake_comp1;
+ fake_vmsc1.msc = &fake_msc1;
+ fake_vmsc2.msc = &fake_msc2;
+ list_add(&fake_vmsc1.comp_list, &fake_comp1.vmsc);
+ list_add(&fake_vmsc2.comp_list, &fake_comp1.vmsc);
+ fake_ris1.vmsc = &fake_vmsc1;
+ fake_ris2.vmsc = &fake_vmsc2;
+ list_add(&fake_ris1.vmsc_list, &fake_vmsc1.ris);
+ list_add(&fake_ris2.vmsc_list, &fake_vmsc2.ris);
+ list_add(&fake_ris1.msc_list, &fake_msc1.ris);
+ list_add(&fake_ris2.msc_list, &fake_msc2.ris);
+ fake_msc1.nr_intpartids = 4;
+ fake_msc2.nr_intpartids = 4;
+ fake_msc1.partid_to_intpartid = maps->map1;
+ fake_msc2.partid_to_intpartid = maps->map2;
+ fake_msc1.partid_has_entry = maps->entries1;
+ fake_msc2.partid_has_entry = maps->entries2;
+ fake_msc1.partid_pending = maps->pending1;
+ fake_msc2.partid_pending = maps->pending2;
+ fake_msc1.intpartid_allocated = maps->intpartids1;
+ fake_msc2.intpartid_allocated = maps->intpartids2;
+ fake_msc1.partid_max = 7;
+ fake_msc2.partid_max = 7;
+ fake_msc1.iface = MPAM_IFACE_MMIO;
+ fake_msc2.iface = MPAM_IFACE_MMIO;
+ __set_bit(0, maps->intpartids1);
+ __set_bit(0, maps->intpartids2);
+ __set_bit(0, maps->entries1);
+ __set_bit(0, maps->entries2);
+ return maps;
+}
+
+static void test_mpam_partid_pair_preflight(struct kunit *test)
+{
+ struct test_partid_maps *maps = setup_test_partid_maps(test);
+ u16 pair[] = { 6, 7 };
+ u16 repeated[] = { 6, 6 };
+ int ret;
+
+ KUNIT_ASSERT_NOT_NULL(test, maps);
+ __set_bit(1, maps->intpartids2);
+ __set_bit(2, maps->intpartids2);
+ ret = mpam_prepare_partid_entries(&fake_comp1, pair, ARRAY_SIZE(pair));
+ KUNIT_EXPECT_EQ(test, ret, -ENOSPC);
+ KUNIT_EXPECT_EQ(test, bitmap_weight(maps->intpartids1, 4), 1);
+ KUNIT_EXPECT_EQ(test, bitmap_weight(maps->intpartids2, 4), 3);
+ KUNIT_EXPECT_FALSE(test, test_bit(6, maps->entries1));
+ KUNIT_EXPECT_FALSE(test, test_bit(6, maps->entries2));
+
+ ret = mpam_prepare_partid_entries(&fake_comp1, repeated, ARRAY_SIZE(repeated));
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_TRUE(test, test_bit(6, maps->entries1));
+ KUNIT_EXPECT_TRUE(test, test_bit(6, maps->entries2));
+}
+
+static void test_mpam_partid_pair_allocation(struct kunit *test)
+{
+ struct test_partid_maps *maps = setup_test_partid_maps(test);
+ u16 pair[] = { 6, 7 };
+ u16 partid = 4;
+ int ret;
+
+ KUNIT_ASSERT_NOT_NULL(test, maps);
+ __set_bit(1, maps->intpartids2);
+ ret = mpam_prepare_partid_entries(&fake_comp1, pair, ARRAY_SIZE(pair));
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, maps->map1[6], 1);
+ KUNIT_EXPECT_EQ(test, maps->map2[6], 2);
+ KUNIT_EXPECT_EQ(test, maps->map1[7], 2);
+ KUNIT_EXPECT_EQ(test, maps->map2[7], 3);
+ ret = mpam_prepare_partid_entries(&fake_comp1, pair, ARRAY_SIZE(pair));
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, bitmap_weight(maps->intpartids1, 4), 3);
+ KUNIT_EXPECT_EQ(test, bitmap_weight(maps->intpartids2, 4), 4);
+ KUNIT_EXPECT_EQ(test, mpam_prepare_partid_entries(&fake_comp1, &partid, 1),
+ -ENOSPC);
+}
+
+static void test_mpam_default_partid_selection(struct kunit *test)
+{
+ for (u16 partid = 0; partid < 8; partid++) {
+ KUNIT_EXPECT_EQ(test, mpam_default_partid(partid, false), 0);
+ KUNIT_EXPECT_EQ(test, mpam_default_partid(partid, true),
+ partid & 1);
+ }
+}
+
+static void test_mpam_cleanup_srcu(void *arg)
+{
+ struct srcu_struct *srcu = arg;
+
+ cleanup_srcu_struct(srcu);
+ memset(srcu, 0, sizeof(*srcu));
+}
+
+static void test_mpam_partid_release_retry(struct kunit *test)
+{
+ struct test_partid_maps *maps = setup_test_partid_maps(test);
+ void *regs1, *regs2;
+ u16 partid = 6;
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_SMP)) {
+ kunit_skip(test, "Requires an unavailable CPU target");
+ return;
+ }
+ KUNIT_ASSERT_NOT_NULL(test, maps);
+ /* The driver skips SRCU setup when the virtual CPU has no MPAM. */
+ if (!mpam_srcu.sda) {
+ KUNIT_ASSERT_EQ(test, init_srcu_struct(&mpam_srcu), 0);
+ ret = kunit_add_action_or_reset(test, test_mpam_cleanup_srcu,
+ &mpam_srcu);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ }
+ regs1 = kunit_kzalloc(test, SZ_64K, GFP_KERNEL);
+ regs2 = kunit_kzalloc(test, SZ_64K, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, regs1);
+ KUNIT_ASSERT_NOT_NULL(test, regs2);
+ fake_msc1.mapped_hwpage = (void __iomem *)regs1;
+ fake_msc2.mapped_hwpage = (void __iomem *)regs2;
+ fake_msc1.mapped_hwpage_sz = SZ_64K;
+ fake_msc2.mapped_hwpage_sz = SZ_64K;
+ KUNIT_ASSERT_EQ(test, mpam_prepare_partid_entries(&fake_comp1, &partid, 1), 0);
+ cpus_read_lock();
+ cpumask_set_cpu(raw_smp_processor_id(), &fake_msc1.accessibility);
+ cpumask_clear(&fake_msc2.accessibility);
+ ret = mpam_release_partid(&fake_comp1, 6, 0);
+ cpus_read_unlock();
+ KUNIT_EXPECT_LT(test, ret, 0);
+ KUNIT_EXPECT_TRUE(test, test_bit(1, maps->intpartids1));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, maps->intpartids2));
+ KUNIT_EXPECT_TRUE(test, test_bit(6, maps->entries1));
+ KUNIT_EXPECT_TRUE(test, test_bit(6, maps->entries2));
+
+ cpus_read_lock();
+ cpumask_set_cpu(raw_smp_processor_id(), &fake_msc2.accessibility);
+ ret = mpam_release_partid(&fake_comp1, 6, 0);
+ cpus_read_unlock();
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ KUNIT_EXPECT_FALSE(test, test_bit(1, maps->intpartids1));
+ KUNIT_EXPECT_FALSE(test, test_bit(1, maps->intpartids2));
+ KUNIT_EXPECT_FALSE(test, test_bit(6, maps->entries1));
+ KUNIT_EXPECT_FALSE(test, test_bit(6, maps->entries2));
+ KUNIT_EXPECT_EQ(test, maps->map1[6], 0);
+ KUNIT_EXPECT_EQ(test, maps->map2[6], 0);
+ partid = 4;
+ KUNIT_ASSERT_EQ(test, mpam_prepare_partid_entries(&fake_comp1, &partid, 1), 0);
+ KUNIT_EXPECT_EQ(test, maps->map1[4], 1);
+ KUNIT_EXPECT_EQ(test, maps->map2[4], 1);
+}
+
+struct test_mapping_update {
+ struct test_partid_maps *maps;
+ struct list_head saved_classes;
+ struct list_head saved_mscs;
+ unsigned int saved_count;
+ u16 saved_partid_max;
+ bool saved_published;
+ bool saved_enabled;
+ bool saved_failed;
+ bool fail_config;
+ int fail_enable;
+ int fail_restore;
+ unsigned int map_writes;
+ unsigned int config_writes;
+ bool published_without_config;
+ unsigned int code_removals;
+ u16 hardware_map[2][8];
+};
+
+static void test_restore_mapping_state(void *arg)
+{
+ struct test_mapping_update *state = arg;
+
+ list_splice_init(&mpam_classes, &fake_classes_list);
+ list_splice_init(&state->saved_classes, &mpam_classes);
+ list_del_init(&fake_msc1.all_msc_list);
+ list_del_init(&fake_msc2.all_msc_list);
+ list_splice_init(&state->saved_mscs, &mpam_all_msc);
+ default_partid_count = state->saved_count;
+ partid_narrowing_enabled = state->saved_enabled;
+ partid_mapping_failed = state->saved_failed;
+ spin_lock(&partid_max_lock);
+ mpam_partid_max = state->saved_partid_max;
+ partid_max_published = state->saved_published;
+ spin_unlock(&partid_max_lock);
+}
+
+static void test_mapping_failure_stub(void)
+{
+ WRITE_ONCE(partid_mapping_failed, true);
+}
+
+static int test_mapping_touch_stub(struct mpam_msc *msc,
+ int (*fn)(void *arg), void *arg)
+{
+ struct kunit *test = kunit_get_current_test();
+ struct test_mapping_update *state = test->priv;
+
+ if (fn == __write_internal_config) {
+ state->config_writes++;
+ return state->fail_config ? -EIO : 0;
+ }
+ if (fn == __mpam_set_partid_map) {
+ struct mpam_partid_map_arg *map = arg;
+ unsigned int index = msc == &fake_msc1 ? 0 : 1;
+
+ state->map_writes++;
+ if (!state->config_writes)
+ state->published_without_config = true;
+ if (default_partid_count == 2 && map->partid == state->fail_enable) {
+ state->fail_enable = -1;
+ return -EIO;
+ }
+ if (default_partid_count == 1 && map->partid == state->fail_restore) {
+ state->fail_restore = -1;
+ return -EIO;
+ }
+ if (default_partid_count == 1 && map->partid == 1 &&
+ map->intpartid == 0)
+ state->code_removals++;
+ state->hardware_map[index][map->partid] = map->intpartid;
+ }
+
+ return 0;
+}
+
+static struct test_mapping_update *setup_mapping_update(struct kunit *test)
+{
+ struct test_mapping_update *state;
+ int ret;
+
+ state = kunit_kzalloc(test, sizeof(*state), GFP_KERNEL);
+ if (!state)
+ return NULL;
+ if (!mpam_srcu.sda) {
+ if (init_srcu_struct(&mpam_srcu))
+ return NULL;
+ ret = kunit_add_action_or_reset(test, test_mpam_cleanup_srcu,
+ &mpam_srcu);
+ if (ret)
+ return NULL;
+ }
+ state->maps = setup_test_partid_maps(test);
+ if (!state->maps)
+ return NULL;
+ fake_comp1.cfg = kunit_kcalloc(test, 8, sizeof(*fake_comp1.cfg), GFP_KERNEL);
+ if (!fake_comp1.cfg)
+ return NULL;
+ fake_ris1.in_reset_state = true;
+ fake_ris2.in_reset_state = true;
+ state->saved_count = default_partid_count;
+ state->saved_enabled = partid_narrowing_enabled;
+ state->saved_failed = partid_mapping_failed;
+ spin_lock(&partid_max_lock);
+ state->saved_partid_max = mpam_partid_max;
+ state->saved_published = partid_max_published;
+ mpam_partid_max = 7;
+ partid_max_published = true;
+ spin_unlock(&partid_max_lock);
+ INIT_LIST_HEAD(&state->saved_classes);
+ list_splice_init(&mpam_classes, &state->saved_classes);
+ list_splice_init(&fake_classes_list, &mpam_classes);
+ INIT_LIST_HEAD(&state->saved_mscs);
+ list_splice_init(&mpam_all_msc, &state->saved_mscs);
+ INIT_LIST_HEAD(&fake_msc1.all_msc_list);
+ INIT_LIST_HEAD(&fake_msc2.all_msc_list);
+ list_add_tail(&fake_msc1.all_msc_list, &mpam_all_msc);
+ list_add_tail(&fake_msc2.all_msc_list, &mpam_all_msc);
+ default_partid_count = 1;
+ partid_narrowing_enabled = true;
+ partid_mapping_failed = false;
+ state->fail_enable = -1;
+ state->fail_restore = -1;
+ test->priv = state;
+ ret = kunit_add_action_or_reset(test, test_restore_mapping_state, state);
+ if (ret)
+ return NULL;
+ kunit_activate_static_stub(test, mpam_touch_msc, test_mapping_touch_stub);
+ kunit_activate_static_stub(test, mpam_fail_partid_mapping,
+ test_mapping_failure_stub);
+
+ return state;
+}
+
+static void test_mpam_cdp_disable_restore_failure(struct kunit *test)
+{
+ struct test_mapping_update *state = setup_mapping_update(test);
+ u16 code_partid = 1;
+ unsigned int i;
+ int ret;
+
+ KUNIT_ASSERT_NOT_NULL(test, state);
+ KUNIT_ASSERT_EQ(test, mpam_prepare_partid_entries(&fake_comp1, &code_partid, 1), 0);
+ mpam_finish_partid(&fake_comp1, code_partid);
+ default_partid_count = 2;
+ for (i = 0; i < 8; i++) {
+ state->hardware_map[0][i] = i & 1;
+ state->hardware_map[1][i] = i & 1;
+ }
+ state->fail_restore = 3;
+ cpus_read_lock();
+ ret = mpam_set_cdp_mapping(false);
+ cpus_read_unlock();
+
+ KUNIT_EXPECT_EQ(test, ret, -EIO);
+ KUNIT_EXPECT_TRUE(test, mpam_partid_mapping_failed());
+ KUNIT_EXPECT_EQ(test, state->hardware_map[0][3], 1);
+ KUNIT_EXPECT_EQ(test, state->code_removals, 0);
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->intpartids1));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->intpartids2));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->entries1));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->entries2));
+}
+
+static void test_mpam_cdp_enable_rollback_failure(struct kunit *test)
+{
+ struct test_mapping_update *state = setup_mapping_update(test);
+ int ret;
+
+ KUNIT_ASSERT_NOT_NULL(test, state);
+ state->fail_enable = 5;
+ state->fail_restore = 3;
+ cpus_read_lock();
+ ret = mpam_set_cdp_mapping(true);
+ cpus_read_unlock();
+
+ KUNIT_EXPECT_EQ(test, ret, -EIO);
+ KUNIT_EXPECT_TRUE(test, mpam_partid_mapping_failed());
+ KUNIT_EXPECT_EQ(test, state->hardware_map[0][3], 1);
+ KUNIT_EXPECT_EQ(test, state->code_removals, 0);
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->intpartids1));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->intpartids2));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->pending1));
+ KUNIT_EXPECT_TRUE(test, test_bit(1, state->maps->pending2));
+}
+
+static void test_mpam_config_restore_failure(struct kunit *test)
+{
+ struct test_mapping_update *state = setup_mapping_update(test);
+
+ KUNIT_ASSERT_NOT_NULL(test, state);
+ state->fail_config = true;
+ cpus_read_lock();
+ scoped_guard(srcu, &mpam_srcu)
+ mpam_reprogram_msc(&fake_msc1);
+ cpus_read_unlock();
+
+ KUNIT_EXPECT_EQ(test, state->map_writes, 0);
+ KUNIT_EXPECT_TRUE(test, mpam_partid_mapping_failed());
+}
+
+static void test_mpam_mapping_restore_failure(struct kunit *test)
+{
+ struct test_mapping_update *state = setup_mapping_update(test);
+
+ KUNIT_ASSERT_NOT_NULL(test, state);
+ state->fail_restore = 3;
+ cpus_read_lock();
+ scoped_guard(srcu, &mpam_srcu)
+ mpam_reprogram_msc(&fake_msc1);
+ cpus_read_unlock();
+
+ KUNIT_EXPECT_EQ(test, state->map_writes, 4);
+ KUNIT_EXPECT_TRUE(test, mpam_partid_mapping_failed());
+}
+
+static void test_mpam_initial_root_mapping(struct kunit *test)
+{
+ struct test_mapping_update *state = setup_mapping_update(test);
+ int ret;
+
+ KUNIT_ASSERT_NOT_NULL(test, state);
+ state->hardware_map[0][0] = 3;
+ cpus_read_lock();
+ scoped_guard(srcu, &mpam_srcu)
+ ret = mpam_init_msc_partid_mappings(&fake_msc1);
+ cpus_read_unlock();
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, state->hardware_map[0][0], 0);
+ KUNIT_EXPECT_GT(test, state->config_writes, 0);
+ KUNIT_EXPECT_FALSE(test, state->published_without_config);
+}
+
+static void test_mpam_shared_msc_mode(struct kunit *test)
+{
+ struct mpam_vmsc *shared;
+ u16 saved_max;
+ bool saved_enabled;
+
+ reset_fake_hierarchy();
+ shared = kunit_kzalloc(test, sizeof(*shared), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, shared);
+ fake_comp1.class = &fake_class;
+ fake_comp2.class = &fake_class;
+ list_add(&fake_comp1.class_list, &fake_class.components);
+ list_add(&fake_comp2.class_list, &fake_class.components);
+ fake_vmsc1.comp = &fake_comp1;
+ fake_vmsc2.comp = &fake_comp2;
+ list_add(&fake_vmsc1.comp_list, &fake_comp1.vmsc);
+ list_add(&fake_vmsc2.comp_list, &fake_comp2.vmsc);
+ shared->comp = &fake_comp2;
+ shared->msc = &fake_msc1;
+ INIT_LIST_HEAD(&shared->ris);
+ INIT_LIST_HEAD(&shared->comp_list);
+ list_add(&shared->comp_list, &fake_comp2.vmsc);
+ fake_ris1.vmsc = &fake_vmsc1;
+ fake_ris2.vmsc = shared;
+ list_add(&fake_ris1.msc_list, &fake_msc1.ris);
+ list_add(&fake_ris2.msc_list, &fake_msc1.ris);
+ fake_msc1.nr_intpartids = 4;
+ fake_msc1.nr_intpartids = 32;
+ fake_msc2.nr_intpartids = 0;
+
+ mutex_lock(&mpam_list_lock);
+ spin_lock(&partid_max_lock);
+ saved_max = mpam_partid_max;
+ mpam_partid_max = 255;
+ spin_unlock(&partid_max_lock);
+ saved_enabled = partid_narrowing_enabled;
+ mpam_enable_set_partid_narrowing(&fake_classes_list);
+ KUNIT_EXPECT_FALSE(test, fake_comp1.uses_partid_narrowing);
+ KUNIT_EXPECT_FALSE(test, fake_comp2.uses_partid_narrowing);
+ KUNIT_EXPECT_FALSE(test, mpam_has_partid_narrowing());
+ KUNIT_EXPECT_EQ(test, mpam_partid_max, 31);
+ spin_lock(&partid_max_lock);
+ mpam_partid_max = saved_max;
+ spin_unlock(&partid_max_lock);
+ partid_narrowing_enabled = saved_enabled;
+ mutex_unlock(&mpam_list_lock);
+}
+
static struct kunit_case mpam_devices_test_cases[] = {
+ KUNIT_CASE(test_mpam_cdp_disable_restore_failure),
+ KUNIT_CASE(test_mpam_cdp_enable_rollback_failure),
+ KUNIT_CASE(test_mpam_config_restore_failure),
+ KUNIT_CASE(test_mpam_mapping_restore_failure),
+ KUNIT_CASE(test_mpam_initial_root_mapping),
+ KUNIT_CASE(test_mpam_shared_msc_mode),
KUNIT_CASE(test_mpam_reset_msc_bitmap),
KUNIT_CASE(test_mpam_enable_merge_features),
+ KUNIT_CASE(test_mpam_component_partid_narrowing),
+ KUNIT_CASE(test_mpam_component_safe_partid_max),
+ KUNIT_CASE(test_mpam_components_choose_partid_mode),
+ KUNIT_CASE(test_mpam_logical_partid_allocator),
+ KUNIT_CASE(test_mpam_partid_pair_preflight),
+ KUNIT_CASE(test_mpam_partid_pair_allocation),
+ KUNIT_CASE(test_mpam_default_partid_selection),
+ KUNIT_CASE(test_mpam_partid_release_retry),
KUNIT_CASE(test__props_mismatch),
{}
};
diff --git a/drivers/resctrl/test_mpam_resctrl.c b/drivers/resctrl/test_mpam_resctrl.c
index b93d6ad87e43f..7fcae7aa2b8d9 100644
--- a/drivers/resctrl/test_mpam_resctrl.c
+++ b/drivers/resctrl/test_mpam_resctrl.c
@@ -296,7 +296,179 @@ static void test_percent_to_max_rounding(struct kunit *test)
KUNIT_EXPECT_LE(test, 4 * num_rounded_up, 3 * total);
}
+struct test_ctrl_update {
+ struct rdt_resource resource;
+ struct mpam_resctrl_dom domains[2];
+ struct mpam_component components[2];
+ unsigned int calls[2];
+};
+
+static bool test_narrowing_enabled_stub(void)
+{
+ return true;
+}
+
+static int test_update_one_stub(struct rdt_resource *r,
+ struct rdt_ctrl_domain *d, u32 closid,
+ enum resctrl_conf_type type, u32 value)
+{
+ struct test_ctrl_update *state = kunit_get_current_test()->priv;
+ struct mpam_resctrl_dom *dom;
+
+ dom = container_of(d, struct mpam_resctrl_dom, resctrl_ctrl_dom);
+ state->calls[dom->ctrl_comp == &state->components[0] ? 0 : 1]++;
+ return 0;
+}
+
+static int test_update_domains_stub(struct rdt_resource *r, u32 id,
+ bool group_init)
+{
+ struct rdt_ctrl_domain *d;
+ int ret;
+
+ list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
+ struct mpam_resctrl_dom *dom;
+ enum resctrl_conf_type type;
+
+ dom = container_of(d, struct mpam_resctrl_dom,
+ resctrl_ctrl_dom);
+ if (group_init && id &&
+ mpam_component_uses_partid_narrowing(dom->ctrl_comp))
+ continue;
+ for (type = 0; type < CDP_NUM_TYPES; type++) {
+ struct resctrl_staged_config *cfg = &d->staged_config[type];
+
+ if (!cfg->have_new_ctrl)
+ continue;
+ ret = resctrl_arch_update_one(r, d, id, type,
+ cfg->new_ctrl);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static void test_mpam_mixed_domain_initialization(struct kunit *test)
+{
+ struct test_ctrl_update *state;
+ unsigned int i;
+ int ret;
+
+ state = kunit_kzalloc(test, sizeof(*state), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, state);
+ test->priv = state;
+ INIT_LIST_HEAD(&state->resource.ctrl_domains);
+ state->components[1].uses_partid_narrowing = true;
+ for (i = 0; i < 2; i++) {
+ struct rdt_ctrl_domain *d = &state->domains[i].resctrl_ctrl_dom;
+
+ state->domains[i].ctrl_comp = &state->components[i];
+ INIT_LIST_HEAD(&d->hdr.list);
+ list_add_tail(&d->hdr.list, &state->resource.ctrl_domains);
+ d->staged_config[CDP_NONE].have_new_ctrl = true;
+ }
+ kunit_activate_static_stub(test, mpam_has_partid_narrowing,
+ test_narrowing_enabled_stub);
+ kunit_activate_static_stub(test, resctrl_arch_update_domains_id,
+ test_update_domains_stub);
+ kunit_activate_static_stub(test, resctrl_arch_update_one, test_update_one_stub);
+ cpus_read_lock();
+ ret = resctrl_arch_init_ctrl_domains(&state->resource, 4);
+ cpus_read_unlock();
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, state->calls[0], 1);
+ KUNIT_EXPECT_EQ(test, state->calls[1], 0);
+
+ memset(state->calls, 0, sizeof(state->calls));
+ cpus_read_lock();
+ ret = resctrl_arch_update_domains(&state->resource, 4);
+ cpus_read_unlock();
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, state->calls[0], 1);
+ KUNIT_EXPECT_EQ(test, state->calls[1], 1);
+
+ memset(state->calls, 0, sizeof(state->calls));
+ cpus_read_lock();
+ ret = resctrl_arch_init_ctrl_domains(&state->resource, 0);
+ cpus_read_unlock();
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, state->calls[0], 1);
+ KUNIT_EXPECT_EQ(test, state->calls[1], 1);
+}
+
+struct test_partid_operations {
+ struct mpam_class class;
+ struct mpam_component components[2];
+ struct mpam_class *saved_classes[RDT_NUM_RESOURCES];
+ bool saved_alloc_capable[RDT_NUM_RESOURCES];
+ unsigned int calls[2];
+};
+
+static void test_restore_resctrl_classes(void *arg)
+{
+ struct test_partid_operations *state = arg;
+ unsigned int i;
+
+ for (i = 0; i < RDT_NUM_RESOURCES; i++) {
+ mpam_resctrl_controls[i].class = state->saved_classes[i];
+ mpam_resctrl_controls[i].resctrl_res.alloc_capable =
+ state->saved_alloc_capable[i];
+ }
+}
+
+static int test_component_partid_op_stub(struct mpam_component *comp, u32 ctrl_id,
+ enum mpam_partid_op op)
+{
+ struct test_partid_operations *state = kunit_get_current_test()->priv;
+ unsigned int index = comp == &state->components[0] ? 0 : 1;
+
+ state->calls[index]++;
+ return index ? 0 : -EIO;
+}
+
+static void test_mpam_abort_all_components(struct kunit *test)
+{
+ struct test_partid_operations *state;
+ unsigned int i;
+ int ret;
+
+ state = kunit_kzalloc(test, sizeof(*state), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, state);
+ test->priv = state;
+ INIT_LIST_HEAD(&state->class.components);
+ for (i = 0; i < 2; i++) {
+ INIT_LIST_HEAD(&state->components[i].class_list);
+ list_add_tail(&state->components[i].class_list, &state->class.components);
+ }
+ for (i = 0; i < RDT_NUM_RESOURCES; i++) {
+ state->saved_classes[i] = mpam_resctrl_controls[i].class;
+ state->saved_alloc_capable[i] =
+ mpam_resctrl_controls[i].resctrl_res.alloc_capable;
+ mpam_resctrl_controls[i].class = NULL;
+ }
+ KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test,
+ test_restore_resctrl_classes, state), 0);
+ mpam_resctrl_controls[RDT_RESOURCE_L3].class = &state->class;
+ mpam_resctrl_controls[RDT_RESOURCE_L3].resctrl_res.alloc_capable = true;
+ kunit_activate_static_stub(test, mpam_component_partid_op,
+ test_component_partid_op_stub);
+ ret = mpam_all_components_partid_op(4, MPAM_PARTID_ABORT);
+ KUNIT_EXPECT_EQ(test, ret, -EIO);
+ KUNIT_EXPECT_EQ(test, state->calls[0], 1);
+ KUNIT_EXPECT_EQ(test, state->calls[1], 1);
+
+ memset(state->calls, 0, sizeof(state->calls));
+ ret = mpam_all_components_partid_op(4, MPAM_PARTID_COMMIT);
+ KUNIT_EXPECT_EQ(test, ret, -EIO);
+ KUNIT_EXPECT_EQ(test, state->calls[0], 1);
+ KUNIT_EXPECT_EQ(test, state->calls[1], 0);
+}
+
static struct kunit_case mpam_resctrl_test_cases[] = {
+ KUNIT_CASE(test_mpam_mixed_domain_initialization),
+ KUNIT_CASE(test_mpam_abort_all_components),
KUNIT_CASE(test_get_mba_granularity),
KUNIT_CASE_PARAM(test_mbw_max_to_percent, test_percent_value_gen_params),
KUNIT_CASE_PARAM(test_percent_to_mbw_max, test_percent_value_gen_params),
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 12/13] selftests/resctrl: Add a test for control ID allocation and reuse
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (10 preceding siblings ...)
2026-11-30 2:29 ` [RFC PATCH 11/13] arm_mpam: Add kunit tests for PARTID narrowing Yunhui Cui
@ 2026-11-30 2:29 ` 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
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
A control group that reads the root policy may either share the root
entry or own a private entry with the same value. Add a CTRL_ID test that
distinguishes controller-local and identity modes with a root policy
update, checks that same-value writes allocate private entries, releases
and reuses an entry after exhaustion, and verifies that a reused direct
ID does not retain the previous policy.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
.../testing/selftests/resctrl/ctrl_id_test.c | 380 ++++++++++++++++++
tools/testing/selftests/resctrl/resctrl.h | 1 +
.../testing/selftests/resctrl/resctrl_tests.c | 1 +
3 files changed, 382 insertions(+)
create mode 100644 tools/testing/selftests/resctrl/ctrl_id_test.c
diff --git a/tools/testing/selftests/resctrl/ctrl_id_test.c b/tools/testing/selftests/resctrl/ctrl_id_test.c
new file mode 100644
index 0000000000000..e9b26ff2d6b5e
--- /dev/null
+++ b/tools/testing/selftests/resctrl/ctrl_id_test.c
@@ -0,0 +1,380 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Test the relationship between resctrl control groups and hardware entries.
+ */
+#include "resctrl.h"
+
+#include <fcntl.h>
+
+#define CTRL_ID_MAX_GROUPS 64
+#define CTRL_ID_NAME_LEN 64
+#define CTRL_ID_VALUE_LEN 64
+
+struct ctrl_id_group {
+ char name[CTRL_ID_NAME_LEN];
+ bool created;
+};
+
+struct ctrl_id_ctx {
+ struct ctrl_id_group groups[CTRL_ID_MAX_GROUPS];
+ char root_value[CTRL_ID_VALUE_LEN];
+ const char *resource;
+ int domain_id;
+ bool root_changed;
+};
+
+static struct ctrl_id_ctx ctrl_id_ctx;
+
+static int ctrl_id_schemata_path(char *path, size_t size, const char *group)
+{
+ int len;
+
+ if (group)
+ len = snprintf(path, size, "%s/%s/schemata", RESCTRL_PATH,
+ group);
+ else
+ len = snprintf(path, size, "%s/schemata", RESCTRL_PATH);
+
+ if (len < 0 || (size_t)len >= size)
+ return -ENAMETOOLONG;
+
+ return 0;
+}
+
+static int ctrl_id_read_policy(const char *group, char *value, size_t size)
+{
+ char path[PATH_MAX];
+ char *line = NULL;
+ size_t line_size = 0;
+ FILE *fp;
+ int ret;
+
+ ret = ctrl_id_schemata_path(path, sizeof(path), group);
+ if (ret)
+ return ret;
+
+ fp = fopen(path, "r");
+ if (!fp)
+ return -errno;
+
+ ret = -ENOENT;
+ while (getline(&line, &line_size, fp) >= 0) {
+ char *entry;
+ char *resource_line = line;
+ char *saveptr;
+ size_t resource_len;
+
+ while (isspace(*resource_line))
+ resource_line++;
+ resource_len = strlen(ctrl_id_ctx.resource);
+ if (strncmp(resource_line, ctrl_id_ctx.resource, resource_len) ||
+ resource_line[resource_len] != ':')
+ continue;
+
+ entry = strtok_r(resource_line + resource_len + 1, ";\n",
+ &saveptr);
+ while (entry) {
+ char current[CTRL_ID_VALUE_LEN];
+ unsigned int domain;
+ int len;
+
+ if (sscanf(entry, "%u=%63s", &domain, current) == 2 &&
+ domain == ctrl_id_ctx.domain_id) {
+ len = snprintf(value, size, "%s", current);
+ if (len < 0 || (size_t)len >= size)
+ ret = -ENOSPC;
+ else
+ ret = 0;
+ goto out;
+ }
+ entry = strtok_r(NULL, ";\n", &saveptr);
+ }
+ }
+
+out:
+ free(line);
+ fclose(fp);
+ return ret;
+}
+
+static int ctrl_id_write_policy(const char *group, const char *value)
+{
+ char path[PATH_MAX];
+ char schemata[256];
+ ssize_t written;
+ int fd;
+ int len;
+ int ret;
+
+ ret = ctrl_id_schemata_path(path, sizeof(path), group);
+ if (ret)
+ return ret;
+
+ len = snprintf(schemata, sizeof(schemata), "%s:%d=%s\n",
+ ctrl_id_ctx.resource, ctrl_id_ctx.domain_id, value);
+ if (len < 0 || len >= sizeof(schemata))
+ return -ENAMETOOLONG;
+
+ fd = open(path, O_WRONLY);
+ if (fd < 0)
+ return -errno;
+
+ written = write(fd, schemata, len);
+ ret = written < 0 ? -errno : 0;
+ close(fd);
+ if (!ret && written != len)
+ ret = -EIO;
+
+ return ret;
+}
+
+static int ctrl_id_create_group(unsigned int index)
+{
+ struct ctrl_id_group *group = &ctrl_id_ctx.groups[index];
+ char path[PATH_MAX];
+ int len;
+
+ len = snprintf(group->name, sizeof(group->name), "ctrl-id-%d-%u",
+ getpid(), index);
+ if (len < 0 || len >= sizeof(group->name))
+ return -ENAMETOOLONG;
+
+ len = snprintf(path, sizeof(path), "%s/%s", RESCTRL_PATH,
+ group->name);
+ if (len < 0 || len >= sizeof(path))
+ return -ENAMETOOLONG;
+
+ if (mkdir(path, 0755))
+ return -errno;
+
+ group->created = true;
+ return 0;
+}
+
+static int ctrl_id_remove_group(unsigned int index)
+{
+ struct ctrl_id_group *group = &ctrl_id_ctx.groups[index];
+ char path[PATH_MAX];
+ int len;
+
+ if (!group->created)
+ return 0;
+
+ len = snprintf(path, sizeof(path), "%s/%s", RESCTRL_PATH,
+ group->name);
+ if (len < 0 || len >= sizeof(path))
+ return -ENAMETOOLONG;
+
+ if (rmdir(path))
+ return -errno;
+
+ group->created = false;
+ return 0;
+}
+
+static void ctrl_id_cleanup(void)
+{
+ int i;
+
+ if (ctrl_id_ctx.root_changed) {
+ ctrl_id_write_policy(NULL, ctrl_id_ctx.root_value);
+ ctrl_id_ctx.root_changed = false;
+ }
+
+ for (i = CTRL_ID_MAX_GROUPS - 1; i >= 0; i--)
+ ctrl_id_remove_group(i);
+
+ memset(&ctrl_id_ctx, 0, sizeof(ctrl_id_ctx));
+}
+
+static int ctrl_id_changed_policy(const char *original, char *changed,
+ size_t size)
+{
+ unsigned int min_bits;
+ unsigned long candidate;
+ unsigned long mask;
+ unsigned int first;
+ char *end;
+ int len;
+
+ if (resource_info_unsigned_get(ctrl_id_ctx.resource, "min_cbm_bits",
+ &min_bits))
+ return -ENOENT;
+
+ errno = 0;
+ mask = strtoul(original, &end, 16);
+ if (errno || *end || !mask)
+ return -EINVAL;
+
+ first = __builtin_ctzl(mask);
+ if (min_bits >= sizeof(mask) * 8 - first)
+ return -ERANGE;
+
+ candidate = ((1UL << min_bits) - 1) << first;
+ if (candidate == mask || (candidate & mask) != candidate)
+ return -ERANGE;
+
+ len = snprintf(changed, size, "%lx", candidate);
+ if (len < 0 || (size_t)len >= size)
+ return -ENAMETOOLONG;
+
+ return 0;
+}
+
+static bool ctrl_id_feature_check(const struct resctrl_test *test)
+{
+ unsigned int num_closids;
+
+ if (!resctrl_resource_exists(test->resource))
+ return false;
+
+ if (resource_info_unsigned_get(test->resource, "num_closids",
+ &num_closids))
+ return false;
+
+ return num_closids >= 3;
+}
+
+static int ctrl_id_run_test(const struct resctrl_test *test,
+ const struct user_params *uparams)
+{
+ char changed[CTRL_ID_VALUE_LEN];
+ char current[CTRL_ID_VALUE_LEN];
+ unsigned int num_closids;
+ unsigned int group_count;
+ unsigned int pending = 0;
+ bool local_mapping;
+ int ret;
+ unsigned int i;
+
+ memset(&ctrl_id_ctx, 0, sizeof(ctrl_id_ctx));
+ ctrl_id_ctx.resource = test->resource;
+
+ ret = get_domain_id(test->resource, uparams->cpu,
+ &ctrl_id_ctx.domain_id);
+ if (ret)
+ return ret;
+
+ ret = resource_info_unsigned_get(test->resource, "num_closids",
+ &num_closids);
+ if (ret)
+ return ret;
+
+ ret = ctrl_id_read_policy(NULL, ctrl_id_ctx.root_value,
+ sizeof(ctrl_id_ctx.root_value));
+ if (ret)
+ return ret;
+
+ group_count = num_closids - 1;
+ if (group_count > CTRL_ID_MAX_GROUPS)
+ group_count = CTRL_ID_MAX_GROUPS;
+
+ for (i = 0; i < group_count; i++) {
+ ret = ctrl_id_create_group(i);
+ if (ret == -ENOSPC && i >= 2) {
+ group_count = i;
+ break;
+ }
+ if (ret)
+ return ret;
+ ret = ctrl_id_read_policy(ctrl_id_ctx.groups[i].name, current,
+ sizeof(current));
+ if (ret || strcmp(current, ctrl_id_ctx.root_value))
+ return ret ?: -EINVAL;
+ }
+
+ ret = ctrl_id_write_policy(ctrl_id_ctx.groups[0].name,
+ ctrl_id_ctx.root_value);
+ if (ret)
+ return ret;
+
+ ret = ctrl_id_changed_policy(ctrl_id_ctx.root_value, changed,
+ sizeof(changed));
+ if (ret)
+ return ret;
+
+ ctrl_id_ctx.root_changed = true;
+ ret = ctrl_id_write_policy(NULL, changed);
+ if (ret)
+ return ret;
+
+ ret = ctrl_id_read_policy(ctrl_id_ctx.groups[0].name, current,
+ sizeof(current));
+ if (ret || strcmp(current, ctrl_id_ctx.root_value))
+ return ret ?: -EINVAL;
+
+ ret = ctrl_id_read_policy(ctrl_id_ctx.groups[1].name, current,
+ sizeof(current));
+ if (ret)
+ return ret;
+ if (!strcmp(current, changed))
+ local_mapping = true;
+ else if (!strcmp(current, ctrl_id_ctx.root_value))
+ local_mapping = false;
+ else
+ return -EINVAL;
+ ksft_print_msg("Detected %s control ID mode\n",
+ local_mapping ? "controller-local" : "identity");
+
+ ret = ctrl_id_write_policy(NULL, ctrl_id_ctx.root_value);
+ if (ret)
+ return ret;
+ ctrl_id_ctx.root_changed = false;
+
+ if (!local_mapping) {
+ ret = ctrl_id_write_policy(ctrl_id_ctx.groups[0].name,
+ changed);
+ if (ret)
+ return ret;
+ ret = ctrl_id_remove_group(0);
+ if (ret)
+ return ret;
+ ret = ctrl_id_create_group(0);
+ if (ret)
+ return ret;
+ ret = ctrl_id_read_policy(ctrl_id_ctx.groups[0].name,
+ current, sizeof(current));
+ if (ret)
+ return ret;
+ return strcmp(current, ctrl_id_ctx.root_value) ? -EINVAL : 0;
+ }
+
+ for (i = 1; i < group_count; i++) {
+ ret = ctrl_id_write_policy(ctrl_id_ctx.groups[i].name,
+ ctrl_id_ctx.root_value);
+ if (ret == -ENOSPC) {
+ pending = i;
+ break;
+ }
+ if (ret)
+ return ret;
+ }
+
+ if (!pending) {
+ ksft_print_msg("Physical control entry exhaustion was not reached\n");
+ return 0;
+ }
+ ksft_print_msg("Physical entry exhaustion reached at test group %u\n",
+ pending);
+
+ ret = ctrl_id_remove_group(0);
+ if (ret)
+ return ret;
+
+ ret = ctrl_id_write_policy(ctrl_id_ctx.groups[pending].name,
+ ctrl_id_ctx.root_value);
+ if (ret)
+ return ret;
+ ksft_print_msg("Released entry reused by test group %u\n", pending);
+
+ return 0;
+}
+
+struct resctrl_test ctrl_id_test = {
+ .name = "CTRL_ID",
+ .group = "CTRL_ID",
+ .resource = "L3",
+ .feature_check = ctrl_id_feature_check,
+ .run_test = ctrl_id_run_test,
+ .cleanup = ctrl_id_cleanup,
+};
diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
index a7556cdae0de3..6b727b080e0b8 100644
--- a/tools/testing/selftests/resctrl/resctrl.h
+++ b/tools/testing/selftests/resctrl/resctrl.h
@@ -244,5 +244,6 @@ extern struct resctrl_test cmt_test;
extern struct resctrl_test l3_cat_test;
extern struct resctrl_test l3_noncont_cat_test;
extern struct resctrl_test l2_noncont_cat_test;
+extern struct resctrl_test ctrl_id_test;
#endif /* RESCTRL_H */
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
index dbcd5eea9fbc9..c706912b5ae3d 100644
--- a/tools/testing/selftests/resctrl/resctrl_tests.c
+++ b/tools/testing/selftests/resctrl/resctrl_tests.c
@@ -21,6 +21,7 @@ static struct resctrl_test *resctrl_tests[] = {
&l3_cat_test,
&l3_noncont_cat_test,
&l2_noncont_cat_test,
+ &ctrl_id_test,
};
static unsigned int detect_vendor(void)
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFC PATCH 13/13] docs/resctrl: Document logical control IDs and hardware entries
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (11 preceding siblings ...)
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 ` Yunhui Cui
2026-11-30 6:15 ` [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Jinjie Ruan
13 siblings, 0 replies; 18+ messages in thread
From: Yunhui Cui @ 2026-11-30 2:29 UTC (permalink / raw)
To: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Cc: Yunhui Cui
Document how logical control IDs map to controller-local hardware entries.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
Documentation/filesystems/resctrl.rst | 88 +++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
index 2750f2eabf70e..64c207d17e214 100644
--- a/Documentation/filesystems/resctrl.rst
+++ b/Documentation/filesystems/resctrl.rst
@@ -541,6 +541,94 @@ conveyed in the error returns from file operations. E.g.
# cat info/last_cmd_status
mask f7 has non-consecutive 1-bits
+Logical control IDs and hardware entries
+========================================
+
+With direct indexing, a control group's CLOSID also selects its hardware
+allocation entry. The smallest controller table therefore limits the number
+of groups, even when most groups only need a private policy on another
+resource.
+
+Controllers with request-ID mapping can accept more identifiers than they
+have hardware entries. Separating the logical control ID from these entries
+allows one group to have a private policy in one mapping table while sharing
+the root policy in another. Each independent mapping table allocates its
+entries separately::
+
+ generic resctrl
+ logical control ID
+ |
+ +------------------+------------------+
+ | | |
+ x86 arm64 MPAM RISC-V CBQRI
+ direct index MSC mapping mapping (proposed)
+ | | |
+ hardware entry internal PARTID controller entry
+
+Direct-index controllers retain their existing behavior. For MPAM, all RIS
+in an MSC share one PARTID mapping table. A component uses narrowing only if
+every MSC serving it supports PARTID narrowing. Components that
+share an MSC cannot mix narrowing and direct indexing; if one requires direct
+indexing, all components connected to that MSC retain direct indexing and its
+safe limits. The proposed CBQRI mapping extension can use the same model, but
+its RISC-V backend is outside this patchset.
+
+The logical ID range remains bounded by the identifiers that all requesters
+and controllers can accept. ``num_closids`` does not guarantee enough
+hardware entries for every group to have a private policy in every mapping
+table.
+
+Group policy lifetime
+---------------------
+
+Creating a group assigns a logical control ID but does not allocate private
+entries in mapped controllers. Until a policy using a mapping table is
+written, the group's requests use that table's root entry and follow the root
+policy.
+
+The first policy written for a mapped controller allocates a private entry in
+its mapping table, even if the policy equals the root policy. resctrl
+initializes the entry for every controller sharing that table, then maps the
+logical control ID to it. The configured controller receives the group's
+policy; the others are initialized from their corresponding root policies.
+Controllers backed by other mapping tables continue using their root entries.
+
+For example, if controllers A and B use independent mapping tables, ``g1`` may
+configure only A while ``g2`` configures only B. A maps ``g1`` to a private
+entry and ``g2`` to its root entry; B maps ``g2`` to a private entry and
+``g1`` to its root entry. A therefore needs entries only for the root group
+and ``g1``, while B needs entries only for the root group and ``g2``.
+
+This arrangement requires hardware support for controller-local request-ID
+mapping. Without it, a request ID directly selects the same-numbered entry in
+A and B, so ``g1`` cannot select its private entry in A and B's root entry,
+nor can ``g2`` make the opposite selection. Both groups then require private
+entries in both controllers.
+
+Direct-index controllers retain their existing group initialization; later
+root updates do not change those groups' policies. A mapped controller that
+shares a newly allocated entry with a configured controller also stops
+following later root updates because both use the same mapping table.
+
+If an entry is unavailable, the write returns ``ENOSPC``. The group keeps its
+logical ID, and the write can be retried after another group releases an
+entry. Exhausting logical IDs instead causes group creation to fail.
+
+Mappings are published only after their entries have been configured. Tasks
+and CPUs return to the default group before entries are retired and logical
+IDs become reusable. A failed removal retains the group and ID for retry;
+entries whose state cannot be recovered must remain unavailable.
+
+CDP uses separate request PARTIDs and default entries for data and code. An
+explicitly configured data or code policy consumes its own entry on a mapped
+controller. Monitoring ID limits are unchanged; RMID exhaustion can also
+prevent group creation.
+
+Updates across controllers are not globally atomic. In-place updates to
+existing entries do not guarantee rollback of all controls on a hardware
+failure.
+
+
Resource alloc and monitor groups
=================================
--
2.39.2 (Apple Git-143)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs
2026-11-30 2:29 [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Yunhui Cui
` (12 preceding siblings ...)
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 ` Jinjie Ruan
2026-11-30 6:56 ` [External] " yunhui cui
2026-11-30 11:22 ` Ben Horgan
13 siblings, 2 replies; 18+ messages in thread
From: Jinjie Ruan @ 2026-11-30 6:15 UTC (permalink / raw)
To: Yunhui Cui, tony.luck, reinette.chatre, ben.horgan, Dave.Martin,
james.morse, babu.moger, fustini, tglx, mingo, bp, dave.hansen,
hpa, fenghuay, shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
在 2026/11/30 10:29, Yunhui Cui 写道:
> Some resource controllers can accept a wider request-ID namespace than
> the number of configuration entries they provide. Arm MPAM PARTID
> narrowing is one example: requests carry a PARTID, while an MSC maps it
> to a smaller internal PARTID table. A future RISC-V CBQRI backend is
We have been working on narrow partid for a long time. Could you please
drop the patches related to MPAM narrow partid?
Link:
https://lore.kernel.org/all/20261020134239.3921377-1-ruanjinjie@huawei.com/
> expected to need a similar mapping from request RCIDs to controller-local
> entries. Resctrl currently uses one ID both to identify a control group
> and to select its hardware entry, so the smallest table limits the number
> of groups exposed to user space.
>
> The framework uses a logical control ID in generic resctrl while each
> architecture selects a hardware entry according to its own model:
>
> generic resctrl
> logical control ID
> |
> +------------------+------------------+
> | | |
> x86 arm64 MPAM RISC-V CBQRI
> direct index MSC mapping mapping (proposed)
> | | |
> hardware entry internal PARTID controller entry
>
> Without controller-local request-ID mapping, the same request ID directly
> indexes every controller. If g1 configures only A and g2 only B, g1
> cannot select its private entry in A and B's root entry while g2 makes
> the opposite selection. Each group therefore consumes an entry in both
> controllers. Controller-local mapping makes these selections independent,
> so A needs entries only for the root group and g1 while B needs only the
> root group and g2.
>
> This series gives control groups logical IDs. A new group initially
> selects the root policy and consumes no private entry on a narrowing
> controller. Its first explicit policy write allocates and programs an
> entry only on the affected controllers, then publishes the
> request-to-internal ID mapping. Controllers that have not been configured
> continue to follow the root policy. A same-value write still creates a
> private policy, so a later root update does not change it.
>
> Entry reservation is completed before a multi-controller policy update
> and mapping changes are published only after the entries are programmed.
> Group removal maps requests back to the root entry before an internal
> entry or logical ID can be reused. CDP keeps separate data and code root
> entries so the default policies remain distinct.
>
> Identity-mapped architectures retain their current behavior, and I/O
> allocation continues to address a hardware entry directly. The generic
> framework supports both direct-index and mapped controllers. The RISC-V
> backend itself is outside this series.
>
> Base: next-20261127
>
> Yunhui Cui (13):
> resctrl: Introduce interfaces for logical control IDs
> resctrl: Add prepare, commit and abort hooks for control updates
> resctrl: Add a release hook before logical control ID reuse
> arm_mpam: Record PARTID narrowing capacity per MSC
> arm_mpam: Select PARTID narrowing per component
> arm_mpam: Add an internal PARTID allocator
> arm_mpam: Add request-to-internal PARTID mapping
> arm_mpam: Apply PARTID narrowing to resctrl control groups
> arm_mpam: Separate request and internal PARTID limits
> arm_mpam: Map CDP data and code defaults separately
> arm_mpam: Add kunit tests for PARTID narrowing
> selftests/resctrl: Add a test for control ID allocation and reuse
> docs/resctrl: Document logical control IDs and hardware entries
>
> Documentation/filesystems/resctrl.rst | 88 ++
> arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 38 +-
> drivers/resctrl/mpam_devices.c | 857 +++++++++++++++++-
> drivers/resctrl/mpam_internal.h | 25 +-
> drivers/resctrl/mpam_resctrl.c | 288 +++++-
> drivers/resctrl/test_mpam_devices.c | 619 ++++++++++++-
> drivers/resctrl/test_mpam_resctrl.c | 172 ++++
> fs/resctrl/ctrlmondata.c | 28 +-
> fs/resctrl/rdtgroup.c | 18 +-
> include/linux/resctrl.h | 17 +-
> .../testing/selftests/resctrl/ctrl_id_test.c | 380 ++++++++
> tools/testing/selftests/resctrl/resctrl.h | 1 +
> .../testing/selftests/resctrl/resctrl_tests.c | 1 +
> 13 files changed, 2470 insertions(+), 62 deletions(-)
> create mode 100644 tools/testing/selftests/resctrl/ctrl_id_test.c
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [External] Re: [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs
2026-11-30 6:15 ` [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs Jinjie Ruan
@ 2026-11-30 6:56 ` yunhui cui
2026-11-30 7:29 ` Jinjie Ruan
2026-11-30 11:22 ` Ben Horgan
1 sibling, 1 reply; 18+ messages in thread
From: yunhui cui @ 2026-11-30 6:56 UTC (permalink / raw)
To: Jinjie Ruan
Cc: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Hi Jinjie,
On Mon, Nov 30, 2026 at 2:15 PM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>
>
>
> 在 2026/11/30 10:29, Yunhui Cui 写道:
> > Some resource controllers can accept a wider request-ID namespace than
> > the number of configuration entries they provide. Arm MPAM PARTID
> > narrowing is one example: requests carry a PARTID, while an MSC maps it
> > to a smaller internal PARTID table. A future RISC-V CBQRI backend is
>
> We have been working on narrow partid for a long time. Could you please
> drop the patches related to MPAM narrow partid?
>
> Link:
> https://lore.kernel.org/all/20261020134239.3921377-1-ruanjinjie@huawei.com/
Thanks for pointing me to the v10 series.
This RFC focuses on the generic resctrl logical-control-ID framework.
It is not intended to modify or extend MPAM's Narrow-PARTID
functionality itself.
The idea is for generic resctrl to provide a common lifecycle, with
each architecture backend integrating according to its hardware model:
x86 retains its direct-index behavior, MPAM implements the
mapped-controller interfaces, and a future RISC-V CBQRI backend can
use the same framework.
The current series is based on next-20261127, which does not include
the v10 patches, so the MPAM backend changes are implemented against
the current code. In a subsequent revision, even if v10 has not been
merged, I can use it as the base for the MPAM part and rebase this
series on top of it.
Thanks,
Yunhui
>
>
> > expected to need a similar mapping from request RCIDs to controller-local
> > entries. Resctrl currently uses one ID both to identify a control group
> > and to select its hardware entry, so the smallest table limits the number
> > of groups exposed to user space.
> >
> > The framework uses a logical control ID in generic resctrl while each
> > architecture selects a hardware entry according to its own model:
> >
> > generic resctrl
> > logical control ID
> > |
> > +------------------+------------------+
> > | | |
> > x86 arm64 MPAM RISC-V CBQRI
> > direct index MSC mapping mapping (proposed)
> > | | |
> > hardware entry internal PARTID controller entry
> >
> > Without controller-local request-ID mapping, the same request ID directly
> > indexes every controller. If g1 configures only A and g2 only B, g1
> > cannot select its private entry in A and B's root entry while g2 makes
> > the opposite selection. Each group therefore consumes an entry in both
> > controllers. Controller-local mapping makes these selections independent,
> > so A needs entries only for the root group and g1 while B needs only the
> > root group and g2.
> >
> > This series gives control groups logical IDs. A new group initially
> > selects the root policy and consumes no private entry on a narrowing
> > controller. Its first explicit policy write allocates and programs an
> > entry only on the affected controllers, then publishes the
> > request-to-internal ID mapping. Controllers that have not been configured
> > continue to follow the root policy. A same-value write still creates a
> > private policy, so a later root update does not change it.
> >
> > Entry reservation is completed before a multi-controller policy update
> > and mapping changes are published only after the entries are programmed.
> > Group removal maps requests back to the root entry before an internal
> > entry or logical ID can be reused. CDP keeps separate data and code root
> > entries so the default policies remain distinct.
> >
> > Identity-mapped architectures retain their current behavior, and I/O
> > allocation continues to address a hardware entry directly. The generic
> > framework supports both direct-index and mapped controllers. The RISC-V
> > backend itself is outside this series.
> >
> > Base: next-20261127
> >
> > Yunhui Cui (13):
> > resctrl: Introduce interfaces for logical control IDs
> > resctrl: Add prepare, commit and abort hooks for control updates
> > resctrl: Add a release hook before logical control ID reuse
> > arm_mpam: Record PARTID narrowing capacity per MSC
> > arm_mpam: Select PARTID narrowing per component
> > arm_mpam: Add an internal PARTID allocator
> > arm_mpam: Add request-to-internal PARTID mapping
> > arm_mpam: Apply PARTID narrowing to resctrl control groups
> > arm_mpam: Separate request and internal PARTID limits
> > arm_mpam: Map CDP data and code defaults separately
> > arm_mpam: Add kunit tests for PARTID narrowing
> > selftests/resctrl: Add a test for control ID allocation and reuse
> > docs/resctrl: Document logical control IDs and hardware entries
> >
> > Documentation/filesystems/resctrl.rst | 88 ++
> > arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 38 +-
> > drivers/resctrl/mpam_devices.c | 857 +++++++++++++++++-
> > drivers/resctrl/mpam_internal.h | 25 +-
> > drivers/resctrl/mpam_resctrl.c | 288 +++++-
> > drivers/resctrl/test_mpam_devices.c | 619 ++++++++++++-
> > drivers/resctrl/test_mpam_resctrl.c | 172 ++++
> > fs/resctrl/ctrlmondata.c | 28 +-
> > fs/resctrl/rdtgroup.c | 18 +-
> > include/linux/resctrl.h | 17 +-
> > .../testing/selftests/resctrl/ctrl_id_test.c | 380 ++++++++
> > tools/testing/selftests/resctrl/resctrl.h | 1 +
> > .../testing/selftests/resctrl/resctrl_tests.c | 1 +
> > 13 files changed, 2470 insertions(+), 62 deletions(-)
> > create mode 100644 tools/testing/selftests/resctrl/ctrl_id_test.c
> >
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [External] Re: [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs
2026-11-30 6:56 ` [External] " yunhui cui
@ 2026-11-30 7:29 ` Jinjie Ruan
0 siblings, 0 replies; 18+ messages in thread
From: Jinjie Ruan @ 2026-11-30 7:29 UTC (permalink / raw)
To: yunhui cui
Cc: tony.luck, reinette.chatre, ben.horgan, Dave.Martin, james.morse,
babu.moger, fustini, tglx, mingo, bp, dave.hansen, hpa, fenghuay,
shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
在 2026/11/30 14:56, yunhui cui 写道:
> Hi Jinjie,
>
> On Mon, Nov 30, 2026 at 2:15 PM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>>
>>
>>
>> 在 2026/11/30 10:29, Yunhui Cui 写道:
>>> Some resource controllers can accept a wider request-ID namespace than
>>> the number of configuration entries they provide. Arm MPAM PARTID
>>> narrowing is one example: requests carry a PARTID, while an MSC maps it
>>> to a smaller internal PARTID table. A future RISC-V CBQRI backend is
>>
>> We have been working on narrow partid for a long time. Could you please
>> drop the patches related to MPAM narrow partid?
>>
>> Link:
>> https://lore.kernel.org/all/20261020134239.3921377-1-ruanjinjie@huawei.com/
>
> Thanks for pointing me to the v10 series.
>
> This RFC focuses on the generic resctrl logical-control-ID framework.
> It is not intended to modify or extend MPAM's Narrow-PARTID
> functionality itself.
>
> The idea is for generic resctrl to provide a common lifecycle, with
> each architecture backend integrating according to its hardware model:
> x86 retains its direct-index behavior, MPAM implements the
> mapped-controller interfaces, and a future RISC-V CBQRI backend can
> use the same framework.
Hi Yunhui,
Don't you think it is too early to provide a framework now?
Currently, the narrow partid on the mpam side cannot work properly on
the mainline, and RISC-V seems to have only just started providing
support. There are some suggestions from James on v8, where he
recommends implementing the simplest static narrow partid first.
Should we follow James's suggestion in v8 and ensure that these features
work properly across different architectures before considering the
framework?
v8:
https://lore.kernel.org/all/20260413085405.1166412-1-zengheng4@huawei.com/
https://lore.kernel.org/all/88c6c8cd-5da7-4c28-8d5c-7d6489e5913f@picoheart.com/
>
> The current series is based on next-20261127, which does not include
> the v10 patches, so the MPAM backend changes are implemented against
> the current code. In a subsequent revision, even if v10 has not been
> merged, I can use it as the base for the MPAM part and rebase this
> series on top of it.
>
> Thanks,
> Yunhui
>
>>
>>
>>> expected to need a similar mapping from request RCIDs to controller-local
>>> entries. Resctrl currently uses one ID both to identify a control group
>>> and to select its hardware entry, so the smallest table limits the number
>>> of groups exposed to user space.
>>>
>>> The framework uses a logical control ID in generic resctrl while each
>>> architecture selects a hardware entry according to its own model:
>>>
>>> generic resctrl
>>> logical control ID
>>> |
>>> +------------------+------------------+
>>> | | |
>>> x86 arm64 MPAM RISC-V CBQRI
>>> direct index MSC mapping mapping (proposed)
>>> | | |
>>> hardware entry internal PARTID controller entry
>>>
>>> Without controller-local request-ID mapping, the same request ID directly
>>> indexes every controller. If g1 configures only A and g2 only B, g1
>>> cannot select its private entry in A and B's root entry while g2 makes
>>> the opposite selection. Each group therefore consumes an entry in both
>>> controllers. Controller-local mapping makes these selections independent,
>>> so A needs entries only for the root group and g1 while B needs only the
>>> root group and g2.
>>>
>>> This series gives control groups logical IDs. A new group initially
>>> selects the root policy and consumes no private entry on a narrowing
>>> controller. Its first explicit policy write allocates and programs an
>>> entry only on the affected controllers, then publishes the
>>> request-to-internal ID mapping. Controllers that have not been configured
>>> continue to follow the root policy. A same-value write still creates a
>>> private policy, so a later root update does not change it.
>>>
>>> Entry reservation is completed before a multi-controller policy update
>>> and mapping changes are published only after the entries are programmed.
>>> Group removal maps requests back to the root entry before an internal
>>> entry or logical ID can be reused. CDP keeps separate data and code root
>>> entries so the default policies remain distinct.
>>>
>>> Identity-mapped architectures retain their current behavior, and I/O
>>> allocation continues to address a hardware entry directly. The generic
>>> framework supports both direct-index and mapped controllers. The RISC-V
>>> backend itself is outside this series.
>>>
>>> Base: next-20261127
>>>
>>> Yunhui Cui (13):
>>> resctrl: Introduce interfaces for logical control IDs
>>> resctrl: Add prepare, commit and abort hooks for control updates
>>> resctrl: Add a release hook before logical control ID reuse
>>> arm_mpam: Record PARTID narrowing capacity per MSC
>>> arm_mpam: Select PARTID narrowing per component
>>> arm_mpam: Add an internal PARTID allocator
>>> arm_mpam: Add request-to-internal PARTID mapping
>>> arm_mpam: Apply PARTID narrowing to resctrl control groups
>>> arm_mpam: Separate request and internal PARTID limits
>>> arm_mpam: Map CDP data and code defaults separately
>>> arm_mpam: Add kunit tests for PARTID narrowing
>>> selftests/resctrl: Add a test for control ID allocation and reuse
>>> docs/resctrl: Document logical control IDs and hardware entries
>>>
>>> Documentation/filesystems/resctrl.rst | 88 ++
>>> arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 38 +-
>>> drivers/resctrl/mpam_devices.c | 857 +++++++++++++++++-
>>> drivers/resctrl/mpam_internal.h | 25 +-
>>> drivers/resctrl/mpam_resctrl.c | 288 +++++-
>>> drivers/resctrl/test_mpam_devices.c | 619 ++++++++++++-
>>> drivers/resctrl/test_mpam_resctrl.c | 172 ++++
>>> fs/resctrl/ctrlmondata.c | 28 +-
>>> fs/resctrl/rdtgroup.c | 18 +-
>>> include/linux/resctrl.h | 17 +-
>>> .../testing/selftests/resctrl/ctrl_id_test.c | 380 ++++++++
>>> tools/testing/selftests/resctrl/resctrl.h | 1 +
>>> .../testing/selftests/resctrl/resctrl_tests.c | 1 +
>>> 13 files changed, 2470 insertions(+), 62 deletions(-)
>>> create mode 100644 tools/testing/selftests/resctrl/ctrl_id_test.c
>>>
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFC PATCH 00/13] resctrl: Introduce a framework for logical control IDs
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 11:22 ` Ben Horgan
1 sibling, 0 replies; 18+ messages in thread
From: Ben Horgan @ 2026-11-30 11:22 UTC (permalink / raw)
To: Jinjie Ruan, Yunhui Cui, tony.luck, reinette.chatre, Dave.Martin,
james.morse, babu.moger, fustini, tglx, mingo, bp, dave.hansen,
hpa, fenghuay, shuah, corbet, skhan, rdunlap, x86, linux-kernel,
linux-arm-kernel, linux-riscv, linux-kselftest, kunit-dev,
linux-doc
Hi Jinjie, Yunhui,
On 30/11/2026 06:15, Jinjie Ruan wrote:
>
>
> 在 2026/11/30 10:29, Yunhui Cui 写道:
>> Some resource controllers can accept a wider request-ID namespace than
>> the number of configuration entries they provide. Arm MPAM PARTID
>> narrowing is one example: requests carry a PARTID, while an MSC maps it
>> to a smaller internal PARTID table. A future RISC-V CBQRI backend is
>
> We have been working on narrow partid for a long time. Could you please
> drop the patches related to MPAM narrow partid?
> > Link:
> https://lore.kernel.org/all/20261020134239.3921377-1-ruanjinjie@huawei.com/
As I see it, there are 3 different options for the use of PARTID narrowing:
Static mapping.
A static MPAM PARTID narrowing mapping. Jinjie's existing PARTID narrowing series [1], is the latest
posting on this. This is an internal mechanism to the MPAM driver to provide more RMIDs to resctrl.
The MPAM driver uses (reqPARTID, PMG) for RMID and intPARTID for CLOSID. This works, without
altering the user interface, resctrl itself or the interface between resctrl and the MPAM driver.
James also has a prototype branch [2] which has some known problems but demonstrates that only the
MPAM driver needs to change.
At components without PARTID narrowing non-aliasing controls have to be hidden, e.g. any MIN or MAX
controls. The number of controls needs to be sanitized to the smallest number of intPARTID in any MSC.
The static mapping is useful for existing systems without many PMG in hardware and that don't have
important non-aliasing controls on the MSC without PARTID narrowing. If monitors just match on PMG
rather than (PARTID, PMG) as will mostly be the case in MPAMv2 then the static mapping doesn't give
us anything over the default MPAM driver policy of a 1-1 static mapping.
Dynamic mapping.
A dynamic MPAM PARTID narrowing mapping. Again the MPAM driver uses (reqPARTID, PMG) for RMID and
intPARTID for CLOSID but it changes the mapping at monitor group creation to allow more flexible
placement of monitor groups.
This was prototyped here [3]. Similar to the static mapping in that it provides PMG constrained
MPAMv1 systems a way of having more monitor groups. resctrl would need to have an arch hook to call
into the architecture on monitor group creating so that the MPAM driver can create the mapping.
Similar to the static mapping, the non-aliasing controls at MSC without narrowing must be hidden,
the same intPARTID sanitization is needed and is only relevant for MPAMv1.
User-controlled mapping.
The MPAM driver uses reqPARTID for CLOSID and lets resctrl control the mapping.
To make full use of MPAM PARTID narrowing the mapping of the request control ID (reqPARTID) to the
internal control configuration (intPARTID) would need to be made visible to the user. For each
resctrl resource (L2, L3, MB, MB_NODE)* there could be a set of internal configuration, e.g. for L2:
red, green, yellow and for L3: owl, robin, nightingale and for MB_NODE: wolf, dog, fox... The
internal configuration would determine the actual hardware values, e.g. red could be the cache
bitmap L2=0xff00. And in the schemata file you would specify the internal configurations, e.g.
L2:0=red;1=blue
L3:0=owl;1=nightingale
MB_NODE:32=wolf;64=fox
*L3 and MB will need the same mapping if they are backed by the same MPAM class.
With a user-controlled mapping there is no need to sanitize to the smallest number of intPARTID as
each resource/mpam component can have a separate mapping. This allows having a heteregeneous number
of controls at different points int the system. Non-aliasing controls, on MSC without PARTID
narrowing, don't need to be hidden.
The user-controlled mapping still makes sense when RMID is not scoped to CLOSID and so the only one
of these proposals than is potentially useful across architectures. It is however a big change to
the resctrl interface and would need some good justification.
From an MPAM driver point of view the static mapping makes sense to concentrate on first. Any
changes here can be fully within the MPAM driver. After this we can consider whether a dynamic
mapping would be useful or if a user-controlled option supersedes this. The MPAM policy for when we
make use of the static mapping and if we need any flags will need to be carefully considered so that
we don't make future options harder.
Yunhui, does your series fall into one of these categories? I haven't looked in any detail but it
looks to me to be a constrained version of the user controlled mapping. What's are the motivating
usecases for this series?
[1] https://lore.kernel.org/all/20261020134239.3921377-1-ruanjinjie@huawei.com/
(Same link as in Jinjie's message)
[2] https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/log/?h=mpam/narrowing/v0
[3] https://lore.kernel.org/all/20260413085405.1166412-1-zengheng4@huawei.com/
Thanks,
Ben
>
>
>> expected to need a similar mapping from request RCIDs to controller-local
>> entries. Resctrl currently uses one ID both to identify a control group
>> and to select its hardware entry, so the smallest table limits the number
>> of groups exposed to user space.
>>
>> The framework uses a logical control ID in generic resctrl while each
>> architecture selects a hardware entry according to its own model:
>>
>> generic resctrl
>> logical control ID
>> |
>> +------------------+------------------+
>> | | |
>> x86 arm64 MPAM RISC-V CBQRI
>> direct index MSC mapping mapping (proposed)
>> | | |
>> hardware entry internal PARTID controller entry
>>
>> Without controller-local request-ID mapping, the same request ID directly
>> indexes every controller. If g1 configures only A and g2 only B, g1
>> cannot select its private entry in A and B's root entry while g2 makes
>> the opposite selection. Each group therefore consumes an entry in both
>> controllers. Controller-local mapping makes these selections independent,
>> so A needs entries only for the root group and g1 while B needs only the
>> root group and g2.
>>
>> This series gives control groups logical IDs. A new group initially
>> selects the root policy and consumes no private entry on a narrowing
>> controller. Its first explicit policy write allocates and programs an
>> entry only on the affected controllers, then publishes the
>> request-to-internal ID mapping. Controllers that have not been configured
>> continue to follow the root policy. A same-value write still creates a
>> private policy, so a later root update does not change it.
>>
>> Entry reservation is completed before a multi-controller policy update
>> and mapping changes are published only after the entries are programmed.
>> Group removal maps requests back to the root entry before an internal
>> entry or logical ID can be reused. CDP keeps separate data and code root
>> entries so the default policies remain distinct.
>>
>> Identity-mapped architectures retain their current behavior, and I/O
>> allocation continues to address a hardware entry directly. The generic
>> framework supports both direct-index and mapped controllers. The RISC-V
>> backend itself is outside this series.
>>
>> Base: next-20261127
>>
>> Yunhui Cui (13):
>> resctrl: Introduce interfaces for logical control IDs
>> resctrl: Add prepare, commit and abort hooks for control updates
>> resctrl: Add a release hook before logical control ID reuse
>> arm_mpam: Record PARTID narrowing capacity per MSC
>> arm_mpam: Select PARTID narrowing per component
>> arm_mpam: Add an internal PARTID allocator
>> arm_mpam: Add request-to-internal PARTID mapping
>> arm_mpam: Apply PARTID narrowing to resctrl control groups
>> arm_mpam: Separate request and internal PARTID limits
>> arm_mpam: Map CDP data and code defaults separately
>> arm_mpam: Add kunit tests for PARTID narrowing
>> selftests/resctrl: Add a test for control ID allocation and reuse
>> docs/resctrl: Document logical control IDs and hardware entries
>>
>> Documentation/filesystems/resctrl.rst | 88 ++
>> arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 38 +-
>> drivers/resctrl/mpam_devices.c | 857 +++++++++++++++++-
>> drivers/resctrl/mpam_internal.h | 25 +-
>> drivers/resctrl/mpam_resctrl.c | 288 +++++-
>> drivers/resctrl/test_mpam_devices.c | 619 ++++++++++++-
>> drivers/resctrl/test_mpam_resctrl.c | 172 ++++
>> fs/resctrl/ctrlmondata.c | 28 +-
>> fs/resctrl/rdtgroup.c | 18 +-
>> include/linux/resctrl.h | 17 +-
>> .../testing/selftests/resctrl/ctrl_id_test.c | 380 ++++++++
>> tools/testing/selftests/resctrl/resctrl.h | 1 +
>> .../testing/selftests/resctrl/resctrl_tests.c | 1 +
>> 13 files changed, 2470 insertions(+), 62 deletions(-)
>> create mode 100644 tools/testing/selftests/resctrl/ctrl_id_test.c
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2026-11-30 11:22 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [RFC PATCH 05/13] arm_mpam: Select PARTID narrowing per component Yunhui Cui
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox