From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752529AbdIWBdg (ORCPT ); Fri, 22 Sep 2017 21:33:36 -0400 Received: from smtprelay0195.hostedemail.com ([216.40.44.195]:55557 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752109AbdIWBde (ORCPT ); Fri, 22 Sep 2017 21:33:34 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1431:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2828:2915:3138:3139:3140:3141:3142:3353:3622:3743:3865:3866:3867:3868:3870:3871:3872:3873:3874:4031:4321:4605:5007:6119:7903:8603:10004:10400:10848:11232:11658:11914:12043:12555:12740:12760:12895:13019:13069:13161:13229:13311:13357:13439:13870:14096:14097:14181:14659:14721:21080:21324:21433:21434:21627:30012:30054:30060:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: sack58_3c09657c82215 X-Filterd-Recvd-Size: 3089 Message-ID: <1506130410.12311.50.camel@perches.com> Subject: Re: [PATCH] lib/lz4: make arrays static const, reduces object code size From: Joe Perches To: Arnd Bergmann Cc: Colin Ian King , Christophe JAILLET , Sven Schmidt <4sschmid@informatik.uni-hamburg.de>, Andrew Morton , kernel-janitors@vger.kernel.org, Linux Kernel Mailing List Date: Fri, 22 Sep 2017 18:33:30 -0700 In-Reply-To: References: <20170921221939.20820-1-colin.king@canonical.com> <5aab65d9-6da6-c770-b5aa-9edbdda31dec@wanadoo.fr> <250fe35e-77d3-a9c0-5613-ce1c65f4cb7f@canonical.com> <1506100881.12311.41.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-09-22 at 23:39 +0200, Arnd Bergmann wrote: > On Fri, Sep 22, 2017 at 9:17 PM, Arnd Bergmann wrote: > > On Fri, Sep 22, 2017 at 7:21 PM, Joe Perches wrote: > > > On Fri, 2017-09-22 at 09:48 +0200, Arnd Bergmann wrote: > > > > On Fri, Sep 22, 2017 at 1:11 AM, Colin Ian King > > > > text data bss dec hex filename > > > > 18220 176 0 18396 47dc build/tmp/lib/lz4/lz4_decompress-after.o > > > > 22297 0 0 22297 5719 build/tmp/lib/lz4/lz4_decompress-before.o > > > > > > Perhaps not so much a gcc bug as an opportunity > > > for gcc to add an additional optimization. > > > > > > gcc would have to verify that the const array is > > > not initialized with some variable or argument like: > > > > > > int foo(int a) > > > { > > > const int array[] = {1, a}; > > > ... > > > } > > > > It depends. With a 10KB different in .text size, my guess is that this > > is a case where gcc does the right optimization in principle, but > > fails to do what was intended in some corner cases. > > I found the problem: "gcc -fsanitze=kernel-address --param asan-stack=1" > produces lots of expensive checks here with gcc-5 or higher. > > Disabling it makes a big difference: > > upstream: > gcc-7.0.0 --fsanitze=kernel-address --param asan-stack=1: 31789 bytes > gcc-7.0.0: 16535 bytes > > patched: > gcc-7.0.0 --fsanitze=kernel-address --param asan-stack=1: 20351 bytes > gcc-7.0.0: 14490 bytes I think you are looking at a different issue. There seems still a difference in size between current and Colin's patch in compiled object size. > Arnd