The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
	linux-kernel@vger.kernel.org,  kernel-team@meta.com,
	Bradley Morgan <include@grrlz.net>
Subject: Re: [PATCH v2] workqueue: annotate racy p->wake_cpu accesses in kick_pool_pick()
Date: Thu, 13 Aug 2026 04:52:42 -0700	[thread overview]
Message-ID: <an2vkepFibHV19R5@gmail.com> (raw)
In-Reply-To: <90e44e95a0b95c74dfb260a335ab0fea@kernel.org>

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

      reply	other threads:[~2026-08-13 11:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  9:55 [PATCH v2] workqueue: annotate racy p->wake_cpu accesses in kick_pool_pick() Breno Leitao
2026-08-12 18:25 ` Tejun Heo
2026-08-13 11:52   ` Breno Leitao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=an2vkepFibHV19R5@gmail.com \
    --to=leitao@debian.org \
    --cc=include@grrlz.net \
    --cc=jiangshanlai@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox