From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754449AbcHZWX0 (ORCPT ); Fri, 26 Aug 2016 18:23:26 -0400 Received: from smtprelay0146.hostedemail.com ([216.40.44.146]:40023 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753976AbcHZWXY (ORCPT ); Fri, 26 Aug 2016 18:23:24 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1539:1593:1594:1711:1714:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3351:3622:3866:3868:3871:3874:4321:5007:6119:7903:10004:10400:10848:11026:11473:11658:11783:11914:12043:12663:12740:13069:13311:13357:13439:13894:14180:14659:21080:30012:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: boy84_1d7c00c044c52 X-Filterd-Recvd-Size: 1469 Message-ID: <1472250201.4914.88.camel@perches.com> Subject: Re: [PATCH] smaller strlen() From: Joe Perches To: Alexey Dobriyan , akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Andi Kleen Date: Fri, 26 Aug 2016 15:23:21 -0700 In-Reply-To: <20160826200120.GA1852@p183.telecom.by> References: <20160826200120.GA1852@p183.telecom.by> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2016-08-26 at 23:01 +0300, Alexey Dobriyan wrote: > gcc prefers "*s++" style code for some reason, doesn't unroll loop > condition check once. Kernel strings are small but they aren't of 0 > length, so that additional branch was almost never taken. Hey Alexey. Is this gcc version specific? And I'm confused why there isn't an asm __HAVE_ARCH_STRLEN version x86_64 strlen like x86_32 or if __builtin_strlen() is or isn't used.  Maybe Andi Kleen knows/remembers (cc'd). > $ ./scripts/bloat-o-meter ../vmlinux-000 ../obj/vmlinux > strlen         30      26      -4 > strlcpy        71      64      -7 > strlcat       120      99     -21 > > strlcpy() and strlcat() are collateral damage :^)