Re: [PATCH] sched,workqueue: Use READ_ONCE()/WRITE_ONCE() for wake_cpu accesses

From: Tejun Heo

Date: Mon Mar 30 2026 - 16:09:54 EST


Hello, Peter.

On Mon, Mar 30, 2026 at 04:36:29PM +0200, Peter Zijlstra wrote:
> > Hmmm... it would trigger KCSAN. Maybe a better way to do it is exposing
> > sched interface that does WRITE_ONCE wrapping? How do you want it resolved?
>
> Perhaps a try_to_wake_up() variant that takes a cpumask (see the
> completely untested code below). But I'm not entirely sure. The current
> thing very much relies on a bunch of implementation details that aren't
> guaranteed.
>
> The below will 'fake' the task cpumask for a while; and note that the
> caller has to be careful to provide a mask that only includes tasks that
> were set in the current task, otherwise 'funny' things will happen.
> Also, it will only use this mask if it ends up doing CPU selection at
> all.
>
> Ooh, I suppose I should make sure wake_cpu is inside the provided map
> too...

Does it need to be? I think all select_task_rq() implementations ignore it
if it's outside allowed. I think all we'd need is cpumask_subset() test to
reject (and trigger WARN_ON_ONCE()) if the preferred mask is not within the
allowed.

Thanks.

--
tejun