diff mbox

[v3,09/15] KVM: MMU: introduce free_meslot_rmap_desc_nolock

Message ID 1366093973-2617-10-git-send-email-xiaoguangrong@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong April 16, 2013, 6:32 a.m. UTC
It frees pte-list-descs used by memslot rmap after update
memslot is completed

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 arch/x86/kvm/mmu.c |   26 ++++++++++++++++++++++++++
 arch/x86/kvm/mmu.h |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index e6414d2..9ac584f 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1049,6 +1049,22 @@  static void pte_list_clear_concurrently(u64 *spte, unsigned long *pte_list)
 	return;
 }
 
+static void pte_list_free_desc(unsigned long *pte_list)
+{
+	struct pte_list_desc *desc, *next;
+	unsigned long pte_value = *pte_list;
+
+	if (!(pte_value & 1))
+		return;
+
+	desc = (struct pte_list_desc *)(pte_value & ~1ul);
+	do {
+		next = desc->more;
+		mmu_free_pte_list_desc(desc);
+		desc = next;
+	} while (desc);
+}
+
 typedef void (*pte_list_walk_fn) (u64 *spte);
 static void pte_list_walk(unsigned long *pte_list, pte_list_walk_fn fn)
 {
@@ -1786,6 +1802,16 @@  unmap_memslot_rmap_nolock(struct kvm *kvm, struct kvm_memory_slot *slot)
 	walk_memslot_rmap_nolock(slot, unmap_invalid_rmap_nolock, kvm);
 }
 
+static void free_rmap_desc_nolock(unsigned long *rmapp, void *data)
+{
+	pte_list_free_desc(rmapp);
+}
+
+void free_meslot_rmap_desc_nolock(struct kvm_memory_slot *slot)
+{
+	walk_memslot_rmap_nolock(slot, free_rmap_desc_nolock, NULL);
+}
+
 #ifdef MMU_DEBUG
 static int is_empty_shadow_page(u64 *spt)
 {
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index d6aa31a..ab434b7 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -130,4 +130,5 @@  struct rmap_operations {
 };
 
 void init_memslot_rmap_ops(struct kvm_memory_slot *slot);
+void free_meslot_rmap_desc_nolock(struct kvm_memory_slot *slot);
 #endif