Skip to content

Commit 4d75f14

Browse files
sean-jcbonzini
authored andcommitted
KVM: MIPS: Mark "struct page" pfns accessed only in "slow" page fault path
Mark pages accessed only in the slow page fault path in order to remove an unnecessary user of kvm_pfn_to_refcounted_page(). Marking pages accessed in the primary MMU during KVM page fault handling isn't harmful, but it's largely pointless and likely a waste of a cycles since the primary MMU will call into KVM via mmu_notifiers when aging pages. I.e. KVM participates in a "pull" model, so there's no need to also "push" updates. Signed-off-by: Sean Christopherson <[email protected]> Tested-by: Dmitry Osipenko <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-ID: <[email protected]>
1 parent d8f4cda commit 4d75f14

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

arch/mips/kvm/mmu.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,6 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa,
484484
struct kvm *kvm = vcpu->kvm;
485485
gfn_t gfn = gpa >> PAGE_SHIFT;
486486
pte_t *ptep;
487-
kvm_pfn_t pfn = 0; /* silence bogus GCC warning */
488-
bool pfn_valid = false;
489487
int ret = 0;
490488

491489
spin_lock(&kvm->mmu_lock);
@@ -498,12 +496,9 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa,
498496
}
499497

500498
/* Track access to pages marked old */
501-
if (!pte_young(*ptep)) {
499+
if (!pte_young(*ptep))
502500
set_pte(ptep, pte_mkyoung(*ptep));
503-
pfn = pte_pfn(*ptep);
504-
pfn_valid = true;
505-
/* call kvm_set_pfn_accessed() after unlock */
506-
}
501+
507502
if (write_fault && !pte_dirty(*ptep)) {
508503
if (!pte_write(*ptep)) {
509504
ret = -EFAULT;
@@ -512,7 +507,6 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa,
512507

513508
/* Track dirtying of writeable pages */
514509
set_pte(ptep, pte_mkdirty(*ptep));
515-
pfn = pte_pfn(*ptep);
516510
mark_page_dirty(kvm, gfn);
517511
}
518512

@@ -523,8 +517,6 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa,
523517

524518
out:
525519
spin_unlock(&kvm->mmu_lock);
526-
if (pfn_valid)
527-
kvm_set_pfn_accessed(pfn);
528520
return ret;
529521
}
530522

0 commit comments

Comments
 (0)