linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Boqun Feng <boqun.feng@gmail.com>, Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Documentation/atomic_t: Clarify signed vs unsigned
Date: Mon, 11 Feb 2019 13:13:02 -0800	[thread overview]
Message-ID: <20190211211302.GT4240@linux.ibm.com> (raw)
In-Reply-To: <20190211172800.GA2994@fuggles.cambridge.arm.com>

On Mon, Feb 11, 2019 at 05:28:00PM +0000, Will Deacon wrote:
> On Mon, Feb 11, 2019 at 06:09:43PM +0100, Peter Zijlstra wrote:
> > 
> > Clarify the whole signed vs unsigned issue for atomic_t.
> > 
> > There has been enough confusion on this topic to warrant a few explicit
> > words I feel.
> > 
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> >  Documentation/atomic_t.txt | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/Documentation/atomic_t.txt b/Documentation/atomic_t.txt
> > index 913396ac5824..dca3fb0554db 100644
> > --- a/Documentation/atomic_t.txt
> > +++ b/Documentation/atomic_t.txt
> > @@ -56,6 +56,23 @@ The 'full' API consists of (atomic64_ and atomic_long_ prefixes omitted for
> >    smp_mb__{before,after}_atomic()
> >  
> >  
> > +TYPES (signed vs unsigned)
> > +-----
> > +
> > +While atomic_t, atomic_long_t and atomic64_t use int, long and s64
> > +respectively (for hysterical raisins), the kernel uses -fno-strict-overflow
> > +(which implies -fwrapv) and defines signed overflow to behave like
> > +2s-complement.
> > +
> > +Therefore, an explicitly unsigned variant of the atomic ops is strictly
> > +unnecessary and we can simply cast, there is no UB.
> > +
> > +There was a bug in UBSAN prior to GCC-8 that would generate UB warnings for
> > +signed types.
> > +
> > +With this we also conform to the C/C++ _Atomic behaviour and things like
> > +P1236R1.
> > +
> 
> Acked-by: Will Deacon <will.deacon@arm.com>

Queued with Will's ack, thank you both!

								Thanx, Paul


  reply	other threads:[~2019-02-11 21:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11 17:09 [PATCH] Documentation/atomic_t: Clarify signed vs unsigned Peter Zijlstra
2019-02-11 17:28 ` Will Deacon
2019-02-11 21:13   ` Paul E. McKenney [this message]
2019-02-12  1:03 ` Boqun Feng
2019-02-12  1:29   ` Paul E. McKenney
2019-02-13  7:54 ` Ingo Molnar

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=20190211211302.GT4240@linux.ibm.com \
    --to=paulmck@linux.ibm.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.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;
as well as URLs for NNTP newsgroup(s).