From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753174AbcFFQBd (ORCPT ); Mon, 6 Jun 2016 12:01:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57482 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752953AbcFFQBc (ORCPT ); Mon, 6 Jun 2016 12:01:32 -0400 Subject: Re: [PATCH 2/2] x86/entry: Inline enter_from_user_mode To: Andy Lutomirski References: <1464611414-12379-1-git-send-email-pbonzini@redhat.com> <1464611414-12379-3-git-send-email-pbonzini@redhat.com> Cc: Thomas Gleixner , "linux-kernel@vger.kernel.org" , Ingo Molnar , "H. Peter Anvin" , X86 ML , Rik van Riel , Peter Zijlstra From: Paolo Bonzini Message-ID: <3113ad0f-8852-39e4-c135-0b13a2bf7108@redhat.com> Date: Mon, 6 Jun 2016 18:01:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 06 Jun 2016 16:01:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/06/2016 07:08, Andy Lutomirski wrote: > On May 30, 2016 5:30 AM, "Paolo Bonzini" wrote: >> >> This matches what is already done for prepare_exit_to_usermode, >> and saves about 60 clock cycles (4% speedup) with the benchmark >> in the previous commit message. >> >> Cc: Andy Lutomirski >> Cc: Peter Zijlstra >> Cc: Rik van Riel >> Cc: H. Peter Anvin >> Cc: Ingo Molnar >> Cc: Thomas Gleixner >> Signed-off-by: Paolo Bonzini >> --- >> arch/x86/entry/common.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c >> index 946bc1a..582bbc8 100644 >> --- a/arch/x86/entry/common.c >> +++ b/arch/x86/entry/common.c >> @@ -40,7 +40,7 @@ static struct thread_info *pt_regs_to_thread_info(struct pt_regs *regs) >> >> #ifdef CONFIG_CONTEXT_TRACKING >> /* Called on entry from user mode with IRQs off. */ >> -__visible void enter_from_user_mode(void) >> +__visible inline void enter_from_user_mode(void) >> { >> CT_WARN_ON(ct_state() != CONTEXT_USER); >> __user_exit(); > > I wonder if an extern inline *declaration* is needed as well in this C > file. At least C99 suggests it is. Maybe __visible is sufficient to > force an external definition to be emitted. An extern inline declaration is not needed because the kernel uses -std=gnu89 (or, if you prefer, because prepare_exit_to_usermode didn't have one :)). It's awesomely perverted: __attribute__((externally_visible)) inline void f(void) {} inline void g(void) {} extern inline void h(void); extern inline void h(void) {} inline void i(void); inline void i(void) {} extern inline void j(void); inline void j(void) {} This patch (and the preexisting prepare_exit_to_usermode code) are equivalent to "f". Compile the above file with "--std=gnu89" or "--std=gnu99 -fgnu89-inline" and f/g/i/j are emitted. Compile it with "--std=gnu99 -fno-gnu89-inline" and h/j is emitted. Yes, the standard is _almost exactly_ the opposite of the preexisting GCC implementation. The only case which achieves the same effect is when declarations are "extern inline" and definitions must always be "inline". Or of course just use "static inline". At least it's decently documented in the GCC info documentation. Thanks, Paolo