public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Carlos O'Donell" <carlos@redhat.com>
To: Steve Ellcey <sellcey@mips.com>,
	       "Carlos O'Donell" <carlos@systemhalted.org>
Cc: "libc-ports@sourceware.org" <libc-ports@sourceware.org>
Subject: Re: [Patch, mips] Faster strcmp for mips
Date: Fri, 15 Nov 2013 18:59:00 -0000	[thread overview]
Message-ID: <52866F20.6070505@redhat.com> (raw)
In-Reply-To: <1384541575.2484.110.camel@ubuntu-sellcey>

On 11/15/2013 01:52 PM, Steve Ellcey wrote:
> On Fri, 2013-11-15 at 13:47 -0500, Carlos O'Donell wrote:
>> On Thu, Nov 14, 2013 at 4:23 PM, Steve Ellcey <sellcey@mips.com> wrote:
>>> This means it could be loading bytes beyond the end of the strings being
>>> compared but it looks like other architecture specific strcmp functions
>>> are also doing this optimization and the newlib version of strcmp also does
>>> this.
>>
>> I thought that doing so was dangerous? I'm pretty sure we've been trying
>> to fix such "load bytes beyond the end of the string" issues because you
>> could have a string that straddles a page boundary with the next page
>> unmapped and such an optimized routine would fault on a read from the
>> unmapped page.
>>
>> How do you plan to fix that?
>>
>> Cheers,
>> Carlos.
> 
> I think the assumption has been that if an aligned word contains at
> least one byte of the string, it is OK to read that entire word.  I
> don't think a single aligned word (4 or 8 bytes depending on the
> architecture) can straddle a page boundary.  If the word was unaligned,
> then I think it could straddle a page boundary and you could get into
> trouble.

That is obviously correct because the aligned word itself wouldn't
cross the the page boundary. My only comment here is that reading
past the end of the string is a dangerous operation unless you take
care to ensure it doesn't cross a page boundary. Given that you've
clarified that it's only ever a an aligned word load, that can't
possibly cross a page boundary so you're safe.

Sorry for the noise.

Cheers,
Carlos.

  reply	other threads:[~2013-11-15 18:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14 21:25 Steve Ellcey
2013-11-14 23:14 ` Ondřej Bílka
2013-11-15 18:21   ` Steve Ellcey
2013-11-15 19:02     ` Ondřej Bílka
2013-11-18 23:50       ` Steve Ellcey
2013-11-19  2:32         ` Ondřej Bílka
2013-11-15 18:48 ` Carlos O'Donell
2013-11-15 18:53   ` Steve Ellcey
2013-11-15 18:59     ` Carlos O'Donell [this message]
2015-02-19  7:25 ` Matt Turner
2015-02-19 18:12   ` Steve Ellcey

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=52866F20.6070505@redhat.com \
    --to=carlos@redhat.com \
    --cc=carlos@systemhalted.org \
    --cc=libc-ports@sourceware.org \
    --cc=sellcey@mips.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).