Re: [PATCH v7 06/19] fs/resctrl: Introduce data structures for kernel mode configuration
From: Reinette Chatre
Date: Fri Dec 04 2026 - 11:33:59 EST
Hi Babu,
On 12/4/26 8:21 AM, Moger, Babu wrote:
> On 12/1/2026 10:51 PM, Reinette Chatre wrote:
>> On 11/11/26 2:43 PM, Babu Moger wrote:
>>> ---
>>> fs/resctrl/internal.h | 27 +++++++++++++++++++++++++++
>>> 1 file changed, 27 insertions(+)
>>>
>>> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
>>> index e62a277dee85..38aa0c0cfb7e 100644
>>> --- a/fs/resctrl/internal.h
>>> +++ b/fs/resctrl/internal.h
>>> @@ -314,6 +314,33 @@ struct mbm_state {
>>> u32 prev_bw;
>>> };
>>> +/**
>>> + * enum kmode_state - Kernel mode association state.
>>
>> Could this make clear that the state applies to one ID at a time? For example,
>> "Source of a CLOSID or RMID used by kernel work"
>
> Sure.
>
> * enum kmode_state - Source of a CLOSID or RMID used by kernel work.
> * The state applies to one ID at a time, either the
> * :qCLOSID or the RMID.
The second sentence may not be necessary but up to you. Mind the typo though.
>
>>
>>> + * @KMODE_INHERIT: Inherit the CLOSID or RMID from the user task.
>>> + * @KMODE_ASSIGN: Use the CLOSID or RMID from the backing resource group.
>>> + */
>>> +enum kmode_state {
>>> + KMODE_INHERIT,
>>> + KMODE_ASSIGN
>>> +};
...
>>> + */
>>> +struct resctrl_kmode_cfg {
>>> + DECLARE_BITMAP(supported, RESCTRL_NUM_KERNEL_MODES);
>>> + enum resctrl_kernel_mode active;
>>> + enum kmode_state ctrl;
>>> + enum kmode_state mon;
>>> + struct rdtgroup *rdtgrp;
>>
>> Looking ahead there is one more RESCTRL_GLOBAL_ENABLE_PER_CPU data structure:
>> the cpumask that tracks which online CPUs has RESCTRL_GLOBAL_ENABLE_PER_CPU
>> enabled. Later patch adds that to every resource group (rdtgroup::kmode_cpu_mask).
>>
>> A system may have many resource groups (num CLOSIDs x num RMIDs) and with
>> a large NR_CPUS a struct cpumask can get large.
>>
>> It seems wasteful to have a per-resource group struct cpumask when only
>> one resource group ever needs it.
>>
>> Could the RESCTRL_GLOBAL_ENABLE_PER_CPU mode properties all be together here
>> and also include the cpumask on which the mode is enabled?
>>
>> * @cpu_mask: CPUs on which %RESCTRL_GLOBAL_ENABLE_PER_CPU is enabled.
>> * Contains only online CPUs. Empty while
>> * %RESCTRL_GLOBAL_ENABLE_PER_CPU is not active.
>>
>
> Yes, this can be done. However, it changes a few other aspects of the implementation as well.
>
> With this approach, we would no longer need:
>
> Patch 11: Add support for hidden resource group files
> Patch 17: Control visibility of global per-CPU kernel mode group files
Why? Moving the CPU mask to struct resctrl_kmode_cfg only changes how resctrl stores
the data, not how it is exposed to user space. The data continues to be unique
to the resource group associated with RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode. Only
the resource group assigned to the active RESCTRL_GLOBAL_ENABLE_PER_CPU kernel mode
should have kmode_cpus and kmode_cpus_list visible and when the user accesses
those files resctrl will show/write resctrl_kmode_cfg::cpu_mask.
>
> The remaining challenge is finding a clean way to display the CPU mask when RESCTRL_GLOBAL_ENABLE_PER_CPU is enabled.
>
> What are your thoughts on handling that?
I do not expect any changes to how this data is exposed to user space.
The problem is not clear to me. Could you please elaborate?
Reinette