Re: [PATCH] sched,workqueue: Use READ_ONCE()/WRITE_ONCE() for wake_cpu accesses
From: Tejun Heo
Date: Fri Mar 27 2026 - 13:06:08 EST
Hello,
On Fri, Mar 27, 2026 at 10:27:39AM +0100, Peter Zijlstra wrote:
> On Fri, Mar 27, 2026 at 03:30:07PM +0800, Yu Peng wrote:
> > task_struct->wake_cpu is used as a wake placement hint by scheduler code
> > and workqueue's non-strict affinity repatriation path.
> >
> > These accesses are intentionally lockless and stale values are tolerated,
> > affecting only wakeup placement.
>
> The scheduler usage isn't lockless. And I'm not at all sure why and how
> workqueue is poking at this stuff :/ It has no business poking at it.
Oh, you were involved in the discussion. It's workqueue using ->wake_cpu as
a way to implement opportunistic affinity at work boundaries as past history
doesn't mean anything at these boundaries.
https://lore.kernel.org/all/20230519001709.2563-1-tj@xxxxxxxxxx/
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?
Thanks.
--
tejun