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

From: Babu Moger

Date: Thu Jun 18 2026 - 13:18:30 EST


Hi Reinette,


On 6/16/26 18:36, Reinette Chatre wrote:
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.


Ack.


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?

It will be initialized to 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.

That means resctrl_set_kmode_support() will be called from the architecture layer, likely from core.c within get_rdt_alloc_resources().

The resctrl_set_kmode_support() handler would need to initialize both the default mode and all supported modes.

I see that this is where the hotplug handler gets registered. Therefore, the modes are already initialized before the hotplug handler is set up.


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

(drop "later patches ...")


Sure.

Thanks
Babi