]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: x86: Don't emit TLB flushes when aging SPTEs for mmu_notifiers
authorSean Christopherson <seanjc@google.com>
Fri, 11 Oct 2024 02:10:50 +0000 (19:10 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 30 Oct 2024 22:25:41 +0000 (15:25 -0700)
commitb9883ee40d7e6c3f3fb59c247283b152fdde955c
tree2baa470b901d9eb1e6d712ae90fd7731e48fdf7e
parent2ebbe0308c29287914eeabe6ed83a6e21f9962bc
KVM: x86: Don't emit TLB flushes when aging SPTEs for mmu_notifiers

Follow x86's primary MMU, which hasn't flushed TLBs when clearing Accessed
bits for 10+ years, and skip all TLB flushes when aging SPTEs in response
to a clear_flush_young() mmu_notifier event.  As documented in x86's
ptep_clear_flush_young(), the probability and impact of "bad" reclaim due
to stale A-bit information is relatively low, whereas the performance cost
of TLB flushes is relatively high.  I.e. the cost of flushing TLBs
outweighs the benefits.

On KVM x86, the cost of TLB flushes is even higher, as KVM doesn't batch
TLB flushes for mmu_notifier events (KVM's mmu_notifier contract with MM
makes it all but impossible), and sending IPIs forces all running vCPUs to
go through a VM-Exit => VM-Enter roundtrip.

Furthermore, MGLRU aging of secondary MMUs is expected to use flush-less
mmu_notifiers, i.e. flushing for the !MGLRU will make even less sense, and
will be actively confusing as it wouldn't be clear why KVM "needs" to
flush TLBs for legacy LRU aging, but not for MGLRU aging.

Cc: James Houghton <jthoughton@google.com>
Cc: Yan Zhao <yan.y.zhao@intel.com>
Link: https://lore.kernel.org/all/20240926013506.860253-18-jthoughton@google.com
Link: https://lore.kernel.org/r/20241011021051.1557902-19-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/Kconfig
arch/x86/kvm/mmu/spte.h