xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: tim@xen.org, Ian.Campbell@citrix.com,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 2/3] xen/arm: implement domain_relinquish_resources
Date: Tue, 22 Jan 2013 13:04:03 +0000	[thread overview]
Message-ID: <1358859844-14056-2-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1301221300520.29727@kaball.uk.xensource.com>

put_page on every entry in xenpage_list and page_list

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen/arch/arm/domain.c |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 17713f8..3e9a690 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -9,6 +9,7 @@
 #include <xen/grant_table.h>
 
 #include <asm/current.h>
+#include <asm/event.h>
 #include <asm/regs.h>
 #include <asm/p2m.h>
 #include <asm/irq.h>
@@ -517,11 +518,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)
-- 
1.7.2.5

  parent reply	other threads:[~2013-01-22 13:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22 13:03 [PATCH 0/3] xen/arm: domain destruction Stefano Stabellini
2013-01-22 13:04 ` [PATCH 1/3] xen/arm: implement arch_domain_destroy Stefano Stabellini
2013-01-22 13:04 ` Stefano Stabellini [this message]
2013-01-22 13:04 ` [PATCH 3/3] xen/arm: implement vcpu_timer_destroy Stefano Stabellini
2013-01-24 17:34 ` [PATCH 0/3] xen/arm: domain destruction Ian Campbell
2013-01-24 17:43   ` Tim Deegan
2013-02-05 11:35     ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358859844-14056-2-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).