[PATCH v7 04/19] fs/resctrl: Introduce kernel mode enum
From: Babu Moger
Date: Wed Nov 11 2026 - 17:54:44 EST
Kernel work need not use the CLOSID and RMID of the user task on whose
behalf it runs. On x86, Privilege Level Zero Association (PLZA) enables a
CPU to use a different CLOSID and/or RMID association while executing at
privilege level zero.
Resctrl needs common definitions of how kernel work is managed so that
architectures can advertise the kernel modes they support and user space
can query them and select the one to use.
Introduce enum resctrl_kernel_mode:
- RESCTRL_INHERIT_USER: Kernel work uses the CLOSID and RMID of the user
task.
- RESCTRL_GLOBAL_ENABLE_PER_CPU: All the kernel work uses the CLOSID
and/or RMID of a single resource group, which may also have user tasks
assigned to it. The mode can be enabled or disabled per-CPU; on a CPU
where it is disabled, kernel work inherits the user task's CLOSID and
RMID.
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v7: Changelog update (Reinette) with minor changes.
Code comment update.
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 | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index b6b4519a5190..6f3e57ec4aa3 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -716,6 +716,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 modes
+ *
+ * @RESCTRL_INHERIT_USER:
+ * Kernel work inherits the CLOSID and RMID of the user task.
+ *
+ * @RESCTRL_GLOBAL_ENABLE_PER_CPU:
+ * All kernel work uses the CLOSID and/or RMID of a single resource
+ * group, which may also have user tasks assigned to it. The mode can
+ * be enabled/disabled per-CPU, all online CPUs are enabled by default.
+ * When the mode is disabled on a CPU then the kernel work on that CPU
+ * inherits the CLOSID and RMID from the user task, effectively the
+ * kernel mode becomes RESCTRL_INHERIT_USER on that CPU.
+ *
+ * On x86, CLOSID and RMID are configured independently; either or both
+ * may differ from the user 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