From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752263AbcBEH2S (ORCPT ); Fri, 5 Feb 2016 02:28:18 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36544 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750789AbcBEH2R (ORCPT ); Fri, 5 Feb 2016 02:28:17 -0500 Date: Fri, 5 Feb 2016 08:28:12 +0100 From: Ingo Molnar To: Denys Vlasenko Cc: Thomas Graf , Peter Zijlstra , David Rientjes , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] force inlining of some byteswap operations Message-ID: <20160205072812.GA28210@gmail.com> References: <1454615136-32308-1-git-send-email-dvlasenk@redhat.com> <1454615136-32308-2-git-send-email-dvlasenk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1454615136-32308-2-git-send-email-dvlasenk@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Denys Vlasenko wrote: > Sometimes gcc mysteriously doesn't inline > very small functions we expect to be inlined. See > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66122 > > With this .config: > http://busybox.net/~vda/kernel_config_OPTIMIZE_INLINING_and_Os, > the following functions get deinlined many times. > Examples of disassembly: > > (12 copies, 51 calls): > 66 8b 07 mov (%rdi),%ax > 55 push %rbp > 48 89 e5 mov %rsp,%rbp > 86 e0 xchg %ah,%al > 5d pop %rbp > c3 retq > > (12 copies, 135 calls): > 8b 07 mov (%rdi),%eax > 55 push %rbp > 48 89 e5 mov %rsp,%rbp > 0f c8 bswap %eax > 5d pop %rbp > c3 retq > > (2 copies, 20 calls): > 48 8b 07 mov (%rdi),%rax > 55 push %rbp > 48 89 e5 mov %rsp,%rbp > 48 0f c8 bswap %rax > 5d pop %rbp > c3 retq > > <__swab16p> (16 copies, 146 calls): > 55 push %rbp > 89 f8 mov %edi,%eax > 86 e0 xchg %ah,%al > 48 89 e5 mov %rsp,%rbp > 5d pop %rbp > c3 retq > > <__swab32p> (43 copies, ~560 calls): > 55 push %rbp > 89 f8 mov %edi,%eax > 0f c8 bswap %eax > 48 89 e5 mov %rsp,%rbp > 5d pop %rbp > c3 retq > > <__swab64p> (21 copies, 119 calls): > 55 push %rbp > 48 89 f8 mov %rdi,%rax > 48 0f c8 bswap %rax > 48 89 e5 mov %rsp,%rbp > 5d pop %rbp > c3 retq > > <__swab32s> (6 copies, 47 calls): > 8b 07 mov (%rdi),%eax > 55 push %rbp > 48 89 e5 mov %rsp,%rbp > 0f c8 bswap %eax > 89 07 mov %eax,(%rdi) > 5d pop %rbp > c3 retq > > This patch fixes this via s/inline/__always_inline/. > Code size decrease after the patch is ~4.5k: > > text data bss dec hex filename > 92202377 20826112 36417536 149446025 8e85d89 vmlinux > 92197848 20826112 36417536 149441496 8e84bd8 vmlinux5_swap_after Acked-by: Ingo Molnar Thanks, Ingo