[PATCH v7 06/19] fs/resctrl: Introduce data structures for kernel mode configuration

Reinette Chatre reinette.chatre at intel.com
Tue Dec 1 20:51:17 PST 2026


Hi Babu,

On 11/11/26 2:43 PM, Babu Moger wrote:
> The resctrl filesystem needs to track the supported kernel modes, the
> active mode, and whether the backing group's CLOSID and RMID are assigned
> or inherited.
> 
> Introduce struct resctrl_kmode_cfg to represent supported kernel modes and
> their configuration.
> 
> Signed-off-by: Babu Moger <babu.moger at amd.com>
> ---

...

> ---
>  fs/resctrl/internal.h | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
> index e62a277dee85..38aa0c0cfb7e 100644
> --- a/fs/resctrl/internal.h
> +++ b/fs/resctrl/internal.h
> @@ -314,6 +314,33 @@ struct mbm_state {
>  	u32	prev_bw;
>  };
>  
> +/**
> + * enum kmode_state - Kernel mode association state.

Could this make clear that the state applies to one ID at a time? For example,
	"Source of a CLOSID or RMID used by kernel work"

> + * @KMODE_INHERIT:    Inherit the CLOSID or RMID from the user task.
> + * @KMODE_ASSIGN:     Use the CLOSID or RMID from the backing resource group.
> + */
> +enum kmode_state {
> +	KMODE_INHERIT,
> +	KMODE_ASSIGN
> +};
> +
> +/**
> + * struct resctrl_kmode_cfg - Kernel mode configuration
> + * @supported:	Bitmap of supported kernel modes.
> + * @active:	Currently active kernel mode.
> + * @ctrl:	CLOSID assign or inherit in %RESCTRL_GLOBAL_ENABLE_PER_CPU.
> + * @mon:	RMID assign or inherit in %RESCTRL_GLOBAL_ENABLE_PER_CPU.
> + * @rdtgrp:	Resource group backing %RESCTRL_GLOBAL_ENABLE_PER_CPU.
> + *		%NULL while the mode is not selected.

The initializer in the next patch initializes ctrl and mon to KMODE_ASSIGN
that matches the default the user sees when viewing info/kernel_mode.
Considering this, should @rdtgrp not be initialized to point to the default
resource group to make the initialization consistent so that resctrl_kmode
contains the defaults of user configurable parameters? 

Doing so will enforce the requirement that resctrl_kmode_cfg::rdtgrp
not be used as synonym for resctrl_kmode_cfg::active that we discussed
in 

https://lore.kernel.org/lkml/f7a56c83-b732-4959-9f31-6273d25963d1@intel.com/

but this series does not consistently apply. 

This should also simplify the info/kernel_mode _show() handler.

> + */
> +struct resctrl_kmode_cfg {
> +	DECLARE_BITMAP(supported, RESCTRL_NUM_KERNEL_MODES);
> +	enum resctrl_kernel_mode	active;
> +	enum kmode_state		ctrl;
> +	enum kmode_state		mon;
> +	struct rdtgroup			*rdtgrp;

Looking ahead there is one more RESCTRL_GLOBAL_ENABLE_PER_CPU data structure:
the cpumask that tracks which online CPUs has RESCTRL_GLOBAL_ENABLE_PER_CPU
enabled. Later patch adds that to every resource group (rdtgroup::kmode_cpu_mask).

A system may have many resource groups (num CLOSIDs x num RMIDs) and with
a large NR_CPUS a struct cpumask can get large. 

It seems wasteful to have a per-resource group struct cpumask when only
one resource group ever needs it. 

Could the RESCTRL_GLOBAL_ENABLE_PER_CPU mode properties all be together here
and also include the cpumask on which the mode is enabled? 

	* @cpu_mask:	CPUs on which %RESCTRL_GLOBAL_ENABLE_PER_CPU is enabled.
	*		Contains only online CPUs. Empty while
	*		%RESCTRL_GLOBAL_ENABLE_PER_CPU is not active.

> +};
> +
>  extern struct mutex rdtgroup_mutex;
>  
>  static inline const char *rdt_kn_name(const struct kernfs_node *kn)

Reinette



More information about the linux-arm-kernel mailing list