Re: [PATCH v7 06/19] fs/resctrl: Introduce data structures for kernel mode configuration

From: Reinette Chatre

Date: Fri Dec 04 2026 - 12:31:17 EST


Hi Babu,

On 12/4/26 9:24 AM, Moger, Babu wrote:
> On 12/4/2026 10:33 AM, Reinette Chatre wrote:
>> 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:
...
>>>>> + */
>>>>> +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?
>>
>>
>
> My bad.
>
> My mistake.
>
> We are still planning to add the files "kmode_cpus" and "kmode_cpus_list" to each group when the group is created.
> The visibility handling remains unchanged and will continue to work as implemented in this series.
>
> The data representing these files has been moved from struct rdtgroup to struct resctrl_kmode_cfg.
>
> Sorry for the confusion.
No problem. The suggestions are intended to simplify this implementation while
making it more robust. No major changes are intended as this work nears completion.

Reinette