Re: [PATCH 4/7] x86,tlb: make lazy TLB mode lazier

From: Rik van Riel
Date: Fri Jun 29 2018 - 13:30:02 EST


On Fri, 2018-06-29 at 10:05 -0700, Dave Hansen wrote:
> On 06/29/2018 07:29 AM, Rik van Riel wrote:
> > + /*
> > + * If the CPU is not in lazy TLB mode, we are just
> > switching
> > + * from one thread in a process to another thread
> > in the same
> > + * process. No TLB flush required.
> > + */
> > + if (!was_lazy)
> > + return;
> > +
> > + /*
> > + * Read the tlb_gen to check whether a flush is
> > needed.
> > + * If the TLB is up to date, just use it.
> > + * The barrier synchronizes with the tlb_gen
> > increment in
> > + * the TLB shootdown code.
> > + */
> > + smp_mb();
> > + next_tlb_gen = atomic64_read(&next-
> > >context.tlb_gen);
> > + if
> > (this_cpu_read(cpu_tlbstate.ctxs[prev_asid].tlb_gen) ==
> > + next_tlb_gen)
> > + return;
>
> Nit: it might be nice to have this hunk in a helper like
> cpu_tlbstate_needs_flush(next) to keep this nice and readable.

That helper might not end up as pretty as you would
like, because when the TLB is not up to date, we use
the value of next_tlb_gen in the "if (need_flush)"
branch below.

I would be happy to whip up a "tlb_up_to_date(mm, &next_tlb_gen)"
helper as patch 8/7, though :)

--
All Rights Reversed.

Attachment: signature.asc
Description: This is a digitally signed message part