[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xen/arm: implement domain_relinquish_resources


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Wed, 06 Feb 2013 10:00:13 +0000
  • Delivery-date: Wed, 06 Feb 2013 10:02:49 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
# Date 1360063868 0
# Node ID 9a272a8ac323ff95c3b239a43d20cb437408ec0f
# Parent  bcb3e1902b3094bdf2d30c9e1146d0dbfc4edac0
xen/arm: implement domain_relinquish_resources

put_page on every entry in xenpage_list and page_list

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Tim Deegan <tim@xxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r bcb3e1902b30 -r 9a272a8ac323 xen/arch/arm/domain.c
--- a/xen/arch/arm/domain.c     Tue Feb 05 11:31:08 2013 +0000
+++ b/xen/arch/arm/domain.c     Tue Feb 05 11:31:08 2013 +0000
@@ -8,6 +8,7 @@
 #include <xen/bitops.h>
 
 #include <asm/current.h>
+#include <asm/event.h>
 #include <asm/regs.h>
 #include <asm/p2m.h>
 #include <asm/irq.h>
@@ -514,11 +515,51 @@ void arch_vcpu_reset(struct vcpu *v)
     vcpu_end_shutdown_deferral(v);
 }
 
+static int relinquish_memory(struct domain *d, struct page_list_head *list)
+{
+    struct page_info *page, *tmp;
+    int               ret = 0;
+
+    /* Use a recursive lock, as we may enter 'free_domheap_page'. */
+    spin_lock_recursive(&d->page_alloc_lock);
+
+    page_list_for_each_safe( page, tmp, list )
+    {
+        /* Grab a reference to the page so it won't disappear from under us. */
+        if ( unlikely(!get_page(page, d)) )
+            /* Couldn't get a reference -- someone is freeing this page. */
+            BUG();
+
+        if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
+            put_page(page);
+
+        put_page(page);
+
+        if ( hypercall_preempt_check() )
+        {
+            ret = -EAGAIN;
+            goto out;
+        }
+    }
+
+  out:
+    spin_unlock_recursive(&d->page_alloc_lock);
+    return ret;
+}
+
 int domain_relinquish_resources(struct domain *d)
 {
-    /* XXX teardown pagetables, free pages etc */
-    ASSERT(0);
-    return 0;
+    int ret = 0;
+
+    ret = relinquish_memory(d, &d->xenpage_list);
+    if ( ret )
+        return ret;
+
+    ret = relinquish_memory(d, &d->page_list);
+    if ( ret )
+        return ret;
+
+    return ret;
 }
 
 void arch_dump_domain_info(struct domain *d)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.