[PATCH 0/2] KVM: x86/mmu: .change_pte() optimization in TDP MMU

From: Yan Zhao
Date: Tue Aug 08 2023 - 11:55:36 EST


This series optmizes KVM mmu notifier.change_pte() handler in x86 TDP MMU
(i.e. kvm_tdp_mmu_set_spte_gfn()) by removing old dead code and prefetching
notified new PFN into SPTEs directly in the handler.

As in [1], .change_pte() has been dead code on x86 for 10+ years.
Patch 1 drops the dead code in x86 TDP MMU to save cpu cycles and prepare
for optimization in TDP MMU in patch 2.

Patch 2 optimizes TDP MMU's .change_pte() handler to prefetch SPTEs in the
handler directly with PFN info contained in .change_pte() to avoid that
each vCPU write that triggers .change_pte() must undergo twice VMExits and
TDP page faults.

base-commit: fdf0eaf11452 + Sean's patch "KVM: Wrap kvm_{gfn,hva}_range.pte
in a per-action union" [2]

[1]: https://lore.kernel.org/lkml/ZMAO6bhan9l6ybQM@xxxxxxxxxx/
[2]:
https://lore.kernel.org/lkml/20230729004144.1054885-1-seanjc@xxxxxxxxxx/

Yan Zhao (2):
KVM: x86/mmu: Remove dead code in .change_pte() handler in x86 TDP MMU
KVM: x86/mmu: prefetch SPTE directly in x86 TDP MMU's change_pte()
handler

arch/x86/kvm/mmu/tdp_mmu.c | 101 +++++++++++++++++++++++++------------
1 file changed, 68 insertions(+), 33 deletions(-)

--
2.17.1