This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Re: [Patch, mips] Faster strcmp for mips
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Steve Ellcey <sellcey at mips dot com>, "Carlos O'Donell" <carlos at systemhalted dot org>
- Cc: "libc-ports at sourceware dot org" <libc-ports at sourceware dot org>
- Date: Fri, 15 Nov 2013 13:59:44 -0500
- Subject: Re: [Patch, mips] Faster strcmp for mips
- Authentication-results: sourceware.org; auth=none
- References: <1384464221 dot 2484 dot 86 dot camel at ubuntu-sellcey> <CAE2sS1jDnPP2hKn6u-nnvAnKgwQrrVUsDUrGWjyUu8+EBXZjgA at mail dot gmail dot com> <1384541575 dot 2484 dot 110 dot camel at 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.