[PATCH v7 12/19] fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup
Reinette Chatre
reinette.chatre at intel.com
Tue Dec 1 21:00:30 PST 2026
Hi Babu,
On 11/11/26 2:44 PM, Babu Moger wrote:
> The RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode allows CPUs to use different
> CLOSID and/or RMID associations when transitioning from user mode to kernel
(same comments as before)
> mode. When active, it is enabled or disabled on a per-CPU basis through a
> backing resource group.
>
> Add kmode_cpus and kmode_cpus_list to display the CPUs in a resource group
> backing the active kernel mode.
This does not sound right. Without this feature each resource group could
have CPUs assigned via the cpus/cpus_list files. "the CPUs in a
resource group" reads as though it refers to these CPUs?
>
> Signed-off-by: Babu Moger <babu.moger at amd.com>
> ---
...
> ---
> fs/resctrl/internal.h | 3 +++
> fs/resctrl/rdtgroup.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
> index 909511e985a1..a473b408dd9d 100644
> --- a/fs/resctrl/internal.h
> +++ b/fs/resctrl/internal.h
> @@ -216,6 +216,8 @@ struct mongroup {
> * @mon: mongroup related data
> * @mode: mode of resource group
> * @mba_mbps_event: input monitoring event id when mba_sc is enabled
> + * @kmode_cpu_mask: list CPUs in the group when backing the active
> + * RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode
This sounds a bit awkward. There is already a rdtgroup::cpu_mask and above
as it is worded creates confusion between these two masks. Although, as noted in
patch #6 this member can just move to struct resctrl_kmode_cfg.
> * @plr: pseudo-locked region
> */
> struct rdtgroup {
> @@ -229,6 +231,7 @@ struct rdtgroup {
> struct mongroup mon;
> enum rdtgrp_mode mode;
> enum resctrl_event_id mba_mbps_event;
> + struct cpumask kmode_cpu_mask;
> struct pseudo_lock_region *plr;
> };
>
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 9235f094245c..16f68f4317ef 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -390,6 +390,32 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of,
> return ret;
> }
>
> +/*
> + * Display CPU mask of the kernel mode backing the resource group.
This does not sound right. How about:
Display the CPUs on which the RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode
is enabled.
> + * Supports both "kmode_cpus" (bitmap format) and "kmode_cpus_list"
> + * (range list format); the output format is selected accordingly.
> + *
> + * Returns -ENOENT on error.
Please be consistent with existing code. For example,
Return: 0 on success, or -ENOENT if the group was removed or does not
back the active RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode.
> + */
> +static int rdtgroup_kmode_cpus_show(struct kernfs_open_file *of,
> + struct seq_file *s, void *v)
> +{
> + struct rdtgroup *rdtgrp;
> + int ret = 0;
> +
> + rdtgrp = rdtgroup_kn_lock_live(of->kn);
> +
> + /* Verify the group is the active kernel mode backing group */
This comment does not address the request to document the synchronization
issue mentioned in
https://lore.kernel.org/lkml/0096fb82-4104-429a-bd69-7f733624c664@intel.com/
/*
* Hiding the file does not wait for a reader blocked on
* rdtgroup_mutex. By the time the mutex is acquired, the kernel
* mode may have been deactivated or moved to a different group.
*/
This also does not address the consistency issue raised during v6 discussion:
https://lore.kernel.org/lkml/f7a56c83-b732-4959-9f31-6273d25963d1@intel.com/
you fixed rdtgroup_kmode_global_deactivate() in this version but the same issue appears
in multiple places in this series (rdtgroup_has_kmode_global(), rdtgroup_rename()),
including below where resctrl_kmode_cfg::rdtgrp is used as synonym for
"RESCTRL_GLOBAL_ENABLE_PER_CPU is enabled".
Since this check is needed multiple places, perhaps a helper is needed? How about
something like;
static bool rdtgroup_backs_kmode_global(struct rdtgroup *rdtgrp)
{
return resctrl_kmode.active == RESCTRL_GLOBAL_ENABLE_PER_CPU &&
resctrl_kmode.rdtgrp == rdtgrp;
}
> + if (!rdtgrp || rdtgrp != resctrl_kmode.rdtgrp)
rdtgroup_kn_lock_live() returns NULL on failure and before it does so it
prints an error to last_cmd_status. There is no error that accompanies the
"rdtgrp != resctrl_kmode.rdtgrp" check so if that causes the file read to
fail the read will return ENOENT but last_cmd_status will return "ok".
> + ret = -ENOENT;
> + else
> + seq_printf(s, is_cpu_list(of) ? "%*pbl\n" : "%*pb\n",
> + cpumask_pr_args(&rdtgrp->kmode_cpu_mask));
> + rdtgroup_kn_unlock(of->kn);
> +
> + return ret;
> +}
Reinette
More information about the linux-arm-kernel
mailing list