public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Andy Lutomirski <luto@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	"Brian Gerst" <brgerst@gmail.com>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Borislav Petkov" <bp@alien8.de>,
	"Frédéric Weisbecker" <fweisbec@gmail.com>,
	"Peter Zijlstra" <peterz@infradead.org>
Subject: Re: [PATCH 4/4] x86/entry/64: Bypass enter_from_user_mode on non-context-tracking boots
Date: Mon, 9 Nov 2015 09:52:23 +0100	[thread overview]
Message-ID: <20151109085223.GA12356@gmail.com> (raw)
In-Reply-To: <32bb09004dc9b005d5c14f021e42eb1f83ce3db3.1446849780.git.luto@kernel.org>


* Andy Lutomirski <luto@kernel.org> wrote:

> On CONFIG_CONTEXT_TRACKING kernels that have context tracking
> disabled at runtime (which includes most distro kernels), we still
> have the overhead of a call to enter_from_user_mode in interrupt and
> exception entries.
> 
> If jump labels are available, this uses the jump label
> infrastructure to skip the call.
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/entry/calling.h  | 15 +++++++++++++++
>  arch/x86/entry/entry_64.S |  8 ++------
>  2 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
> index 3c71dd947c7b..271e30c585bc 100644
> --- a/arch/x86/entry/calling.h
> +++ b/arch/x86/entry/calling.h
> @@ -1,3 +1,5 @@
> +#include <linux/jump_label.h>
> +
>  /*
>  
>   x86 function call convention, 64-bit:
> @@ -232,3 +234,16 @@ For 32-bit we have the following conventions - kernel is built with
>  
>  #endif /* CONFIG_X86_64 */
>  
> +/*
> + * This does 'call enter_from_user_mode' unless we can avoid it based on
> + * kernel config or using the static jump infrastructure.
> + */
> +.macro CALL_ENTER_FROM_USER_MODE
> +#ifdef CONFIG_CONTEXT_TRACKING
> +#ifdef HAVE_JUMP_LABEL
> +	STATIC_JUMP_IF_FALSE .Lafter_call_\@, context_tracking_enabled, def=0
> +#endif
> +	call enter_from_user_mode
> +.Lafter_call_\@:
> +#endif
> +.endm
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index f585df24ab3d..9b49b56efa29 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -517,9 +517,7 @@ END(irq_entries_start)
>  	 */
>  	TRACE_IRQS_OFF
>  
> -#ifdef CONFIG_CONTEXT_TRACKING
> -	call enter_from_user_mode
> -#endif
> +	CALL_ENTER_FROM_USER_MODE
>  
>  1:
>  	/*
> @@ -1058,9 +1056,7 @@ ENTRY(error_entry)
>  
>  .Lerror_entry_from_usermode_after_swapgs:
>  	TRACE_IRQS_OFF
> -#ifdef CONFIG_CONTEXT_TRACKING
> -	call enter_from_user_mode
> -#endif
> +	CALL_ENTER_FROM_USER_MODE
>  	ret

Yeah, so I only have a really minor syntactic nit abou tthis: it's OK to 
capitalize things when doing macros, but here I don't think capitalizing the 
called function name is good - I think the following would be more obvious:

	CALL_enter_from_user_mode

this makes it really, really obvious (to me!) that this macro is a shortcut for:

	call enter_from_user_mode

with some glue around it, and I could grep for 'enter_from_user_mode' immediately 
- while grepping for ENTER_FROM_USER_MODE would miss the called function.

Thanks,

	Ingo

      reply	other threads:[~2015-11-09  8:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-06 23:12 [PATCH 0/4] x86 entry stuff, maybe for 4.4 Andy Lutomirski
2015-11-06 23:12 ` [PATCH 1/4] x86/entry/64: Fix irqflag tracing wrt context tracking Andy Lutomirski
2015-11-07  9:59   ` Thomas Gleixner
2015-11-07 11:18   ` Borislav Petkov
2015-11-09  4:20     ` Andy Lutomirski
2015-11-06 23:12 ` [PATCH 2/4] context_tracking: Switch to new static_branch API Andy Lutomirski
2015-11-07  9:59   ` Thomas Gleixner
2015-11-06 23:12 ` [PATCH 3/4] x86/asm: Add asm macros for static keys/jump labels Andy Lutomirski
2015-11-07 11:20   ` Thomas Gleixner
2015-11-07 16:49     ` Andy Lutomirski
2015-11-07 16:58       ` Thomas Gleixner
2015-11-07 17:05         ` Andy Lutomirski
2015-11-07 17:08           ` Thomas Gleixner
2015-11-07 18:16             ` Andy Lutomirski
2015-11-09  9:48               ` Peter Zijlstra
2015-11-08 16:16             ` Andy Lutomirski
2015-11-06 23:12 ` [PATCH 4/4] x86/entry/64: Bypass enter_from_user_mode on non-context-tracking boots Andy Lutomirski
2015-11-09  8:52   ` Ingo Molnar [this message]

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=20151109085223.GA12356@gmail.com \
    --to=mingo@kernel.org \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    --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