[PATCH v7 16/19] fs/resctrl: Reject mode changes for groups backing kernel mode
Reinette Chatre
reinette.chatre at intel.com
Tue Dec 1 21:07:09 PST 2026
Hi Babu,
On 11/11/26 2:44 PM, Babu Moger wrote:
> ---
> fs/resctrl/rdtgroup.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 872755532fb4..1ad169e714a4 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -1994,6 +1994,27 @@ static bool rdtgroup_mode_test_exclusive(struct rdtgroup *rdtgrp)
> return true;
> }
>
> +/* True when @rdtgrp or one of its monitor groups backs the kernel mode. */
> +static bool rdtgroup_has_kmode_global(struct rdtgroup *rdtgrp)
> +{
> + struct rdtgroup *child;
> +
> + if (!resctrl_kmode.rdtgrp)
> + return false;
Another instance of resctrl_kmode_cfg::rdtgroup used as synonym of RESCTRL_GLOBAL_ENABLE_PER_CPU
> +
> + if (resctrl_kmode.rdtgrp == rdtgrp)
> + return true;
> +
> + if (rdtgrp->type != RDTCTRL_GROUP)
> + return false;
> +
> + list_for_each_entry(child, &rdtgrp->mon.crdtgrp_list, mon.crdtgrp_list)
> + if (child == resctrl_kmode.rdtgrp)
> + return true;
> +
> + return false;
> +}
> +
> /*
> * rdtgroup_mode_write - Modify the resource group's mode
> */
> @@ -2034,6 +2055,12 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of,
> goto out;
> }
>
> + if (rdtgroup_has_kmode_global(rdtgrp)) {
> + rdt_last_cmd_puts("Cannot change mode for kernel mode backing group\n");
> + ret = -EINVAL;
> + goto out;
> + }
> +
> if (!strcmp(buf, "shareable")) {
> if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
> ret = rdtgroup_locksetup_exit(rdtgrp);
> @@ -4922,6 +4949,19 @@ static int rdtgroup_rename(struct kernfs_node *kn,
> goto out;
> }
>
> + /*
> + * Changing the parent of a group backing the active kernel mode changes
> + * the effective CLOSID and/or RMID configuration applied to kernel work.
> + * Reject such moves and require kernel mode to be reconfigured explicitly
> + * instead.
> + */
> + if (rdtgrp == resctrl_kmode.rdtgrp &&
... and another.
> + rdtgrp->mon.parent != new_prdtgrp) {
> + rdt_last_cmd_puts("Cannot move a group that backs kernel mode\n");
> + ret = -EPERM;
> + goto out;
> + }
> +
> /*
> * Allocate the cpumask for use in mongrp_reparent() to avoid the
> * possibility of failing to allocate it after kernfs_rename() has
Reinette
More information about the linux-arm-kernel
mailing list