From: Paolo Bonzini <pbonzini@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Thomas Gleixner <tglx@linutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org.com>,
"H. Peter Anvin" <hpa@zytor.com>, X86 ML <x86@kernel.org>,
Rik van Riel <riel@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 2/2] x86/entry: Inline enter_from_user_mode
Date: Mon, 6 Jun 2016 18:01:23 +0200 [thread overview]
Message-ID: <3113ad0f-8852-39e4-c135-0b13a2bf7108@redhat.com> (raw)
In-Reply-To: <CALCETrVhXEdf_GPth1VxhDjYqQRmgGQRFzc42h9o7FAkxZeR8Q@mail.gmail.com>
On 04/06/2016 07:08, Andy Lutomirski wrote:
> On May 30, 2016 5:30 AM, "Paolo Bonzini" <pbonzini@redhat.com> 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 <luto@kernel.org>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Rik van Riel <riel@redhat.com>
>> Cc: H. Peter Anvin <hpa@zytor.com>
>> Cc: Ingo Molnar <mingo@kernel.org.com>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> 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
next prev parent reply other threads:[~2016-06-06 16:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-30 12:30 [PATCH 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles Paolo Bonzini
2016-05-30 12:30 ` [PATCH 1/2] x86/entry: Avoid interrupt flag save and restore Paolo Bonzini
2016-06-01 14:52 ` Rik van Riel
2016-06-04 5:07 ` Andy Lutomirski
2016-06-06 15:47 ` Paolo Bonzini
2016-06-08 12:16 ` Ingo Molnar
2016-06-08 12:34 ` Paolo Bonzini
2016-06-08 12:54 ` Ingo Molnar
2016-06-08 13:39 ` Paolo Bonzini
2016-06-08 13:46 ` Ingo Molnar
2016-05-30 12:30 ` [PATCH 2/2] x86/entry: Inline enter_from_user_mode Paolo Bonzini
2016-06-01 14:54 ` Rik van Riel
2016-06-04 5:08 ` Andy Lutomirski
2016-06-06 16:01 ` Paolo Bonzini [this message]
2016-06-09 17:17 ` Andy Lutomirski
2016-06-20 14:58 [PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles Paolo Bonzini
2016-06-20 14:58 ` [PATCH 2/2] x86/entry: Inline enter_from_user_mode Paolo Bonzini
2016-06-20 20:22 ` Rik van Riel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3113ad0f-8852-39e4-c135-0b13a2bf7108@redhat.com \
--to=pbonzini@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®