From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932887AbcBIQOK (ORCPT ); Tue, 9 Feb 2016 11:14:10 -0500 Received: from terminus.zytor.com ([198.137.202.10]:38419 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757803AbcBIQJ0 (ORCPT ); Tue, 9 Feb 2016 11:09:26 -0500 Date: Tue, 9 Feb 2016 08:08:12 -0800 From: tip-bot for Andy Lutomirski Message-ID: Cc: dvlasenk@redhat.com, mcgrof@suse.com, oleg@redhat.com, aryabinin@virtuozzo.com, luto@amacapital.net, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, dave.hansen@linux.intel.com, mingo@kernel.org, bp@alien8.de, peterz@infradead.org, toshi.kani@hp.com, akpm@linux-foundation.org, bp@suse.de, torvalds@linux-foundation.org, luto@kernel.org, brgerst@gmail.com Reply-To: bp@alien8.de, mingo@kernel.org, luto@amacapital.net, linux-kernel@vger.kernel.org, oleg@redhat.com, aryabinin@virtuozzo.com, mcgrof@suse.com, dvlasenk@redhat.com, tglx@linutronix.de, dave.hansen@linux.intel.com, hpa@zytor.com, torvalds@linux-foundation.org, brgerst@gmail.com, luto@kernel.org, toshi.kani@hp.com, peterz@infradead.org, bp@suse.de, akpm@linux-foundation.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/mm: If INVPCID is available, use it to flush global mappings Git-Commit-ID: d8bced79af1db6734f66b42064cc773cada2ce99 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d8bced79af1db6734f66b42064cc773cada2ce99 Gitweb: http://git.kernel.org/tip/d8bced79af1db6734f66b42064cc773cada2ce99 Author: Andy Lutomirski AuthorDate: Fri, 29 Jan 2016 11:42:59 -0800 Committer: Ingo Molnar CommitDate: Tue, 9 Feb 2016 13:36:11 +0100 x86/mm: If INVPCID is available, use it to flush global mappings On my Skylake laptop, INVPCID function 2 (flush absolutely everything) takes about 376ns, whereas saving flags, twiddling CR4.PGE to flush global mappings, and restoring flags takes about 539ns. Signed-off-by: Andy Lutomirski Reviewed-by: Borislav Petkov Cc: Andrew Morton Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/ed0ef62581c0ea9c99b9bf6df726015e96d44743.1454096309.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/tlbflush.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 8b57683..fc9a2fd 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -152,6 +152,15 @@ static inline void __native_flush_tlb_global(void) { unsigned long flags; + if (static_cpu_has(X86_FEATURE_INVPCID)) { + /* + * Using INVPCID is considerably faster than a pair of writes + * to CR4 sandwiched inside an IRQ flag save/restore. + */ + invpcid_flush_all(); + return; + } + /* * Read-modify-write to CR4 - protect it from preemption and * from interrupts. (Use the raw variant because this code can