xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mem sharing: Take care of domain reference for shared pages
@ 2012-04-04 15:48 Andres Lagar-Cavilla
  2012-04-05 10:09 ` Tim Deegan
  0 siblings, 1 reply; 2+ messages in thread
From: Andres Lagar-Cavilla @ 2012-04-04 15:48 UTC (permalink / raw)
  To: xen-devel; +Cc: andres, tim, adin

 xen/arch/x86/mm/mem_sharing.c |  8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)


Making a page sharable removes it from the previous owner's list. Making it
private adds it. These actions are similar to freeing or allocating a page.
Except that they were not minding the domain reference that is taken/dropped
when the first/last page is allocated/freed.

Without fixing this, a domain might remain zombie when destroyed if all its
pages are shared.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r 48763a117b2a -r 6a3e651ee3b6 xen/arch/x86/mm/mem_sharing.c
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -401,6 +401,7 @@ static int page_make_sharable(struct dom
                        struct page_info *page, 
                        int expected_refcnt)
 {
+    int drop_dom_ref;
     spin_lock(&d->page_alloc_lock);
 
     /* Change page type and count atomically */
@@ -430,8 +431,12 @@ static int page_make_sharable(struct dom
 
     page_set_owner(page, dom_cow);
     d->tot_pages--;
+    drop_dom_ref = (d->tot_pages == 0);
     page_list_del(page, &d->page_list);
     spin_unlock(&d->page_alloc_lock);
+
+    if ( drop_dom_ref )
+        put_domain(d);
     return 0;
 }
 
@@ -466,7 +471,8 @@ static int page_make_private(struct doma
     ASSERT(page_get_owner(page) == dom_cow);
     page_set_owner(page, d);
 
-    d->tot_pages++;
+    if ( d->tot_pages++ == 0 )
+        get_domain(d);
     page_list_add_tail(page, &d->page_list);
     spin_unlock(&d->page_alloc_lock);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/mem sharing: Take care of domain reference for shared pages
  2012-04-04 15:48 [PATCH] x86/mem sharing: Take care of domain reference for shared pages Andres Lagar-Cavilla
@ 2012-04-05 10:09 ` Tim Deegan
  0 siblings, 0 replies; 2+ messages in thread
From: Tim Deegan @ 2012-04-05 10:09 UTC (permalink / raw)
  To: Andres Lagar-Cavilla; +Cc: andres, adin, xen-devel

At 11:48 -0400 on 04 Apr (1333540112), Andres Lagar-Cavilla wrote:
> Making a page sharable removes it from the previous owner's list. Making it
> private adds it. These actions are similar to freeing or allocating a page.
> Except that they were not minding the domain reference that is taken/dropped
> when the first/last page is allocated/freed.
> 
> Without fixing this, a domain might remain zombie when destroyed if all its
> pages are shared.
> 
> Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

Applied, thanks.

Tim.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-05 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-04 15:48 [PATCH] x86/mem sharing: Take care of domain reference for shared pages Andres Lagar-Cavilla
2012-04-05 10:09 ` Tim Deegan

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).