Re: [PATCH v2] workqueue: annotate racy p->wake_cpu accesses in kick_pool_pick()

From: Breno Leitao

Date: Thu Aug 13 2026 - 07:53:43 EST


Hello Tejun,

On Wed, Aug 12, 2026 at 08:25:28AM -1000, Tejun Heo wrote:
> On Tue, Aug 11, 2026 at 02:55:56AM -0700, Breno Leitao wrote:
> > The race is harmless, this patch only acknowledge that this is racy and
> > it is fine, silenting KCSAN.
>
> Can you say why it's harmless? wake_cpu is a best-effort placement hint.
> Every writer stores a valid CPU id and the wakeup path validates it
> through select_task_rq(), so a racy value only affects where the worker
> wakes up. Also, s/acknowledge/acknowledges/ and s/silenting/silencing/.

Ack. I will spell that out in v3: wake_cpu is only a placement hint,
every writer stores a valid CPU id, and select_task_rq() validates it at
wakeup, so a stale value _at most_ wakes the worker on a suboptimal CPU.

> > - if (!pool->attrs->affn_strict &&
> > - !cpumask_test_cpu(p->wake_cpu, pool->attrs->__pod_cpumask)) {
> > + bool wake_cpu_in_pod = cpumask_test_cpu(READ_ONCE(p->wake_cpu),
> > + pool->attrs->__pod_cpumask);
> > +
> > + if (!pool->attrs->affn_strict && !wake_cpu_in_pod) {
>
> The hoist drops the !affn_strict short-circuit and adds a declaration
> after statements. Can you keep the test inline in the condition?
>
> if (!pool->attrs->affn_strict &&
> !cpumask_test_cpu(READ_ONCE(p->wake_cpu),
> pool->attrs->__pod_cpumask)) {

Ack. It also keeps per-CPU pools (affn_strict) from paying for a mask
test they used to skip.

Thanks for the review,
--breno