[PATCH v5 04/16] fs/resctrl: Introduce kernel mode policy enum
From: Babu Moger
Date: Wed Aug 26 2026 - 15:35:17 EST
Kernel mode traffic 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/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 inherits allocation and monitoring
from the user task.
- RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU: Kernel mode may use allocation
and/or monitoring associations that differ from the user task. On x86,
CLOSID and RMID can be configured independently for kernel mode.
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
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 | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index dd09c2ce9a0f..4245d1e65ccc 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -704,6 +704,31 @@ 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, kernel uses the same CLOSID and
+ * RMID as the user-space task.
+ *
+ * @RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU:
+ * Kernel mode may use allocation and monitoring associations that
+ * differ from the user task. On x86, CLOSID and RMID are configured
+ * independently; either or both may differ from user mode.
+ *
+ * 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 associated with this mode.
+ */
+enum resctrl_kernel_mode {
+ RESCTRL_INHERIT_USER,
+ RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU,
+ RESCTRL_KMODE_LAST = RESCTRL_ASSIGN_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