question on lazy tlb flush

From: Zhenzhong Duan
Date: Wed May 29 2019 - 03:39:59 EST


Hi Maintainers,

A question raised when I learned below code. Appreciate any help me understand the code.

void native_flush_tlb_others(const struct cpumask *cpumask,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ const struct flush_tlb_info *info)

{

...

ÂÂÂÂÂÂÂ /*
ÂÂÂÂÂÂÂÂ * 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);

}

I just didn't understand how a kernel thread could trip up on the new contents of what used to be page tables. I presume the freed page tables are user mapping?

But kernel thread only access kernel address space, is kernel space also freed?


thanks

Zhenzhong