From patchwork Wed Dec 16 04:42:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11976413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2465EC4361B for ; Wed, 16 Dec 2020 04:42:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C758F23124 for ; Wed, 16 Dec 2020 04:42:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C758F23124 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 656998D0006; Tue, 15 Dec 2020 23:42:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 608066B0070; Tue, 15 Dec 2020 23:42:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 544ED8D0006; Tue, 15 Dec 2020 23:42:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 3DADE6B006E for ; Tue, 15 Dec 2020 23:42:48 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F3CF7824999B for ; Wed, 16 Dec 2020 04:42:47 +0000 (UTC) X-FDA: 77597900016.14.fly72_1907db227429 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id CD82318229837 for ; Wed, 16 Dec 2020 04:42:47 +0000 (UTC) X-HE-Tag: fly72_1907db227429 X-Filterd-Recvd-Size: 3434 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 04:42:47 +0000 (UTC) Date: Tue, 15 Dec 2020 20:42:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1608093766; bh=4Wl9mgxOgHzG0TK/Tzgh+6lCJN38AjG2Gfv+hjDpv1k=; h=From:To:Subject:In-Reply-To:From; b=UoB3NNN2yrzNv66YMoU+Z/x8KQhS4j7/KB/DYRVnpL8dWDAqHZTsNqTy+Z5cfavXm nvissiqIgHRNNy3Vwv9ajp6jT7f+fPbYkW1N8tb7e2Ma8yG0v61ePjnbWyEqEYSRTp rHerlCafhxiBfj/L4lLG90EVkF4yXpoHVkSgOMMA= From: Andrew Morton To: akpm@linux-foundation.org, arnd@arndb.de, christophe.leroy@csgroup.eu, joel@jms.id.au, linux-mm@kvack.org, mm-commits@vger.kernel.org, segher@kernel.crashing.org, torvalds@linux-foundation.org, yamada.masahiro@socionext.com Subject: [patch 08/95] asm-generic: force inlining of get_order() to work around gcc10 poor decision Message-ID: <20201216044245.gdQ1_1QzT%akpm@linux-foundation.org> In-Reply-To: <20201215204156.f05ec694b907845bcfab5c44@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Subject: asm-generic: force inlining of get_order() to work around gcc10 poor decision When building mpc885_ads_defconfig with gcc 10.1, the function get_order() appears 50 times in vmlinux: [linux]# ppc-linux-objdump -x vmlinux | grep get_order | wc -l 50 [linux]# size vmlinux text data bss dec hex filename 3842620 675624 135160 4653404 47015c vmlinux In the old days, marking a function 'static inline' was forcing GCC to inline, but since commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly") GCC may decide to not inline a function. It looks like GCC 10 is taking poor decisions on this. get_order() compiles into the following tiny function, occupying 20 bytes of text. 0000007c : 7c: 38 63 ff ff addi r3,r3,-1 80: 54 63 a3 3e rlwinm r3,r3,20,12,31 84: 7c 63 00 34 cntlzw r3,r3 88: 20 63 00 20 subfic r3,r3,32 8c: 4e 80 00 20 blr By forcing get_order() to be __always_inline, the size of text is reduced by 1940 bytes, that is almost twice the space occupied by 50 times get_order() [linux-powerpc]# size vmlinux text data bss dec hex filename 3840680 675588 135176 4651444 46f9b4 vmlinux Link: https://lkml.kernel.org/r/96c6172d619c51acc5c1c4884b80785c59af4102.1602949927.git.christophe.leroy@csgroup.eu Signed-off-by: Christophe Leroy Reviewed-by: Joel Stanley Cc: Segher Boessenkool Cc: Arnd Bergmann Cc: Masahiro Yamada Signed-off-by: Andrew Morton --- include/asm-generic/getorder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/asm-generic/getorder.h~asm-generic-force-inlining-of-get_order-to-work-around-gcc10-poor-decision +++ a/include/asm-generic/getorder.h @@ -26,7 +26,7 @@ * * The result is undefined if the size is 0. */ -static inline __attribute_const__ int get_order(unsigned long size) +static __always_inline __attribute_const__ int get_order(unsigned long size) { if (__builtin_constant_p(size)) { if (!size)