Re: [PATCH v2 2/2] fs/resctrl: Give a monitor domain the counters the groups already use

From: Jinjie Ruan

Date: Wed Nov 18 2026 - 21:12:57 EST




在 2026/11/18 23:57, Babu Moger 写道:
> Hi Jinjie,

Hi Babu,

>
> On 11/15/26 22:02, Jinjie Ruan wrote:
>>
>>
>> 在 2026/11/14 0:14, Ben Horgan 写道:
>>> Hi Jinjie,
>>
>> Hi Ben,
>>
>>>
>>> On 13/11/2026 08:35, tizi4590 wrote:
>>>> From: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
>>>>
>>>> With assignable MBM counters, resctrl can be mounted while all CPUs of
>>>> a monitor domain go offline and one of them comes back, either through
>>>> CPU hotplug or because hibernation takes the non-boot CPUs offline. The
>>>> domain is destroyed and re-created, and the new domain starts with no
>>>> counters assigned. Counters are otherwise only assigned when a group is
>>>> created, when rdtgroup_assign_cntrs() takes a free counter in each
>>>> monitor domain for each MBM event, so no code revisits the groups that
>>>> already exist.
>>>>
>>>> Those groups read "Unassigned" on the new domain, on any system with
>>>> assignable MBM counters. A counter assigned to them later through
>>>> mbm_L3_assignments is the lowest free one in that domain, so the same
>>>> group can end up with a different counter ID on different domains. For
>>>> example, with the counter ID each group uses for mbm_total_bytes and
>>>> "_" for none:
>>>>
>>>>                                 domain 0         domain 1
>>>>    mount, mkdir g1              default=0 g1=1   default=0 g1=1
>>>>    all CPUs of domain 1 offline default=0 g1=1   (destroyed)
>>>>    one CPU of domain 1 online   default=0 g1=1   default=_ g1=_
>>>>    assign g1 on domain 1        default=0 g1=1   default=_ g1=0
>>>>
>>>> Each domain has its own counters, so g1 can use counter 0 on domain 1
>>>> and counter 1 on domain 0 without affecting the other domain, but until
>>>> it is assigned on domain 1 it reads Unassigned there.
>>>
>>> I brought this up before and it was assessed that no change was
>>> required:
>>> https://lore.kernel.org/lkml/171f92a3-fa2e-44fb-
>>> b0d1-1250c72e31d1@xxxxxxx/
>>>
>>> Do you have any particular reason for wanting this behaviour?
>>
>> I discovered this issue during the testing process and feel it is not
>> very reasonable.
>>
>> This patch doesn't assign anything new - it only restores the counter ID
>> the group already uses on a domain that stayed online.
>>
>> So with the patch, Babu's two cases (`2=e;3=e` and `2=_;3=e`) both come
>> back exactly as they were. The only case it can't know is a group that
>> used a different ID on the domain that went away, and there it leaves
>> the event unassigned rather than guessing.
>
> I see this patch is trying to address two separate issues:
>
> 1. Automatically assigning counters when a domain comes online
>
> I understand the motivation here. It is reasonable to expect counters to
> be assigned when a monitor domain comes online and counters are
> available. However, monitor domain online/offline events are typically

Yes, there was originally a counter available, and after the domain
going offline and coming back online, users still expect it to be available.

> driven by CPU hotplug, hibernation, or other user-initiated actions. In

I agree

> these cases, the user is generally aware of the state transition and can
> explicitly assign counters after the domain is online if monitoring is
> required.

If the power management daemon triggers the sleep mode and no process
with the resctrl permission is involved, the existing monitoring group
in the newly created domain will remain in the unassigned state, causing
the monitoring data to be interrupted.

>
> 2. Retaining the same counter ID across domains
>
> I do not see why this is necessary. The design of assignable MBM
> counters intentionally treats counters as domain-local resources and
> provides flexibility to maximize counter availability across groups.
> Counter IDs are an implementation detail and are not visible to users. A

While fixing the issues related to mpam (the first patch), I also
realized that counters are in-domain resources. I believe this point was
intended to address the mpam issues in the first patch, but it is indeed
unnecessary.

> group using a different counter ID in another domain does not affect
> functionality or monitoring results. Therefore, I do not see a strong
> justification for preserving the same counter ID when a domain is
> recreated. Given the above, I am not convinced the added complexity is
> justified.
>
> Thanks,
>
> Babu