Re: [PATCH] x86/mm/tlb: Do partial TLB flush when possible

From: Zhenzhong Duan
Date: Thu May 30 2019 - 22:55:41 EST



On 2019/5/30 22:15, Andy Lutomirski wrote:
On Thu, May 30, 2019 at 12:56 AM Zhenzhong Duan
<zhenzhong.duan@xxxxxxxxxx> wrote:
This is a small optimization to stale TLB flush, if there is one new TLB
flush, let it choose to do partial or full flush. or else, the stale
flush take over and do full flush.
I think this is invalid because:

+ if (unlikely(f->new_tlb_gen <= local_tlb_gen &&
+ local_tlb_gen + 1 == mm_tlb_gen)) {
+ /*
+ * For stale TLB flush request, if there will be one new TLB
+ * flush coming, we leave the work to the new IPI as it knows
+ * partial or full TLB flush to take, or else we do the full
+ * flush.
+ */
+ trace_tlb_flush(reason, 0);
+ return;
We do indeed know that the TLB will get flushed eventually, but we're
actually providing a stronger guarantee that the TLB will be
adequately flushed by the time we return. Otherwise, after
flush_tlb_mm_range(), there will be a window in which the TLB isn't
flushed yet.

You are right. I didn't notice this point, sorry for the noise.

Zhenzhong