[PATCH v6 04/18] fs/resctrl: Introduce kernel mode enum
From: Babu Moger
Date: Thu Oct 01 2026 - 11:38:44 EST
Kernel mode work can use different allocation and monitoring associations
than the originating user task. On x86, Privilege Level Zero Association
(PLZA) enables the kernel to switch to a different CLOSID and/or RMID when
entering kernel mode.
Architectures need a common way to name kernel modes before resctrl
can report what is active or what the platform supports.
Introduce enum resctrl_kernel_mode:
- RESCTRL_INHERIT_USER: Kernel mode work inherits allocation and
monitoring from the user task.
- RESCTRL_GLOBAL_ENABLE_PER_CPU: Kernel mode work uses allocation and/or
monitoring associations that differ from the user task.
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v6: changelog update and code comment update.
Renamed RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU to RESCTRL_GLOBAL_ENABLE_PER_CPU.
v5: Collapse the two global-assign modes into a single
RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU value. Update the changelog to
match the enum names and descriptions in the code.
v4: Updated the changelog to be generic as possible.
Moved the enum resctrl_kernel_mode to include/linux/resctrl.h.
Updated the code comments to be generic.
Removed resctrl_kmode_cfg from the code. This definition can be fs
specific only and architectures dont need to know.
Changed enum name to resctrl_kernel_mode from resctrl_kernel_modes.
v3: Removed resctrl_kmode definition.
Changed the kernel mode definitions to enum resctrl_kernel_modes.
Used BIT() to set/test the features.
Added details to changelog.
v2: New patch to handle PLZA interfaces with /sys/fs/resctrl/info/ directory.
https://lore.kernel.org/lkml/2ab556af-095b-422b-9396-f845c6fd0342@xxxxxxxxx/
---
include/linux/resctrl.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 10dfdca7f4bf..f6adff7f4e1f 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -723,6 +723,35 @@ int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable);
*/
bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r);
+/**
+ * enum resctrl_kernel_mode - Kernel mode control and monitoring association.
+ *
+ * @RESCTRL_INHERIT_USER:
+ * Kernel mode inherits both allocation and monitoring associations
+ * from the user-space task. On x86, the kernel uses the same CLOSID and
+ * RMID as the user-space task.
+ *
+ * @RESCTRL_GLOBAL_ENABLE_PER_CPU:
+ * All kernel mode work uses the same allocation and/or monitoring
+ * association via an assigned CTRL_MON or MON group. The mode can
+ * be enabled/disabled per-CPU. When the mode is disabled on a CPU
+ * then the kernel work on that CPU inherits the allocation and
+ * monitoring association from the user-space task, effectively the
+ * kernel mode becomes RESCTRL_INHERIT_USER on that CPU.
+ *
+ * All online CPUs are included by default. A subset may be selected
+ * through the resctrl group interface, and a CTRL_MON or MON group
+ * may be assigned to this mode. On x86, CLOSID and RMID are configured
+ * independently; either or both may differ from the user-space task.
+ */
+enum resctrl_kernel_mode {
+ RESCTRL_INHERIT_USER,
+ RESCTRL_GLOBAL_ENABLE_PER_CPU,
+ RESCTRL_KMODE_LAST = RESCTRL_GLOBAL_ENABLE_PER_CPU
+};
+
+#define RESCTRL_NUM_KERNEL_MODES (RESCTRL_KMODE_LAST + 1)
+
extern unsigned int resctrl_rmid_realloc_threshold;
extern unsigned int resctrl_rmid_realloc_limit;
--
2.43.0