From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24404 invoked by alias); 15 Nov 2013 18:59:59 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 24390 invoked by uid 89); 15 Nov 2013 18:59:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RDNS_NONE,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Nov 2013 18:59:57 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAFIxkJR016951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 15 Nov 2013 13:59:47 -0500 Received: from [10.3.113.62] (ovpn-113-62.phx2.redhat.com [10.3.113.62]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAFIxiwP012893; Fri, 15 Nov 2013 13:59:45 -0500 Message-ID: <52866F20.6070505@redhat.com> Date: Fri, 15 Nov 2013 18:59:00 -0000 From: "Carlos O'Donell" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Steve Ellcey , "Carlos O'Donell" CC: "libc-ports@sourceware.org" Subject: Re: [Patch, mips] Faster strcmp for mips References: <1384464221.2484.86.camel@ubuntu-sellcey> <1384541575.2484.110.camel@ubuntu-sellcey> In-Reply-To: <1384541575.2484.110.camel@ubuntu-sellcey> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00023.txt.bz2 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 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.