From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754200AbcANAe7 (ORCPT ); Wed, 13 Jan 2016 19:34:59 -0500 Received: from mail-oi0-f44.google.com ([209.85.218.44]:35467 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657AbcANAe5 (ORCPT ); Wed, 13 Jan 2016 19:34:57 -0500 MIME-Version: 1.0 In-Reply-To: <5696E420.9040704@linux.intel.com> References: <5696E129.9000804@linux.intel.com> <5696E420.9040704@linux.intel.com> From: Andy Lutomirski Date: Wed, 13 Jan 2016 16:34:37 -0800 Message-ID: Subject: Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB using CR3 To: Dave Hansen Cc: Linus Torvalds , Oleg Nesterov , X86 ML , Borislav Petkov , Linux Kernel Mailing List , "linux-mm@kvack.org" , Brian Gerst Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2016 at 3:56 PM, Dave Hansen wrote: > On 01/13/2016 03:51 PM, Andy Lutomirski wrote: >> On Wed, Jan 13, 2016 at 3:43 PM, Dave Hansen >> wrote: >>> On 01/13/2016 03:35 PM, Andy Lutomirski wrote: >>>> Can anyone here ask a hardware or microcode person what's going on >>>> with CR3 writes possibly being faster than INVPCID? Is there some >>>> trick to it? >>> >>> I just went and measured it myself this morning. "INVPCID Type 3" (all >>> contexts no global) on a Skylake system was 15% slower than a CR3 write. >>> >>> Is that in the same ballpark from what you've observed? >> >> It's similar, except that I was comparing "INVPCID Type 1" (single >> context no globals) to a CR3 write. > > Ahh, because you're using PCID... That one I saw as being ~1.85x the > number of cycles that a CR3 write was. > I think that settles it, then: if (static_cpu_has_safe(X86_FEATURE_PCID)) { raw_local_irqsave(); native_write_cr3(native_read_cr3()); raw_local_irqrestore(); } else { native_write_cr3(native_read_cr3()); } I don't think it's worth hacking more complexity into switch_mm to make that annoyance go away. --Andy