Re: [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup

From: Jinjie Ruan

Date: Thu Nov 19 2026 - 07:16:00 EST




在 2026/11/19 19:21, Ben Horgan 写道:
> Hi Jinjie,
>
> On 19/11/2026 09:48, Jinjie Ruan wrote:
>> To support CDP, resctrl halves the number of CLOSIDs available to
>> resource groups and gives each remaining CLOSID two hardware
>> configurations instead of one, distinguished by index: 2 * CLOSID for
>> data and 2 * CLOSID + 1 for code. Without CDP a CLOSID has a single
>> configuration, at index CLOSID. Every architecture computes these
>> indices the same way.
>>
>> Unmounting clears the CDP state before it undoes what the groups were
>> given, so the cleanup computes index CLOSID where the group was set up
>> with 2 * CLOSID and 2 * CLOSID + 1. The group's two configurations are
>> left in place and index CLOSID is cleared instead, which with CDP
>> enabled is a configuration of a different CLOSID. The architecture may
>> keep this state for as long as the resource exists.
>>
>> Only MPAM can reach this today. Of everything the cleanup has to undo,
>> MPAM addresses only the MBM counter assignment by the translated CLOSID,
>> and it only began doing so when it implemented assignable counters.
>
> This is clearly not ideal but even in MPAM we get away without any usable visible effect. Or am I
> missing something? We are left with some assigned counters from the MPAM driver point of view but
> the resctrl is in charge of the assignments and MPAM doesn't check if a counter is already assigned
> when resctrl asks for a new assignment. The change looks good to me.

I agree with your analysis, and I have also confirmed it:

- __config_cntr() only performs an overwrite write and does not modify
the allocation of assigned_counters[].

if (assign)
mon->mbwu_idx_to_mon[mbwu_idx] = mon->assigned_counters[mon_idx];
else
mon->mbwu_idx_to_mon[mbwu_idx] = -1;

- When umount, the resctrl cntr_cfg[] is destroyed along with the
domain, and cross-mounting does not exist.

- When the mbm_cntr_get() is used to read, cntr_cfg[] of the resctrl is
checked first. If no record is found, the value is directly set to
Unassigned, so the stale mbwu_idx_to_mon will not be read between
unmounted and the next time it is mounted.

- Each time a new allocation is performed, the same
mbwu_idx_to_mon[mbwu_idx] is overwritten.

so there is no observable error. It is a silent error.

Best regards,
Jinjie

>
> Thanks,
>
> Ben
>
>
> x86
>> addresses its counters by RMID alone.
>>
>> Clear the CDP state after the cleanup, so that the cleanup runs with the
>> CDP state the groups were set up under.
>>
>> Fixes: 6e0e538a75ce ("arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use")
>> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
>> Cc: <stable@xxxxxxxxxxxxxxx>
>> ---
>> v6:
>> - Describe the CDP indices as resctrl filesystem behavior that applies
>> to every architecture, and the flow instead of the code (Reinette).
>> - Drop the stable version range, the Fixes tag already gives it.
>> ---
>> fs/resctrl/rdtgroup.c | 10 ++++++++--
>> 1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
>> index 5d0351453c2f..3312637fb514 100644
>> --- a/fs/resctrl/rdtgroup.c
>> +++ b/fs/resctrl/rdtgroup.c
>> @@ -3150,13 +3150,19 @@ static void resctrl_unmount(void)
>> cpus_read_lock();
>> mutex_lock(&rdtgroup_mutex);
>>
>> - rdt_disable_ctx();
>> -
>> /* Put everything back to default values. */
>> for_each_alloc_capable_rdt_resource(r)
>> resctrl_arch_reset_all_ctrls(r);
>>
>> resctrl_fs_teardown();
>> +
>> + /*
>> + * Clear the CDP state after the cleanup. The CDP state decides
>> + * which hardware configuration a CLOSID refers to, so the teardown
>> + * must run with the state the configuration was created under.
>> + */
>> + rdt_disable_ctx();
>> +
>> if (resctrl_arch_alloc_capable())
>> resctrl_arch_disable_alloc();
>> if (resctrl_arch_mon_capable())
>