Re: [PATCH v7 06/19] fs/resctrl: Introduce data structures for kernel mode configuration
From: Moger, Babu
Date: Fri Dec 04 2026 - 11:21:41 EST
Hi Reinette,
On 12/1/2026 10:51 PM, Reinette Chatre wrote:
Hi Babu,
On 11/11/26 2:43 PM, Babu Moger wrote:
The resctrl filesystem needs to track the supported kernel modes, the
active mode, and whether the backing group's CLOSID and RMID are assigned
or inherited.
Introduce struct resctrl_kmode_cfg to represent supported kernel modes and
their configuration.
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
...
---
fs/resctrl/internal.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index e62a277dee85..38aa0c0cfb7e 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -314,6 +314,33 @@ struct mbm_state {
u32 prev_bw;
};
+/**
+ * enum kmode_state - Kernel mode association state.
Could this make clear that the state applies to one ID at a time? For example,
"Source of a CLOSID or RMID used by kernel work"
Sure.
* enum kmode_state - Source of a CLOSID or RMID used by kernel work.
* The state applies to one ID at a time, either the
* :qCLOSID or the RMID.
+ * @KMODE_INHERIT: Inherit the CLOSID or RMID from the user task.
+ * @KMODE_ASSIGN: Use the CLOSID or RMID from the backing resource group.
+ */
+enum kmode_state {
+ KMODE_INHERIT,
+ KMODE_ASSIGN
+};
+
+/**
+ * struct resctrl_kmode_cfg - Kernel mode configuration
+ * @supported: Bitmap of supported kernel modes.
+ * @active: Currently active kernel mode.
+ * @ctrl: CLOSID assign or inherit in %RESCTRL_GLOBAL_ENABLE_PER_CPU.
+ * @mon: RMID assign or inherit in %RESCTRL_GLOBAL_ENABLE_PER_CPU.
+ * @rdtgrp: Resource group backing %RESCTRL_GLOBAL_ENABLE_PER_CPU.
+ * %NULL while the mode is not selected.
The initializer in the next patch initializes ctrl and mon to KMODE_ASSIGN
that matches the default the user sees when viewing info/kernel_mode.
Considering this, should @rdtgrp not be initialized to point to the default
resource group to make the initialization consistent so that resctrl_kmode
contains the defaults of user configurable parameters?
Doing so will enforce the requirement that resctrl_kmode_cfg::rdtgrp
not be used as synonym for resctrl_kmode_cfg::active that we discussed
in
Sure. Will do.
https://lore.kernel.org/lkml/f7a56c83-b732-4959-9f31-6273d25963d1@xxxxxxxxx/
but this series does not consistently apply.
This should also simplify the info/kernel_mode _show() handler.
Ack.
+ */
+struct resctrl_kmode_cfg {
+ DECLARE_BITMAP(supported, RESCTRL_NUM_KERNEL_MODES);
+ enum resctrl_kernel_mode active;
+ enum kmode_state ctrl;
+ enum kmode_state mon;
+ struct rdtgroup *rdtgrp;
Looking ahead there is one more RESCTRL_GLOBAL_ENABLE_PER_CPU data structure:
the cpumask that tracks which online CPUs has RESCTRL_GLOBAL_ENABLE_PER_CPU
enabled. Later patch adds that to every resource group (rdtgroup::kmode_cpu_mask).
A system may have many resource groups (num CLOSIDs x num RMIDs) and with
a large NR_CPUS a struct cpumask can get large.
It seems wasteful to have a per-resource group struct cpumask when only
one resource group ever needs it.
Could the RESCTRL_GLOBAL_ENABLE_PER_CPU mode properties all be together here
and also include the cpumask on which the mode is enabled?
* @cpu_mask: CPUs on which %RESCTRL_GLOBAL_ENABLE_PER_CPU is enabled.
* Contains only online CPUs. Empty while
* %RESCTRL_GLOBAL_ENABLE_PER_CPU is not active.
Yes, this can be done. However, it changes a few other aspects of the implementation as well.
With this approach, we would no longer need:
Patch 11: Add support for hidden resource group files
Patch 17: Control visibility of global per-CPU kernel mode group files
The remaining challenge is finding a clean way to display the CPU mask when RESCTRL_GLOBAL_ENABLE_PER_CPU is enabled.
What are your thoughts on handling that?
Thanks,
Babu