[PATCH v7 06/19] fs/resctrl: Introduce data structures for kernel mode configuration

Babu Moger babu.moger at amd.com
Wed Nov 11 14:43:59 PST 2026


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 at amd.com>
---
v7: Changed kmode_sup -> supported, kmode_cur -> active.
    Updated the changelog.
    Removed resctrl_kmode_init().
    Updated the code comments.

v6: Drop ctrl_en/mon_en and use resctrl_arch_alloc_capable() /
    resctrl_arch_mon_capable() directly. Flatten caps/active into
    resctrl_kmode_cfg. Rename resctrl_kcfg to resctrl_kmode, ctrl_mode
    to ctrl, mon_mode to mon, and k_rdtgrp to rdtgrp. Comments describe
    the objects, not a member list. Rewrite changelog.

v5: Replace per-mode registration helpers with a single resctrl_kmode_cfg
    structure. Derive ctrl_en and mon_en from resctrl_arch_alloc_capable()
    and resctrl_arch_mon_capable() during filesystem init. Update code
    comments and changelog.

v4: New patch to initialize supported kernel modes.
    https://lore.kernel.org/lkml/737a4228-52fb-4583-ac64-8efe79c107e6@intel.com/
    Changed the kmode_cur to enum resctrl_kernel_mode in resctrl_kmode_cfg.
    Moved the resctrl_kmode_cfg to filesystem code.
---
 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.
+ * @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.
+ */
+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;
+};
+
 extern struct mutex rdtgroup_mutex;
 
 static inline const char *rdt_kn_name(const struct kernfs_node *kn)
-- 
2.43.0




More information about the linux-arm-kernel mailing list