From: Peter Zijlstra <peterz@infradead.org>
To: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: David Laight <David.Laight@ACULAB.COM>,
"linux-snps-arc@lists.infradead.org"
<linux-snps-arc@lists.infradead.org>,
Arnd Bergmann <arnd.bergmann@linaro.org>,
Vineet Gupta <vineet.gupta1@synopsys.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH] ARC: Explicitly set ARCH_SLAB_MINALIGN = 8
Date: Thu, 14 Feb 2019 12:08:13 +0100 [thread overview]
Message-ID: <20190214110813.GK32494@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <4881796E12491D4BB15146FE0209CE64681DB122@DE02WEMBXB.internal.synopsys.com>
On Thu, Feb 14, 2019 at 10:44:49AM +0000, Alexey Brodkin wrote:
> > On Wed, Feb 13, 2019 at 03:23:36PM -0800, Vineet Gupta wrote:
> > > On 2/13/19 4:56 AM, Peter Zijlstra wrote:
> > > >
> > > > Personally I think u64 and company should already force natural
> > > > alignment; but alas.
> > >
> > > But there is an ISA/ABI angle here too. e.g. On 32-bit ARC, LDD (load double) is
> > > allowed to take a 32-bit aligned address to load a register pair. Thus all u64
> > > need not be 64-bit aligned (unless attribute aligned 8 etc) hence the relaxation
> > > in ABI (alignment of long long is 4). You could certainly argue that we end up
> > > undoing some of it anyways by defining things like ARCH_KMALLOC_MINALIGN to 8, but
> > > still...
> >
> > So what happens if the data is then split across two cachelines; will a
> > STD vs LDD still be single-copy-atomic? I don't _think_ we rely on that
> > for > sizeof(unsigned long), with the obvious exception of atomic64_t,
> > but yuck...
>
> STD & LDD are simple store/load instructions so there's no problem for
> their 64-bit data to be from 2 subsequent cache lines as well as 2 pages
> (if we're that unlucky). Or you mean something else?
u64 x;
WRITE_ONCE(x, 0x1111111100000000);
WRITE_ONCE(x, 0x0000000011111111);
vs
t = READ_ONCE(x);
is t allowed to be 0x1111111111111111 ?
If the data is split between two cachelines, the hardware must do
something very funny to avoid that.
single-copy-atomicity requires that to never happen; IOW no load or
store tearing. You must observe 'whole' values, no mixing.
Linux requires READ_ONCE()/WRITE_ONCE() to be single-copy-atomic for
<=sizeof(unsigned long) and atomic*_read()/atomic*_set() for all atomic
types. Your atomic64_t alignment should ensure this is so.
So while I think we're fine, I do find hardware instructions that tear
yuck (yah, I know, x86...)
> > So even though it is allowed by the chip; does it really make sense to
> > use this?
>
> It gives performance benefits when dealing with either 64-bit or even
> larger buffers, see how we use it in our string routines like here [1].
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/lib/memset-archs.S#n81
That doesn't require the ABI alignment crud.
next prev parent reply other threads:[~2019-02-14 11:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 10:55 [PATCH] ARC: Explicitly set ARCH_SLAB_MINALIGN = 8 Alexey Brodkin
2019-02-12 17:17 ` Vineet Gupta
2019-02-12 17:30 ` David Laight
2019-02-12 17:45 ` Vineet Gupta
2019-02-13 12:56 ` Peter Zijlstra
2019-02-13 14:13 ` David Laight
2019-02-13 23:23 ` Vineet Gupta
2019-02-14 8:50 ` Alexey Brodkin
2019-02-14 10:28 ` Peter Zijlstra
2019-02-15 1:34 ` Vineet Gupta
2019-02-18 8:53 ` Alexey Brodkin
2019-02-19 23:30 ` Vineet Gupta
2019-02-14 10:31 ` Peter Zijlstra
2019-02-14 10:44 ` Alexey Brodkin
2019-02-14 11:08 ` Peter Zijlstra [this message]
2019-02-14 12:05 ` Alexey Brodkin
2019-02-14 12:24 ` Peter Zijlstra
2019-02-14 14:14 ` David Laight
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=20190214110813.GK32494@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=David.Laight@ACULAB.COM \
--cc=alexey.brodkin@synopsys.com \
--cc=arnd.bergmann@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=stable@vger.kernel.org \
--cc=vineet.gupta1@synopsys.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).