diff options
author | 2024-10-10 11:23:50 -0700 | |
---|---|---|
committer | 2024-10-25 13:00:47 -0400 | |
commit | 8eaa98004b23e02adb3e11120132e0e2fecc6e0e (patch) | |
tree | fcf386035a1ccd73364100c096cec61a5975da63 | |
parent | KVM: x86/mmu: Put refcounted pages instead of blindly releasing pfns (diff) | |
download | wireguard-linux-8eaa98004b23e02adb3e11120132e0e2fecc6e0e.tar.xz wireguard-linux-8eaa98004b23e02adb3e11120132e0e2fecc6e0e.zip |
KVM: x86/mmu: Don't mark unused faultin pages as accessed
When finishing guest page faults, don't mark pages as accessed if KVM
is resuming the guest _without_ installing a mapping, i.e. if the page
isn't being used. While it's possible that marking the page accessed
could avoid minor thrashing due to reclaiming a page that the guest is
about to access, it's far more likely that the gfn=>pfn mapping was
was invalidated, e.g. due a memslot change, or because the corresponding
VMA is being modified.
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20241010182427.1434605-49-seanjc@google.com>
-rw-r--r-- | arch/x86/kvm/mmu/mmu.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index fe3f3bc0bb79..f3a4ed6afec2 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4393,7 +4393,9 @@ static void kvm_mmu_finish_page_fault(struct kvm_vcpu *vcpu, * fault handler, and so KVM must (somewhat) speculatively mark the * folio dirty if KVM could locklessly make the SPTE writable. */ - if (!fault->map_writable || r == RET_PF_RETRY) + if (r == RET_PF_RETRY) + kvm_release_page_unused(fault->refcounted_page); + else if (!fault->map_writable) kvm_release_page_clean(fault->refcounted_page); else kvm_release_page_dirty(fault->refcounted_page); |