Re: [PATCH v2 0/4] fork,arm,x86,fs/resctrl: Fix stale resource group assignment on fork
From: Reinette Chatre
Date: Fri Dec 04 2026 - 18:00:45 EST
Hi Tony,
On 12/4/26 1:07 PM, Luck, Tony wrote:
> On Fri, Dec 04, 2026 at 11:15:12AM -0800, Reinette Chatre wrote:
>> What remains?
>> =============
>> On x86 the CLOSID and RMID are separate values in struct task_struct and
>> __resctrl_sched_in() reads them without a lock, so a task can still be
>> labelled with a mismatched pair for the duration of a move. Unlike the
>> fork case, which is permanent and invisible to every later walk of the
>> task list, that window is transient and the pair is corrected at the next
>> context switch. MPAM stores the two as a single value.
>
> I think the patch below covers this (only atomic on 64-bit CPUs).
Thank you for taking a look.
If I understand correctly the 64-bit dependency comes from the READ_ONCE()
and WRITE_ONCE() usage that requires the 64-bit value to be accessed as a
single value. Since your proposal relies on READ_ONCE() and WRITE_ONCE()
it requires resctrl to depend on X86_64. As soon as
https://lore.kernel.org/lkml/39843a4166ca45ac777548eb70e777e2f23c949c.1793864720.git.yu.c.chen@xxxxxxxxx/
lands then we can address this remaining transient issue without needing to
involve the scheduler and MM maintainers.
The fix in this series addresses a different and more severe (permanent instead
of transient) issue that does not have this dependency.
> Builds and passes tools/testing/selftests/resctrl/resctrl_tests.
>
> -Tony
>
> ---
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index e4f6323d7855..c79ac345136d 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1364,8 +1364,13 @@ struct task_struct {
> #endif /* CONFIG_PREEMPT_RT */
> #endif /* CONFIG_CGROUPS */
> #ifdef CONFIG_X86_CPU_RESCTRL
> - u32 closid;
> - u32 rmid;
> + union x86_pqosid {
> + u64 pqosid;
> + struct {
> + u32 closid;
> + u32 rmid;
> + };
> + };
> #endif
>
Have you considered Chenyu's proposal?
https://lore.kernel.org/lkml/awO3nYazk97csbpO@chenyu-dev/
It matches the MPAM implementation with a single:
u64 closid_rmid;
I prefer this single value approach since it does not create false
impression that the closid and rmid members can be written on their own.
Reinette