Re: [PATCH v3 06/12] fs/resctrl: Initialize the global kernel-mode policy at subsystem init

From: Reinette Chatre

Date: Tue Jun 16 2026 - 19:36:29 EST


Hi Babu,

On 4/30/26 4:24 PM, Babu Moger wrote:
> kernel_mode feature needs to add the interface that lets user space
> choose between INHERIT_CTRL_AND_MON, GLOBAL_ASSIGN_CTRL_INHERIT_MON_PER_CPU
> and GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU. Both the generic resctrl
> code and the architecture layer need a single shared snapshot of the
> supported and effective policy plus the resource group that backs the
> global-assign modes; that snapshot is struct resctrl_kmode_cfg.

This does not seem to match implementation since this implementation does
not actually share struct resctrl_kmode_cfg as described above. Only
resctrl_arch_get_kmode_support() exchanges this struct between fs and
arch and as already mentioned that usage looks unnecessary. The other
arch/fs touch points use either individual members or their properties
(like closid/rmid).

As described in response to previous patch I think this can be simplified
while also making it more robust.

>
> Add the file-local resctrl_kcfg and a helper resctrl_kmode_init() that:
>
> - Adds kmode and kmode_cur with BIT(INHERIT_CTRL_AND_MON), the
> universally supported mode and today's behaviour;
> - points k_rdtgrp at rdtgroup_default so global-assign modes have a
> valid backing group from boot;

If the default mode is INHERIT_CTRL_AND_MON then should the default group
not be NULL?

> - calls resctrl_arch_get_kmode_support() so each architecture ORs
> BIT(<mode>) into kmode for the policies its hardware supports
> (on x86, AMD PLZA contributes the two global-assign modes).
>
> resctrl_kmode_init() runs from resctrl_init() once the default group

resctrl_kmode_init() can be dropped after changes described in response
to previous patch. Apart from no longer being necessary I also find that
having the kernel mode fully initialized *before* the hotplug handlers run
to be simpler.

> has been set up. No user-visible behaviour changes yet; later patches

(drop "later patches ...")

> expose kmode_cur via sysfs and act on changes.
>
> Signed-off-by: Babu Moger <babu.moger@xxxxxxx>


Reinette