Skip to contentSkip to conversation

KVM: Drop gfn_to_pfn_atomic()

PATCH New Peter Xu 1 participant 3 messages Mar 5, 2020

Subsystems (2)
lore
Share & tools
lore

Peter Xu

author
#0 lore raw

v2 cover KVM: Drop gfn_to_pfn_atomic()

v2:
- add a document update for indirect sp fast path which referenced gfn_to_pfn_atomic(). [linmiaohe]

Please review, thanks.

Peter Xu (2):
KVM: Documentation: Update fast page fault for indirect sp
KVM: Drop gfn_to_pfn_atomic()

 Documentation/virt/kvm/locking.rst | 9 ++++-----
 include/linux/kvm_host.h           | 1 -
 virt/kvm/kvm_main.c                | 6 ------
 3 files changed, 4 insertions(+), 12 deletions(-)
Signature · 1 line
2.24.1
author
#1 lore raw

PATCH v2 1/2 KVM: Documentation: Update fast page fault for indirect sp

gfn_to_pfn_atomic() is not used anywhere. Before dropping it, reorganize the locking document to state the fact that we're not enabling fast page fault for indirect sps. The previous wording is confusing that it seems we have implemented it however it's not.

---
 Documentation/virt/kvm/locking.rst | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
Documentation/virt/kvm/locking.rst +4 -5
index c02291beac3f..d045b2a89505 100644
@@ -96,8 +96,10 @@ will happen:
 We dirty-log for gfn1, that means gfn2 is lost in dirty-bitmap.
 
 For direct sp, we can easily avoid it since the spte of direct sp is fixed
-to gfn. For indirect sp, before we do cmpxchg, we call gfn_to_pfn_atomic()
-to pin gfn to pfn, because after gfn_to_pfn_atomic():
+to gfn.  For indirect sp, we disabled fast page fault for simplicity.
+
+A solution for indirect sp is that, before we do cmpxchg, we pin the
+pfn of the gfn atomically.  After the pinning:
 
 - We have held the refcount of pfn that means the pfn can not be freed and
   be reused for another gfn.
@@ -106,9 +108,6 @@ to pin gfn to pfn, because after gfn_to_pfn_atomic():
 
 Then, we can ensure the dirty bitmaps is correctly set for a gfn.
 
-Currently, to simplify the whole things, we disable fast page fault for
-indirect shadow page.
-
 2) Dirty bit tracking
 
 In the origin code, the spte can be fast updated (non-atomically) if the
Signature · 1 line
2.24.1
author
#2 lore raw

PATCH v2 2/2 KVM: Drop gfn_to_pfn_atomic()

In reply to Peter Xu

It's never used anywhere now.

---
 include/linux/kvm_host.h | 1 -
 virt/kvm/kvm_main.c      | 6 ------
 2 files changed, 7 deletions(-)
include/linux/kvm_host.h +0 -1
index bcb9b2ac0791..3faa062ea108 100644
@@ -704,7 +704,6 @@ void kvm_release_page_clean(struct page *page);
 void kvm_release_page_dirty(struct page *page);
 void kvm_set_page_accessed(struct page *page);
 
-kvm_pfn_t gfn_to_pfn_atomic(struct kvm *kvm, gfn_t gfn);
 kvm_pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn);
 kvm_pfn_t gfn_to_pfn_prot(struct kvm *kvm, gfn_t gfn, bool write_fault,
 		      bool *writable);
virt/kvm/kvm_main.c +0 -6
index 70f03ce0e5c1..d29718c7017c 100644
@@ -1754,12 +1754,6 @@ kvm_pfn_t gfn_to_pfn_memslot_atomic(struct kvm_memory_slot *slot, gfn_t gfn)
 }
 EXPORT_SYMBOL_GPL(gfn_to_pfn_memslot_atomic);
 
-kvm_pfn_t gfn_to_pfn_atomic(struct kvm *kvm, gfn_t gfn)
-{
-	return gfn_to_pfn_memslot_atomic(gfn_to_memslot(kvm, gfn), gfn);
-}
-EXPORT_SYMBOL_GPL(gfn_to_pfn_atomic);
-
 kvm_pfn_t kvm_vcpu_gfn_to_pfn_atomic(struct kvm_vcpu *vcpu, gfn_t gfn)
 {
 	return gfn_to_pfn_memslot_atomic(kvm_vcpu_gfn_to_memslot(vcpu, gfn), gfn);
Signature · 1 line
2.24.1