Re: [PATCH 7/7] x86/mm/tlb: Make lazy TLB mode lazier

From: Peter Zijlstra
Date: Mon Oct 01 2018 - 12:07:55 EST


On Tue, Sep 25, 2018 at 11:58:44PM -0400, Rik van Riel wrote:
> @@ -594,8 +628,23 @@ void native_flush_tlb_others(const struct cpumask *cpumask,
> (void *)info, 1);
> return;
> }
> - smp_call_function_many(cpumask, flush_tlb_func_remote,
> +
> + /*
> + * If no page tables were freed, we can skip sending IPIs to
> + * CPUs in lazy TLB mode. They will flush the CPU themselves
> + * at the next context switch.
> + *
> + * However, if page tables are getting freed, we need to send the
> + * IPI everywhere, to prevent CPUs in lazy TLB mode from tripping
> + * up on the new contents of what used to be page tables, while
> + * doing a speculative memory access.
> + */
> + if (info->freed_tables)
> + smp_call_function_many(cpumask, flush_tlb_func_remote,
> (void *)info, 1);
> + else
> + on_each_cpu_cond_mask(tlb_is_not_lazy, flush_tlb_func_remote,
> + (void *)info, 1, GFP_ATOMIC, cpumask);
> }

And this is safe vs paravirt, because for native we now do _less_
invalidations.

That might warrant a mention in the Changelog perhaps.