From: Steven Munroe <munroesj@linux.vnet.ibm.com>
To: Zack Weinberg <zackw@panix.com>
Cc: Florian Weimer <fweimer@redhat.com>,
Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>,
GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] powerpc: Use aligned stores in memset
Date: Tue, 12 Sep 2017 13:57:00 -0000 [thread overview]
Message-ID: <1505224647.12360.24.camel@oc7878010663> (raw)
In-Reply-To: <CAKCAbMhj5TE4sy7nqKEYAR8yWfY7Dv5HyzTZHPQQH3RKDozeZg@mail.gmail.com>
On Tue, 2017-09-12 at 08:18 -0400, Zack Weinberg wrote:
> On Tue, Sep 12, 2017 at 6:30 AM, Florian Weimer <fweimer@redhat.com> wrote:
> >
> > I could not find the manual which has the requirement that the mem*
> > functions do not use unaligned accesses. Unless they are worded in a
> > very peculiar way, right now, the GCC/glibc combination does not comply
> > with a requirement that memset & Co. can be used for device memory access.
>
> mem* are required to behave as-if they access memory as an array of
> unsigned char. Therefore it is valid to give them arbitrarily
> (un)aligned pointers. The C abstract machine doesn't specifically
> contemplate the possibility of a CPU that can do unaligned word reads
> but maybe not to all memory addresses, but I would argue that if there
> is such a CPU, then mem* are obliged to cope with it.
>
> > ...the current glibc
> > implementation accesses locations which are outside the specified object
> > boundaries.
>
> I think that's technically a defect. Nothing in the C standard
> licenses it to do that; we just get away with it because, on the
> implementations to date, it's not observable (unless you go past the
> end of a page, which you'll note there are a bunch of tests to ensure
> we don't do). If an over-read by a single byte is observable, then
> mem* is not allowed to do that.
>
Also a bit of over reaction.
As long a the library routine does no cause a visible artifact (segfault
or alignment check) aligned access before or after the requested start
address and length is an optimization.
For example accessing the source at offset 3 and length 10 with an
aligned quadword load is Ok as long I clear the leading and trailing
bytes.
But attempting to store 7 bytes within a quadword by merging bytes in a
register and storing the whole quadword would violate single copy
atomicity and is not allowed.
> zw
>
next prev parent reply other threads:[~2017-09-12 13:57 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 5:13 Rajalakshmi Srinivasaraghavan
2017-08-18 6:21 ` Florian Weimer
2017-08-18 6:51 ` Rajalakshmi Srinivasaraghavan
2017-08-18 9:10 ` Florian Weimer
2017-08-18 12:13 ` Adhemerval Zanella
2017-09-12 10:30 ` Florian Weimer
2017-09-12 12:18 ` Zack Weinberg
2017-09-12 13:57 ` Steven Munroe [this message]
2017-09-12 14:37 ` Joseph Myers
2017-09-12 15:06 ` Zack Weinberg
2017-09-12 17:09 ` Florian Weimer
2017-09-12 13:38 ` Steven Munroe
2017-09-12 14:08 ` Florian Weimer
2017-09-12 14:16 ` Steven Munroe
2017-09-12 17:04 ` Florian Weimer
2017-09-12 19:21 ` Steven Munroe
2017-09-12 19:45 ` Florian Weimer
2017-09-12 20:25 ` Steven Munroe
2017-09-13 13:12 ` Tulio Magno Quites Machado Filho
2017-09-18 13:54 ` Florian Weimer
2017-10-03 18:29 ` Adhemerval Zanella
2017-10-05 12:13 ` Rajalakshmi Srinivasaraghavan
2017-11-08 18:52 ` Tulio Magno Quites Machado Filho
2017-12-08 19:52 ` [PATCHv2] powerpc: POWER8 memcpy optimization for cached memory Tulio Magno Quites Machado Filho
2017-12-08 20:06 ` Florian Weimer
2017-12-11 12:44 ` Tulio Magno Quites Machado Filho
2017-12-11 20:09 ` Adhemerval Zanella
2017-12-10 7:11 ` Rajalakshmi Srinivasaraghavan
2017-12-11 19:48 ` Tulio Magno Quites Machado Filho
2017-08-18 6:25 ` [PATCH] powerpc: Use aligned stores in memset Andrew Pinski
2017-08-21 2:20 ` Tulio Magno Quites Machado Filho
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=1505224647.12360.24.camel@oc7878010663 \
--to=munroesj@linux.vnet.ibm.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=raji@linux.vnet.ibm.com \
--cc=zackw@panix.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 read-only IMAP folder(s) and NNTP newsgroup(s).