public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Cc: "paulmck@linux.ibm.com" <paulmck@linux.ibm.com>,
	Will Deacon <Will.Deacon@arm.com>,
	arcml <linux-snps-arc@lists.infradead.org>,
	lkml <linux-kernel@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>
Subject: Re: single copy atomicity for double load/stores on 32-bit systems
Date: Fri, 31 May 2019 10:23:22 +0200	[thread overview]
Message-ID: <20190531082322.GI2623@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <C2D7FE5348E1B147BCA15975FBA2307501A2520D9C@us01wembx1.internal.synopsys.com>

On Thu, May 30, 2019 at 07:16:36PM +0000, Vineet Gupta wrote:
> On 5/30/19 11:55 AM, Paul E. McKenney wrote:
> >
> >> I'm not sure how to interpret "natural alignment" for the case of double
> >> load/stores on 32-bit systems where the hardware and ABI allow for 4 byte
> >> alignment (ARCv2 LDD/STD, ARM LDRD/STRD ....)
> >>
> >> I presume (and the question) that lkmm doesn't expect such 8 byte load/stores to
> >> be atomic unless 8-byte aligned
> > I would not expect 8-byte accesses to be atomic on 32-bit systems unless
> > some special instruction was in use.  But that usually means special
> > intrinsics or assembly code.
> 
> Thx for confirming.
> 
> In cases where we *do* expect the atomicity, it seems there's some existing type
> checking but isn't water tight.
> e.g.
> 
> #define __smp_load_acquire(p)                        \
> ({                                    \
>     typeof(*p) ___p1 = READ_ONCE(*p);                \
>     compiletime_assert_atomic_type(*p);                \
>     __smp_mb();                            \
>     ___p1;                                \
> })
> 
> #define compiletime_assert_atomic_type(t)                \
>     compiletime_assert(__native_word(t),                \
>         "Need native word sized stores/loads for atomicity.")
> 
> #define __native_word(t) \
>     (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
>      sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
> 
> 
> So it won't catch the usage of 4 byte aligned long long which gcc targets to
> single double load instruction.

Yes, we didn't do those because that would result in runtime overhead.

We assume natural alignment for any type the hardware can do.

  parent reply	other threads:[~2019-05-31  8:23 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 18:22 single copy atomicity for double load/stores on 32-bit systems Vineet Gupta
2019-05-30 18:22 ` Vineet Gupta
2019-05-30 18:53 ` Paul E. McKenney
2019-05-30 18:53   ` Paul E. McKenney
2019-05-30 19:16   ` Vineet Gupta
2019-05-30 19:16     ` Vineet Gupta
2019-05-31  8:23     ` Peter Zijlstra [this message]
2019-05-31  8:23       ` Peter Zijlstra
2019-05-31  8:25   ` Peter Zijlstra
2019-05-31  8:25     ` Peter Zijlstra
2019-05-31  8:21 ` Peter Zijlstra
2019-05-31  8:21   ` Peter Zijlstra
2019-06-03 18:08   ` Vineet Gupta
2019-06-03 18:08     ` Vineet Gupta
2019-06-03 20:13     ` Paul E. McKenney
2019-06-03 20:13       ` Paul E. McKenney
2019-06-03 21:59       ` Vineet Gupta
2019-06-03 21:59         ` Vineet Gupta
2019-06-04  7:41       ` Geert Uytterhoeven
2019-06-04  7:41         ` Geert Uytterhoeven
2019-06-06  9:43         ` Paul E. McKenney
2019-06-06  9:43           ` Paul E. McKenney
2019-06-06  9:53           ` Geert Uytterhoeven
2019-06-06  9:53             ` Geert Uytterhoeven
2019-06-06 16:34           ` David Laight
2019-06-06 16:34             ` David Laight
2019-06-06 21:17             ` Paul E. McKenney
2019-06-06 21:17               ` Paul E. McKenney
2019-06-03 18:43   ` Vineet Gupta
2019-06-03 18:43     ` Vineet Gupta
2019-07-01 20:05   ` Vineet Gupta
2019-07-01 20:05     ` Vineet Gupta
2019-07-02 10:46     ` Will Deacon
2019-07-02 10:46       ` Will Deacon
2019-05-31  9:41 ` David Laight
2019-05-31  9:41   ` David Laight
2019-05-31 11:44   ` Paul E. McKenney
2019-05-31 11:44     ` Paul E. McKenney
2019-06-03 18:44   ` Vineet Gupta
2019-06-03 18:44     ` Vineet Gupta

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=20190531082322.GI2623@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=Will.Deacon@arm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=paulmck@linux.ibm.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