linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Ian Rogers' <irogers@google.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>,
	German Gomez <german.gomez@arm.com>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Stephane Eranian <eranian@google.com>
Subject: RE: [PATCH v1 0/8] Update to C11, fix signal undefined behavior
Date: Tue, 25 Oct 2022 10:36:16 +0000	[thread overview]
Message-ID: <7b0769b35f124869b4e30ddcc20a5985@AcuMS.aculab.com> (raw)
In-Reply-To: <CAP-5=fVGicObnifnUzDXjbkGOVtmNaLKcfqpGeTwnFw2zsOuDQ@mail.gmail.com>

From: Ian Rogers
> Sent: 24 October 2022 19:12
> 
> On Mon, Oct 24, 2022 at 10:59 AM Ian Rogers <irogers@google.com> wrote:
> >
> > On Mon, Oct 24, 2022 at 10:51 AM Arnaldo Carvalho de Melo
> > <acme@kernel.org> wrote:
> > >
> > > Em Mon, Oct 24, 2022 at 10:35:15AM -0700, Ian Rogers escreveu:
> > > > The use of C11 is mainstream in the kernel [1]. There was some
> > > > confusion on volatile and signal handlers in [2]. Switch to using
> > > > stdatomic.h (requires C11) and sig_atomic_t as per [3]. Thanks to Leo
> > > > Yan <leo.yan@linaro.org> for the suggestions.
> > > >
> > > > [1] https://lore.kernel.org/lkml/CAHk-=whWbENRz-
> vLY6vpESDLj6kGUTKO3khGtVfipHqwewh2HQ@mail.gmail.com/
> > > > [2] https://lore.kernel.org/lkml/20221024011024.462518-1-irogers@google.com/
> > > > [3] https://wiki.sei.cmu.edu/confluence/display/c/SIG31-
> C.+Do+not+access+shared+objects+in+signal+handlers
> > >
> > > I think I'll apply this to perf/core, i.e. for 6.3, ok?
> >
> > Sounds good to me. 6.3 or 6.2? I suspect there is more cleanup like
> > this and to the iterators (from C11) that can be done.
> >
> > Thanks,
> > Ian
> 
> So I noticed a few changes missing #include-ing stdatomic.h and
> sig_atomic_t is actually in signal.h. I'm not sure we need the C11
> change then, but it seems like the right thing to do anyway. I'll do a
> v2 to drop the unneeded (currently) include of stdatomic.h.

While the C standard requires you use sig_atomic_t (to avoid
wider RMW being done for writes) the kernel very much requires
that volatiles accesses are atomic.
So the compilers used will do that even when the C standard
would allow them to do otherwise.

Pretty much the last mainstream cpu that couldn't do atomic
byte writes was an old alpha.

So for anything that Linux is going to run on these changes
aren't really needed.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2022-10-25 10:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24 17:35 [PATCH v1 0/8] Update to C11, fix signal undefined behavior Ian Rogers
2022-10-24 17:35 ` [PATCH v1 1/8] perf build: Update to C standard to gnu11 Ian Rogers
2022-10-24 17:35 ` [PATCH v1 2/8] perf record: Use sig_atomic_t for signal handlers Ian Rogers
2022-10-24 17:35 ` [PATCH v1 3/8] perf daemon: Use sig_atomic_t to avoid UB Ian Rogers
2022-10-24 17:35 ` [PATCH v1 4/8] perf ftrace: " Ian Rogers
2022-10-24 17:35 ` [PATCH v1 5/8] perf session: Change type " Ian Rogers
2022-10-24 17:35 ` [PATCH v1 6/8] perf stat: Use sig_atomic_t " Ian Rogers
2022-10-24 17:35 ` [PATCH v1 7/8] perf top: " Ian Rogers
2022-10-24 17:35 ` [PATCH v1 8/8] perf trace: " Ian Rogers
2022-10-24 17:51 ` [PATCH v1 0/8] Update to C11, fix signal undefined behavior Arnaldo Carvalho de Melo
2022-10-24 17:59   ` Ian Rogers
2022-10-24 18:11     ` Ian Rogers
2022-10-25 10:36       ` David Laight [this message]
2022-10-25 11:25         ` Leo Yan
2022-10-24 19:36     ` Arnaldo Carvalho de Melo

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=7b0769b35f124869b4e30ddcc20a5985@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=eranian@google.com \
    --cc=german.gomez@arm.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --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 \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).