From: Peter Zijlstra <peterz@infradead.org>
To: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
tglx@linutronix.de, richard.fellner@student.tugraz.at,
moritz.lipp@iaik.tugraz.at, daniel.gruss@iaik.tugraz.at,
michael.schwarz@iaik.tugraz.at, luto@kernel.org,
torvalds@linux-foundation.org, keescook@google.com,
hughd@google.com, bp@alien8.de, x86@kernel.org
Subject: Re: [PATCH] x86/mm/kaiser: Flush the correct ASID in __native_flush_tlb_single()
Date: Wed, 29 Nov 2017 16:26:31 +0100 [thread overview]
Message-ID: <20171129152631.GQ3326@worktop> (raw)
In-Reply-To: <27729551-ecd6-e4e9-d214-4ab03d8008da@linux.intel.com>
On Wed, Nov 29, 2017 at 07:21:23AM -0800, Dave Hansen wrote:
> Yes, that works. Also, as I think about it, INVLPG is a safer
> (bug-resistant) instruction to use too. INVPCID _can_ get the current
> (kernel) ASID wrong, as we saw. But INVLPG always uses the current one
> and can't be wrong about flushing the *current* ASID.
>
> I think Andy measured it to be faster than INVPCID too.
>
> So, maybe we should just remove INVPCID's use entirely.
With my patches the below invpcid_flush_one() is the only remaining user
(not counting flush_tlb_global).
I know Andy hates on INVPCID, but I could not convince myself that doing
a full user invalidate makes sense for flush_tlb_single(), then again
maybe it does, the patch is trivial after this.
> > arch/x86/include/asm/tlbflush.h | 23 +++++++----------------
> > 1 file changed, 7 insertions(+), 16 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
> > index 481d5094559e..9587722162ee 100644
> > --- a/arch/x86/include/asm/tlbflush.h
> > +++ b/arch/x86/include/asm/tlbflush.h
> > @@ -438,29 +438,20 @@ static inline void __native_flush_tlb_single(unsigned long addr)
> > {
> > u32 loaded_mm_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid);
> >
> > + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
> > +
> > + if (!kaiser_enabled)
> > + return;
> > +
> > /*
> > * Some platforms #GP if we call invpcid(type=1/2) before
> > * CR4.PCIDE=1. Just call invpcid in the case we are called
> > * early.
> > */
> > + if (!this_cpu_has(X86_FEATURE_INVPCID_SINGLE))
> > flush_user_asid(loaded_mm_asid);
> > + else
> > invpcid_flush_one(user_asid(loaded_mm_asid), addr);
> > }
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
tglx@linutronix.de, richard.fellner@student.tugraz.at,
moritz.lipp@iaik.tugraz.at, daniel.gruss@iaik.tugraz.at,
michael.schwarz@iaik.tugraz.at, luto@kernel.org,
torvalds@linux-foundation.org, keescook@google.com,
hughd@google.com, bp@alien8.de, x86@kernel.org
Subject: Re: [PATCH] x86/mm/kaiser: Flush the correct ASID in __native_flush_tlb_single()
Date: Wed, 29 Nov 2017 16:26:31 +0100 [thread overview]
Message-ID: <20171129152631.GQ3326@worktop> (raw)
In-Reply-To: <27729551-ecd6-e4e9-d214-4ab03d8008da@linux.intel.com>
On Wed, Nov 29, 2017 at 07:21:23AM -0800, Dave Hansen wrote:
> Yes, that works. Also, as I think about it, INVLPG is a safer
> (bug-resistant) instruction to use too. INVPCID _can_ get the current
> (kernel) ASID wrong, as we saw. But INVLPG always uses the current one
> and can't be wrong about flushing the *current* ASID.
>
> I think Andy measured it to be faster than INVPCID too.
>
> So, maybe we should just remove INVPCID's use entirely.
With my patches the below invpcid_flush_one() is the only remaining user
(not counting flush_tlb_global).
I know Andy hates on INVPCID, but I could not convince myself that doing
a full user invalidate makes sense for flush_tlb_single(), then again
maybe it does, the patch is trivial after this.
> > arch/x86/include/asm/tlbflush.h | 23 +++++++----------------
> > 1 file changed, 7 insertions(+), 16 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
> > index 481d5094559e..9587722162ee 100644
> > --- a/arch/x86/include/asm/tlbflush.h
> > +++ b/arch/x86/include/asm/tlbflush.h
> > @@ -438,29 +438,20 @@ static inline void __native_flush_tlb_single(unsigned long addr)
> > {
> > u32 loaded_mm_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid);
> >
> > + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
> > +
> > + if (!kaiser_enabled)
> > + return;
> > +
> > /*
> > * Some platforms #GP if we call invpcid(type=1/2) before
> > * CR4.PCIDE=1. Just call invpcid in the case we are called
> > * early.
> > */
> > + if (!this_cpu_has(X86_FEATURE_INVPCID_SINGLE))
> > flush_user_asid(loaded_mm_asid);
> > + else
> > invpcid_flush_one(user_asid(loaded_mm_asid), addr);
> > }
next prev parent reply other threads:[~2017-11-29 15:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 9:55 [PATCH] x86/mm/kaiser: Flush the correct ASID in __native_flush_tlb_single() Dave Hansen
2017-11-29 14:35 ` Peter Zijlstra
2017-11-29 14:35 ` Peter Zijlstra
2017-11-29 15:21 ` Dave Hansen
2017-11-29 15:21 ` Dave Hansen
2017-11-29 15:26 ` Peter Zijlstra [this message]
2017-11-29 15:26 ` Peter Zijlstra
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=20171129152631.GQ3326@worktop \
--to=peterz@infradead.org \
--cc=bp@alien8.de \
--cc=daniel.gruss@iaik.tugraz.at \
--cc=dave.hansen@linux.intel.com \
--cc=hughd@google.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=moritz.lipp@iaik.tugraz.at \
--cc=richard.fellner@student.tugraz.at \
--cc=tglx@linutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.