[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrUecDLRTdQBERrzk4nuS-fGFg0USkWRXfRMGw1fxYRP7w@mail.gmail.com>
Date: Wed, 1 Nov 2017 14:04:35 -0700
From: Andy Lutomirski <luto@...nel.org>
To: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Andy Lutomirski <luto@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
moritz.lipp@...k.tugraz.at,
Daniel Gruss <daniel.gruss@...k.tugraz.at>,
michael.schwarz@...k.tugraz.at,
Linus Torvalds <torvalds@...ux-foundation.org>,
Kees Cook <keescook@...gle.com>,
Hugh Dickins <hughd@...gle.com>, X86 ML <x86@...nel.org>
Subject: Re: [PATCH 21/23] x86, pcid, kaiser: allow flushing for future ASID switches
On Wed, Nov 1, 2017 at 1:59 PM, Dave Hansen <dave.hansen@...ux.intel.com> wrote:
> On 11/01/2017 01:31 PM, Andy Lutomirski wrote:
>> On Wed, Nov 1, 2017 at 7:17 AM, Dave Hansen <dave.hansen@...ux.intel.com> wrote:
>>> On 11/01/2017 01:03 AM, Andy Lutomirski wrote:
>>>>> This ensures that any futuee context switches will do a full flush
>>>>> of the TLB so they pick up the changes.
>>>> I'm convuced. What was wrong with the old code? I guess I just don't
>>>> see what the problem is that is solved by this patch.
>>>
>>> Instead of flushing *now* with INVPCID, this lets us flush *later* with
>>> CR3. It just hijacks the code that you already have that flushes CR3
>>> when loading a new ASID by making all ASIDs look new in the future.
>>>
>>> We have to load CR3 anyway, so we might as well just do this flush then.
>>
>> Would it make more sense to put it in flush_tlb_func_common() instead?
>>
>> Also, I don't understand what clear_non_loaded_ctxs() is trying to do.
>> It looks like it's invalidating all the other logical address spaces.
>> And I don't see why you want a all_other_ctxs_invalid variable. Isn't
>> the goal to mark a single ASID as needing a *user* flush the next time
>> we switch to user mode using that ASID? Your code seems like it's
>> going to flush a lot of *kernel* PCIDs.
>
> The point of the whole thing is to (relatively) efficiently flush
> *kernel* TLB entries in *other* address spaces.
Aha! That wasn't at all clear to me from the changelog. Can I make a
totally different suggestion? Add a new function
__flush_tlb_one_kernel() and use it for kernel addresses. That
function should just do __flush_tlb_all() if KAISER is on. Then make
sure that there are no performance-critical looks that call
__flush_tlb_one_kernel() in KAISER mode. The approach you're using is
quite expensive, and I suspect that just going a global flush may
actually be faster. It's certainly a lot simpler.
Optionally add a warning to __flush_tlb_one() if the address is a
kernel address to help notice any missed conversions. Or just rename
it to __flush_tlb_one_user().
--Andy
Powered by blists - more mailing lists