Re: [PATCH v5 11/16] fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup

From: Babu Moger

Date: Thu Sep 17 2026 - 15:23:25 EST


Hi Reinette,

On 9/16/26 00:34, Reinette Chatre wrote:
Hi Babu,

On 8/26/26 12:32 PM, Babu Moger wrote:
fs/resctrl/internal.h | 5 +++++
fs/resctrl/rdtgroup.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)

diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index b56f95625072..01f9f596f9b1 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -216,6 +216,9 @@ struct mongroup {
* @mon: mongroup related data
* @mode: mode of resource group
* @mba_mbps_event: input monitoring event id when mba_sc is enabled
+ * @kmode: true if this group has an active kernel-mode
+ * association

This really just seems specific to the global per-CPU kernel mode. Why is
it necessary? Is resctrl_kcfg.active.k_rdtgrp not sufficient by itself? (more below)

I think we can do it by checking the
rdtgrp == resctrl_kcfg.active.k_rdtgrp


+ * @kmode_cpu_mask: CPUs in this group's kernel-mode association
* @plr: pseudo-locked region
*/
struct rdtgroup {
@@ -229,6 +232,8 @@ struct rdtgroup {
struct mongroup mon;
enum rdtgrp_mode mode;
enum resctrl_event_id mba_mbps_event;
+ bool kmode;
+ struct cpumask kmode_cpu_mask;
struct pseudo_lock_region *plr;
};
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index d2fff8adf915..06e74b027044 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -389,6 +389,32 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of,
return ret;
}
+/*
+ * Display CPU masks for the kernel-mode associated 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);
+
+ if (rdtgrp && rdtgrp->kmode) {

First, it would be helpful to explain why the second test is needed since it
is not obvious that a resource group may get re-assigned while a user has this
file open.

Second, could a check of rdtgrp->kmode be replaced with a comparison between
rdtgrp and resctrl_kcfg.active.k_rdtgrp ? If so, why is rdtgrp::kmode needed?
I think one part of this is how this series blurs between a generic
"kernel mode" and the specific only-supported global per-CPU kernel mode
that makes it difficult to know what state can be used.

ok. We can check rdtgrp == resctrl_kcfg.active.k_rdtgrp

Thanks
Babu