x86/hyperv: Exclude lazy TLB mode CPUs from enlightened TLB flushes
authorMichael Kelley <mikelley@microsoft.com>
Mon, 27 Mar 2023 13:16:07 +0000 (06:16 -0700)
committerWei Liu <wei.liu@kernel.org>
Mon, 17 Apr 2023 19:19:05 +0000 (19:19 +0000)
commit493cc07385cf1c6678a6159d410854b8e99aa945
treef408a2b26c75c82370e5e38a9883f8ff6ca3b68e
parentd7b6ba9611aefc4bef207b16db8ff06b726efe35
x86/hyperv: Exclude lazy TLB mode CPUs from enlightened TLB flushes

In the case where page tables are not freed, native_flush_tlb_multi()
does not do a remote TLB flush on CPUs in lazy TLB mode because the
CPU will flush itself at the next context switch. By comparison, the
Hyper-V enlightened TLB flush does not exclude CPUs in lazy TLB mode
and so performs unnecessary flushes.

If we're not freeing page tables, add logic to test for lazy TLB
mode when adding CPUs to the input argument to the Hyper-V TLB
flush hypercall. Exclude lazy TLB mode CPUs so the behavior
matches native_flush_tlb_multi() and the unnecessary flushes are
avoided. Handle both the <=64 vCPU case and the _ex case for >64
vCPUs.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/1679922967-26582-3-git-send-email-mikelley@microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
arch/x86/hyperv/mmu.c