[PATCH v5 07/16] fs/resctrl: Introduce resctrl_set_kmode_support() to register supported modes

From: Babu Moger

Date: Wed Aug 26 2026 - 15:36:01 EST


Architectures need to advertise supported kernel modes before resctrl
can expose them through the filesystem.

Generic resctrl has no registration hook for architecture-specific
kernel mode policies.

Introduce resctrl_set_kmode_support() to set the corresponding bit in
resctrl_kcfg.caps.kmode_sup during initialization. Architectures may
call this to register RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU when they
support independent kernel mode control and/or monitoring assignment.

Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v5: New patch split from resctrl_kmode_cfg initialization. Register modes
in resctrl_kmode_cfg.caps.kmode_sup using RESCTRL_INHERIT_USER and
RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU. Ignore out-of-range mode values.

v4: New patch to initialize supported kernel modes.
https://lore.kernel.org/lkml/737a4228-52fb-4583-ac64-8efe79c107e6@xxxxxxxxx/
---
fs/resctrl/rdtgroup.c | 13 +++++++++++++
include/linux/resctrl.h | 17 +++++++++++++++++
2 files changed, 30 insertions(+)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 3c53f3f74e5a..3bb0e3a203ac 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -892,6 +892,19 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of,
return ret;
}

+/**
+ * resctrl_set_kmode_support() - Register a supported kernel mode
+ * @kmode: Kernel mode policy supported by the architecture.
+ *
+ * Set the corresponding bit in resctrl_kcfg.caps.kmode_sup so @kmode
+ * is visible to the resctrl file system.
+ */
+void resctrl_set_kmode_support(enum resctrl_kernel_mode kmode)
+{
+ if (kmode < RESCTRL_NUM_KERNEL_MODES)
+ __set_bit(kmode, resctrl_kcfg.caps.kmode_sup);
+}
+
#ifdef CONFIG_PROC_CPU_RESCTRL
/*
* A task can only be part of one resctrl control group and of one monitor
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 8b30eef835aa..051aece77eb9 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -729,6 +729,23 @@ enum resctrl_kernel_mode {

#define RESCTRL_NUM_KERNEL_MODES (RESCTRL_KMODE_LAST + 1)

+/**
+ * resctrl_set_kmode_support() - Register a supported kernel mode
+ * @kmode: Kernel mode supported by the architecture.
+ *
+ * Set the corresponding bit in resctrl_kcfg.caps.kmode_sup so @kmode
+ * can be exposed through the resctrl filesystem.
+ * RESCTRL_INHERIT_USER is registered by resctrl_kmode_init() and does
+ * not need to be registered again.
+ *
+ * Architectures use this interface during resctrl initialization to
+ * advertise supported kernel modes. Registration of a mode indicates
+ * architectural support only. The final decision to expose and enable
+ * a mode is made by resctrl based on system capabilities and
+ * configuration.
+ */
+void resctrl_set_kmode_support(enum resctrl_kernel_mode kmode);
+
/**
* resctrl_arch_configure_kmode() - Program kernel mode association
* @cpu_mask: CPUs to assign the kernel mode on.
--
2.43.0