Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1305105

Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB using CR3

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB using CR3
Date 2016-01-09 01:20 +0100
Message-ID <qOPq9-5WM-13@gated-at.bofh.it> (permalink)
References <qOOu6-5ka-5@gated-at.bofh.it> <qOOu6-5ka-29@gated-at.bofh.it> <qOOX7-5wC-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Jan 8, 2016 3:41 PM, "Linus Torvalds" <torvalds@linux-foundation.org> wrote:
>
> On Fri, Jan 8, 2016 at 3:15 PM, Andy Lutomirski <luto@kernel.org> wrote:
> > +       /*
> > +        * We mustn't be preempted or handle an IPI while reading and
> > +        * writing CR3.  Preemption could switch mms and switch back, and
> > +        * an IPI could call leave_mm.  Either of those could cause our
> > +        * PCID to change asynchronously.
> > +        */
> > +       raw_local_irq_save(flags);
> >         native_write_cr3(native_read_cr3());
> > +       raw_local_irq_restore(flags);
>
> This seems sad for two reasons:
>
>  - it adds unnecessary overhead on non-pcid setups (32-bit being an
> example of that)

I can certainly skip the flag saving on !PCID.

>
>  - on pcid setups, wouldn't invpcid_flush_single_context() be better?
>

I played with that and it was slower.  I don't pretend that makes any sense.

> So on the whole I hate it.
>
> Why isn't this something like
>
>         if (static_cpu_has_safe(X86_FEATURE_INVPCID)) {
>                 invpcid_flush_single_context();
>                 return;
>         }
>         native_write_cr3(native_read_cr3());
>
> *without* any flag saving crud?
>
> And yes, that means that we'd require X86_FEATURE_INVPCID in order to
> use X86_FEATURE_PCID, but that seems fine.

I have an SNB "Extreme" with PCID but not INVPCID, and there could be
a whole generation of servers like that.  I think we should fully
support them.

We might be able to get away with just disabling preemption instead of
IRQs, at least if mm == active_mm.

>
> Or is there some reason you wanted the odd flags version? If so, that
> should be documented.

What do you mean "odd"?

--Andy

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 09/13] x86/mm: Disable interrupts when flushing the TLB using CR3 Andy Lutomirski <luto@kernel.org> - 2016-01-09 00:20 +0100
  Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-09 00:50 +0100
    Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Andy Lutomirski <luto@amacapital.net> - 2016-01-09 01:20 +0100
      Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-09 03:30 +0100
        Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Ingo Molnar <mingo@kernel.org> - 2016-01-11 12:00 +0100
          Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Andy Lutomirski <luto@amacapital.net> - 2016-01-14 00:40 +0100
        Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Andy Lutomirski <luto@amacapital.net> - 2016-01-14 00:40 +0100
          Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Dave Hansen <dave.hansen@linux.intel.com> - 2016-01-14 00:50 +0100
            Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Dave Hansen <dave.hansen@linux.intel.com> - 2016-01-14 01:00 +0100
              Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Andy Lutomirski <luto@amacapital.net> - 2016-01-14 01:40 +0100
            Re: [RFC 09/13] x86/mm: Disable interrupts when flushing the TLB  using CR3 Andy Lutomirski <luto@amacapital.net> - 2016-01-14 01:00 +0100

csiph-web