[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y1fHn1mFeVPn7O3+@leoy-huanghe.lan>
Date: Tue, 25 Oct 2022 19:25:19 +0800
From: Leo Yan <leo.yan@...aro.org>
To: David Laight <David.Laight@...lab.com>
Cc: 'Ian Rogers' <irogers@...gle.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>,
German Gomez <german.gomez@....com>,
"linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH v1 0/8] Update to C11, fix signal undefined behavior
On Tue, Oct 25, 2022 at 10:36:16AM +0000, David Laight wrote:
[...]
> > 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.
One case that it might break atomicity for the data with int type,
I.e. on Arm CPU when CPU access data without alignment, then it
cannot promise atomicity. I am not sure if the data with int type
will be always compiled with 4-byte alignment, if it's packed
without alignment then sig_atomic_t is still required.
Clarify that I don't have deep understanding for compiler, so sorry
if I introduce any noise.
Thanks,
Leo
> 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)
Powered by blists - more mailing lists