Skip to content

Commit 5186ec2

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86/mmu: Bump pf_taken stat only in the "real" page fault handler
Account stat.pf_taken in kvm_mmu_page_fault(), i.e. the actual page fault handler, instead of conditionally bumping it in kvm_mmu_do_page_fault(). The "real" page fault handler is the only path that should ever increment the number of taken page faults, as all other paths that "do page fault" are by definition not handling faults that occurred in the guest. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent bc1a5cd commit 5186ec2

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5925,6 +5925,8 @@ int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 err
59255925
}
59265926

59275927
if (r == RET_PF_INVALID) {
5928+
vcpu->stat.pf_taken++;
5929+
59285930
r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, error_code, false,
59295931
&emulation_type);
59305932
if (KVM_BUG_ON(r == RET_PF_INVALID, vcpu->kvm))

arch/x86/kvm/mmu/mmu_internal.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,6 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
318318
fault.slot = kvm_vcpu_gfn_to_memslot(vcpu, fault.gfn);
319319
}
320320

321-
/*
322-
* Async #PF "faults", a.k.a. prefetch faults, are not faults from the
323-
* guest perspective and have already been counted at the time of the
324-
* original fault.
325-
*/
326-
if (!prefetch)
327-
vcpu->stat.pf_taken++;
328-
329321
if (IS_ENABLED(CONFIG_MITIGATION_RETPOLINE) && fault.is_tdp)
330322
r = kvm_tdp_page_fault(vcpu, &fault);
331323
else

0 commit comments

Comments
 (0)