[PATCH v7 14/19] fs/resctrl: Deactivate kernel mode when the group is removed

Reinette Chatre reinette.chatre at intel.com
Tue Dec 1 21:03:38 PST 2026


Hi Babu,

On 11/11/26 2:44 PM, Babu Moger wrote:
> The RESCTRL_GLOBAL_ENABLE_PER_CPU allows CPUs to use different CLOSID

(missing kernel mode)

> and/or RMID association when transitioning from user mode to kernel mode.
> When active, the mode is enabled or disabled on a per-CPU basis as part a
> backing resource group.

"as part a backing" -> "as part of a backing"

(above is mostly repeated copy&paste - please make context unique to patch)

> 
> When the backing group is removed, the configured kernel mode settings are
> no longer valid. Deactivate the kernel mode and restore it to
> RESCTRL_INHERIT_USER, the default mode in which kernel work inherits the
> user task's CLOSID and/or RMID.

I am not able to find the explanation you planned to add about *why* this
behavior is different from other typical resctrl flows that move a removed
resource group's assignment to the default resource group:

	https://lore.kernel.org/lkml/71285fd5-6094-4114-a0f0-7d55c049edd9@amd.com/

> 
> Signed-off-by: Babu Moger <babu.moger at amd.com>
> ---

...

> ---
>  Documentation/filesystems/resctrl.rst |  3 +++
>  fs/resctrl/rdtgroup.c                 | 30 +++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
> index 033d405338c0..e57361dd342e 100644
> --- a/Documentation/filesystems/resctrl.rst
> +++ b/Documentation/filesystems/resctrl.rst
> @@ -594,6 +594,9 @@ The top level of the "info" directory contains the following file(s):
>  			When "mon=inherit", or monitoring is unsupported, a CTRL_MON group
>  			is shown as "<CTRL_MON>/".
>  
> +			Removing the backing group deactivates the current kernel mode and
> +			restores to "inherit_user".

This is the "global_enable_per_cpu" section so no need to be vague with "the current kernel mode".

"restores to "inherit_user"" ? restores what?

> +
>  		When the mode is not active, the output lists the supported parameters
>  		and their default values, which are used if the mode is activated
>  		without new values.
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index af4c929d7ed4..97d99406de00 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -1178,6 +1178,29 @@ static void resctrl_kmode_global_offline_cpu(unsigned int cpu)
>  	resctrl_configure_kmode_global(cpumask_of(cpu), rdtgrp, false);
>  }
>  
> +/*
> + * rdtgroup_kmode_global_deactivate() - Deactivate global kernel mode
> + * @rdtgrp: Resctrl group backing the active kernel mode.
> + *
> + * If @rdtgrp backs the active RESCTRL_GLOBAL_ENABLE_PER_CPU mode, disable
> + * the mode, clear kernel mode state, and restore the default
> + * RESCTRL_INHERIT_USER configuration.
> + */
> +static void rdtgroup_kmode_global_deactivate(struct rdtgroup *rdtgrp)
> +{
> +	if (resctrl_kmode.active != RESCTRL_GLOBAL_ENABLE_PER_CPU ||
> +	    resctrl_kmode.rdtgrp != rdtgrp)
> +		return;
> +
> +	resctrl_configure_kmode_global(&rdtgrp->kmode_cpu_mask, rdtgrp, false);
> +	cpumask_clear(&rdtgrp->kmode_cpu_mask);
> +
> +	resctrl_kmode.rdtgrp = NULL;
> +	resctrl_kmode.active = RESCTRL_INHERIT_USER;
> +	resctrl_kmode.ctrl = KMODE_ASSIGN;
> +	resctrl_kmode.mon = KMODE_ASSIGN;

Please see response to patch #13 about this function.

Reinette



More information about the linux-arm-kernel mailing list