Re: [PATCH v7 23/40] sched: Make deadline policy and affinity changes wait for a cpuset attach
From: Mathieu Desnoyers
Date: Wed Nov 18 2026 - 08:40:10 EST
> Can this second __set_cpus_allowed_ptr() call apply a stale new_mask
> after cpuset_lock_no_attach() sleeps?
Yes, thanks. The restore reads the cpuset mask with no lock. That is
upstream code. But this patch sleeps between that read and the write,
and an attach can move the task meanwhile. The next version takes
cpuset_lock_no_attach() first. It then reads the cpuset mask again and
builds the restore mask under that lock. Every writer of a cpuset mask
holds cpuset_mutex, so the mask stays valid until the call.
> In addition, if css_set_move_task() moves p to the destination
> cpuset before cpuset_cpus_allowed() is read while
> attach_ctx.in_progress is still set, waiting in
> cpuset_lock_no_attach() delays restoring p->user_cpus_ptr from
> ctx->user_mask until after cpuset_attach_task() has already run
This does not change the result. A cpuset attach intersects the mask
with the user mask of the task, with or without this patch. So the task
gets the cpuset mask and the old user mask, as if the old user mask had
been put back first. The bandwidth stays in the root domain the attach
reserved: cpuset_can_attach() and cpuset_attach() saw the same user
mask. Keeping the restore after the attach is the reason for the wait.
Both points were checked by reading. Neither was reproduced.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com