The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] sched/topology: Avoid unsequenced accesses to jiffies in sd_init()
Date: Thu, 19 Nov 2026 15:41:29 -0700	[thread overview]
Message-ID: <20261119224129.GA1660308@ax162> (raw)
In-Reply-To: <20261118094726.GM1813469@noisy.programming.kicks-ass.net>

On Wed, Nov 18, 2026 at 10:47:26AM +0100, Peter Zijlstra wrote:
> Could it be fixed by adding an explicit cast? Say:
> 
> 	.last_balance = (unsigned long)jiffies,

No because the accesses are still unsequenced even with the cast.

> Also, the C people are daft and want to get rid of volatile,
> irrespective of its many uses, so perhaps this is a subtle act of
> sabotage or something and we should get clang to revert this weirdness.

I won't comment on C standards politics since that's far out of my
league but I don't think it is wrong or weird for clang to warn here
(this went through a lot of review upstream). I would argue it is
genuinely trying to be helpful here since as David points out down
thread, there is a potential consistency issue here. Either you want the
same value for jiffies in the initializer (in which case, use a variable
to read the value once then use that in the initializer like this patch
does) or you don't care about potentially getting two different values
from each read of jiffies (in which case, move each access out of the
initializer like my v1 did) but the way the code is currently written,
it is not clear what behavior is desirable.

I am happy to try and make the commit message better in whatever way you
see fit.

-- 
Cheers,
Nathan

  reply	other threads:[~2026-11-19 22:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 20:55 [PATCH v2] sched/topology: Avoid unsequenced accesses to jiffies in sd_init() Nathan Chancellor
2026-11-17  0:39 ` Nick Desaulniers
2026-11-17 18:30 ` Peter Zijlstra
2026-11-17 18:39   ` Nick Desaulniers
2026-11-18  7:57     ` Nathan Chancellor
2026-11-18  9:47     ` Peter Zijlstra
2026-11-19 22:41       ` Nathan Chancellor [this message]
2026-11-18 10:03     ` David Laight

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=20261119224129.GA1660308@ax162 \
    --to=nathan@kernel.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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