From: Peter Zijlstra <peterz@infradead.org>
To: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH v1] perf build: Revert "enable -fno-strict-aliasing"
Date: Sat, 14 Mar 2026 00:30:55 +0100 [thread overview]
Message-ID: <20260313233055.GD2872@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAP-5=fXneV5fawTncLH13p_8-9OAxwpTERXk5ty=8m0s8U1ANg@mail.gmail.com>
On Thu, Sep 04, 2025 at 02:33:24PM -0700, Ian Rogers wrote:
> On Thu, Sep 4, 2025 at 1:59 PM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Thu, Sep 04, 2025 at 10:41:17PM +0200, Peter Zijlstra wrote:
> > > On Thu, Sep 04, 2025 at 10:44:30AM -0700, Ian Rogers wrote:
> > > > This reverts commit 55a18d2f3ff7 ("perf build: enable
> > > > -fno-strict-aliasing"). With (get|put)_unaligned_* using memcpy
> > > > -fno-strict-aliasing is no longer necessary as memcpys are assumed to
> > > > possibly alias.
> > >
> > > I don't think this is a good idea. Much of tools/ includes kernel
> > > headers and various kernel code, all of which is written in the
> > > understanding that this (often called broken) C language feature does
> > > not exist.
> > >
> > > As such, I would strongly suggest all of tools is built with
> > > -fno-strict-aliasing.
> >
> > Similarly I would strongly suggest having -fwrapv on all code that
> > includes kernel headers.
>
> Given we can build and run with sanitizers, ubsan covers fwrapv and
> type sanitizer is in development to detect strict aliasing violations.
> So we can have correct code without hamstringing the compiler.
>
> There's lots wrong with C, a particular favorite of mine is:
> ```
> void foo(const int *p) {
> int x = *p;
> if (x == 10) {
> mutex_lock(&global_mutex);
> if (x == 10) {
> // Code should always run ...
> ```
> The compiler can save registers by re-loading from p in the code
> above, meaning the second "if" may not always run.
mutex_lock() should imply barrier() which should very much inhibit this.
prev parent reply other threads:[~2026-03-13 23:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 17:44 [PATCH v1] perf build: Revert "enable -fno-strict-aliasing" Ian Rogers
2025-09-04 20:41 ` Peter Zijlstra
2025-09-04 20:59 ` Peter Zijlstra
2025-09-04 21:33 ` Ian Rogers
2026-03-12 20:58 ` Ian Rogers
2026-03-13 21:17 ` Namhyung Kim
2026-03-20 22:42 ` [PATCH v2] " Ian Rogers
2026-03-21 2:49 ` Ian Rogers
2026-03-13 23:30 ` Peter Zijlstra [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=20260313233055.GD2872@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ebiggers@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.