[PATCH v7 04/19] fs/resctrl: Introduce kernel mode enum
Babu Moger
babu.moger at amd.com
Mon Nov 16 12:07:04 PST 2026
On 11/11/26 16:43, Babu Moger wrote:
> 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 at amd.com>
> ---
> 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@intel.com/
> ---
> 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
> +};
Sashiko reported:
https://sashiko.dev/#/patchset/cover.1794437052.git.babu.moger%40amd.com?part=4
=========================================================================
Should RESCTRL_KMODE_LAST be documented in the kernel-doc comment or
placed after a /* private: */ comment? Without either,
scripts/kernel-doc warns that RESCTRL_KMODE_LAST is not described in
enum resctrl_kernel_mode.
Also, the blank comment line before "On x86, CLOSID and RMID..." ends
the @RESCTRL_GLOBAL_ENABLE_PER_CPU section in kernel-doc, placing that
paragraph into the general enum description instead.
=======================================================================
Will document RESCTRL_KMODE_LAST and also remove the blank line before
the line ""On x86, CLOSID and RMID...".
Thanks
Babu
More information about the linux-arm-kernel
mailing list