From: Borislav Petkov <bp@alien8.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@kernel.org>,
Brian Gerst <brgerst@gmail.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Rik van Riel <riel@redhat.com>,
daniel.gruss@iaik.tugraz.at, hughd@google.com,
keescook@google.com, linux-mm@kvack.org,
michael.schwarz@iaik.tugraz.at, moritz.lipp@iaik.tugraz.at,
richard.fellner@student.tugraz.at
Subject: Re: [PATCH 5/6] x86/mm/kaiser: Optimize RESTORE_CR3
Date: Wed, 29 Nov 2017 21:02:12 +0100 [thread overview]
Message-ID: <20171129200212.gze3avcjofxrpy4t@pd.tnic> (raw)
In-Reply-To: <20171129103512.869504878@infradead.org>
On Wed, Nov 29, 2017 at 11:33:06AM +0100, Peter Zijlstra wrote:
> Currently RESTORE_CR3 does an unconditional flush
> (SAVE_AND_SWITCH_TO_KERNEL_CR3 does not set bit 63 on \save_reg).
>
> When restoring to a user ASID, check the user_asid_flush_mask to see
> if we can avoid the flush.
>
> For kernel ASIDs we can unconditionaly avoid the flush, since we do
> explicit flushes for them.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/x86/entry/calling.h | 29 +++++++++++++++++++++++++++--
> arch/x86/entry/entry_64.S | 4 ++--
> 2 files changed, 29 insertions(+), 4 deletions(-)
>
> --- a/arch/x86/entry/calling.h
> +++ b/arch/x86/entry/calling.h
> @@ -263,8 +263,33 @@ For 32-bit we have the following convent
> .Ldone_\@:
> .endm
>
> -.macro RESTORE_CR3 save_reg:req
> +.macro RESTORE_CR3 scratch_reg:req save_reg:req
> STATIC_JUMP_IF_FALSE .Lend_\@, kaiser_enabled_key, def=1
> +
> + /* ASID bit 11 is for user */
> + bt $11, \save_reg
<---- newline here.
> + /*
> + * KERNEL pages can always resume with NOFLUSH as we do
> + * explicit flushes.
> + */
> + jnc .Lnoflush_\@
> +
> + /*
> + * Check if there's a pending flush for the user ASID we're
> + * about to set.
> + */
> + movq \save_reg, \scratch_reg
> + andq $(0x7FF), \scratch_reg
> + bt \scratch_reg, PER_CPU_VAR(user_asid_flush_mask)
> + jnc .Lnoflush_\@
> +
> + btr \scratch_reg, PER_CPU_VAR(user_asid_flush_mask)
> + jmp .Ldo_\@
Can you save yourself one of the BT-insns?
...
andq $(0x7FF), \scratch_reg
btr \scratch_reg, PER_CPU_VAR(user_asid_flush_mask)
jnc .Lnoflush_\@
jmp .Ldo_\@
...
or am I missing a case?
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-11-29 20:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 10:33 [PATCH 0/6] more KAISER bits Peter Zijlstra
2017-11-29 10:33 ` [PATCH 1/6] x86/mm/kaiser: Add some static Peter Zijlstra
2017-11-29 10:33 ` [PATCH 2/6] x86/mm/kaiser: Fix inconsistency in SAVE_AND_SWITCH_TO_KERNEL_CR3 Peter Zijlstra
2017-11-29 10:33 ` [PATCH 3/6] x86/mm/kaiser: Allow PCID with nokaiser Peter Zijlstra
2017-11-29 10:33 ` [PATCH 4/6] x86/mm/kaiser: Support PCID without INVPCID Peter Zijlstra
2017-11-29 10:48 ` Peter Zijlstra
2017-11-29 11:48 ` Peter Zijlstra
2017-11-29 12:31 ` Peter Zijlstra
2017-11-29 13:38 ` Peter Zijlstra
2017-11-29 10:33 ` [PATCH 5/6] x86/mm/kaiser: Optimize RESTORE_CR3 Peter Zijlstra
2017-11-29 20:02 ` Borislav Petkov [this message]
2017-11-29 20:06 ` Peter Zijlstra
2017-11-29 10:33 ` [PATCH 6/6] x86/mm/kaiser: Optimize __native_flush_tlb Peter Zijlstra
2017-11-30 12:43 ` Peter Zijlstra
2017-11-30 13:13 ` Peter Zijlstra
2017-11-29 14:26 ` [PATCH 0/6] more KAISER bits Thomas Gleixner
2017-11-29 16:02 ` Thomas Gleixner
2017-11-29 18:03 ` Dave Hansen
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=20171129200212.gze3avcjofxrpy4t@pd.tnic \
--to=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=daniel.gruss@iaik.tugraz.at \
--cc=dave.hansen@linux.intel.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=hughd@google.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=michael.schwarz@iaik.tugraz.at \
--cc=mingo@kernel.org \
--cc=moritz.lipp@iaik.tugraz.at \
--cc=peterz@infradead.org \
--cc=richard.fellner@student.tugraz.at \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).