[PATCH v7 12/19] fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup
From: Babu Moger
Date: Wed Nov 11 2026 - 17:55:21 EST
The RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode allows CPUs to use different
CLOSID and/or RMID associations when transitioning from user mode to kernel
mode. When active, it is enabled or disabled on a per-CPU basis through a
backing resource group.
Add kmode_cpus and kmode_cpus_list to display the CPUs in a resource group
backing the active kernel mode.
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v7: Changelog updated with consistant terms.
Code comment update.
v6: Drop rdtgrp::kmode. Rewrite changelog (not a bugfix; association).
https://lore.kernel.org/lkml/ef8804d5-f20c-49a1-87cf-ab39437a5f0d@xxxxxxxxx/
v5: Updated the changelog.
Removed the RDT_MODE_PSEUDO_LOCKED check and added rdtgroup->kmode check.
Files are created hidden.
v4: Rewrote the change to be generic.
v3: New patch to add "kmode_cpus" and "kmode_cpus_list" to support
kernel_modes.
---
fs/resctrl/internal.h | 3 +++
fs/resctrl/rdtgroup.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index 909511e985a1..a473b408dd9d 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -216,6 +216,8 @@ struct mongroup {
* @mon: mongroup related data
* @mode: mode of resource group
* @mba_mbps_event: input monitoring event id when mba_sc is enabled
+ * @kmode_cpu_mask: list CPUs in the group when backing the active
+ * RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode
* @plr: pseudo-locked region
*/
struct rdtgroup {
@@ -229,6 +231,7 @@ struct rdtgroup {
struct mongroup mon;
enum rdtgrp_mode mode;
enum resctrl_event_id mba_mbps_event;
+ struct cpumask kmode_cpu_mask;
struct pseudo_lock_region *plr;
};
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 9235f094245c..16f68f4317ef 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -390,6 +390,32 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of,
return ret;
}
+/*
+ * Display CPU mask of the kernel mode backing the resource group.
+ * Supports both "kmode_cpus" (bitmap format) and "kmode_cpus_list"
+ * (range list format); the output format is selected accordingly.
+ *
+ * Returns -ENOENT on error.
+ */
+static int rdtgroup_kmode_cpus_show(struct kernfs_open_file *of,
+ struct seq_file *s, void *v)
+{
+ struct rdtgroup *rdtgrp;
+ int ret = 0;
+
+ rdtgrp = rdtgroup_kn_lock_live(of->kn);
+
+ /* Verify the group is the active kernel mode backing group */
+ if (!rdtgrp || rdtgrp != resctrl_kmode.rdtgrp)
+ ret = -ENOENT;
+ else
+ seq_printf(s, is_cpu_list(of) ? "%*pbl\n" : "%*pb\n",
+ cpumask_pr_args(&rdtgrp->kmode_cpu_mask));
+ rdtgroup_kn_unlock(of->kn);
+
+ return ret;
+}
+
/*
* Update the PGR_ASSOC MSR on all cpus in @cpu_mask,
*
@@ -2266,6 +2292,23 @@ static struct rftype res_common_files[] = {
.flags = RFTYPE_FLAGS_CPUS_LIST,
.fflags = RFTYPE_BASE,
},
+ {
+ .name = "kmode_cpus",
+ .mode = 0444,
+ .hidden = true,
+ .kf_ops = &rdtgroup_kf_single_ops,
+ .seq_show = rdtgroup_kmode_cpus_show,
+ .fflags = RFTYPE_BASE,
+ },
+ {
+ .name = "kmode_cpus_list",
+ .mode = 0444,
+ .hidden = true,
+ .kf_ops = &rdtgroup_kf_single_ops,
+ .seq_show = rdtgroup_kmode_cpus_show,
+ .flags = RFTYPE_FLAGS_CPUS_LIST,
+ .fflags = RFTYPE_BASE,
+ },
{
.name = "tasks",
.mode = 0644,
--
2.43.0