From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756168AbbIYMXc (ORCPT ); Fri, 25 Sep 2015 08:23:32 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39368 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756071AbbIYMX3 (ORCPT ); Fri, 25 Sep 2015 08:23:29 -0400 Date: Fri, 25 Sep 2015 05:22:29 -0700 From: tip-bot for Denys Vlasenko Message-ID: Cc: linux-kernel@vger.kernel.org, dvlasenk@redhat.com, tglx@linutronix.de, brgerst@gmail.com, mingo@kernel.org, torvalds@linux-foundation.org, hpa@zytor.com, luto@amacapital.net, bp@alien8.de, peterz@infradead.org Reply-To: linux-kernel@vger.kernel.org, dvlasenk@redhat.com, mingo@kernel.org, brgerst@gmail.com, tglx@linutronix.de, luto@amacapital.net, bp@alien8.de, peterz@infradead.org, hpa@zytor.com, torvalds@linux-foundation.org In-Reply-To: <1443096149-27291-1-git-send-email-dvlasenk@redhat.com> References: <1443096149-27291-1-git-send-email-dvlasenk@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/asm: Force inlining of cpu_relax() Git-Commit-ID: 0b101e62afe626ecae60173f92f1e0ec72151653 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0b101e62afe626ecae60173f92f1e0ec72151653 Gitweb: http://git.kernel.org/tip/0b101e62afe626ecae60173f92f1e0ec72151653 Author: Denys Vlasenko AuthorDate: Thu, 24 Sep 2015 14:02:29 +0200 Committer: Ingo Molnar CommitDate: Fri, 25 Sep 2015 09:44:34 +0200 x86/asm: Force inlining of cpu_relax() On x86, cpu_relax() simply calls rep_nop(), which generates one instruction, PAUSE (aka REP NOP). With this config: http://busybox.net/~vda/kernel_config_OPTIMIZE_INLINING_and_Os gcc-4.7.2 does not always inline rep_nop(): it generates several copies of this: (16 copies, 194 calls): 55 push %rbp 48 89 e5 mov %rsp,%rbp f3 90 pause 5d pop %rbp c3 retq See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66122 This patch fixes this via s/inline/__always_inline/ on rep_nop() and cpu_relax(). ( Forcing inlining only on rep_nop() causes GCC to deinline cpu_relax(), with almost no change in generated code). text data bss dec hex filename 88118971 19905208 36421632 144445811 89c1173 vmlinux.before 88118139 19905208 36421632 144444979 89c0e33 vmlinux Signed-off-by: Denys Vlasenko Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1443096149-27291-1-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 19577dd..b55f309 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -556,12 +556,12 @@ static inline unsigned int cpuid_edx(unsigned int op) } /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ -static inline void rep_nop(void) +static __always_inline void rep_nop(void) { asm volatile("rep; nop" ::: "memory"); } -static inline void cpu_relax(void) +static __always_inline void cpu_relax(void) { rep_nop(); }