WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] xenheap pages mapped by dom0

To: Jan Beulich <JBeulich@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] xenheap pages mapped by dom0
From: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Date: Fri, 18 Dec 2009 15:24:58 +0000
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 18 Dec 2009 07:25:27 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4B2B9FC50200007800026A53@xxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acp/7md7y8ndDRJxQ3mdmUpqwco9pQAB9qP7
Thread-topic: [Xen-devel] xenheap pages mapped by dom0
User-agent: Microsoft-Entourage/12.23.0.091001
On 18/12/2009 14:29, "Jan Beulich" <JBeulich@xxxxxxxxxx> wrote:

>>>> George Dunlap <George.Dunlap@xxxxxxxxxxxxx> 18.12.09 15:04 >>>
>> What's the standard practice regarding freeing xenheap pages that have
>> been shared with dom0 (and may currently be mapped)?  Do we need to
>> make sure they're unmapped before we free them, or can we just call
>> free_xenheap_pages() and let the reference counting take care of
>> actually freeing them when dom0 unmaps them (if ever)?
> 
> No, free_xenheap_pages() is what would be called when the refcount
> drops to zero. What you need to do is, afaics, a simply
> put_page_and_type(), which undoes the one type and one general
> reference share_xen_page_with_guest() installed. This will then
> either free the page right away (if Dom0 doesn't have it mapped) or
> defer freeing until when Dom0 unmaps it.

In fact not. put_page() calls free_domheap_page() when the refcnt falls to
zero. And free_domheap_page() does not actually free Xen-heap pages: it is
expected that this will happen explicitly later (e.g., when domain is
destroyed) -- this is to deal with Xen itself possibly still using those
pages, and those uses are not reference counted.

I think the right thing to do would be very roughly:
On allocation:
 page = alloc_xenheap_page();
 share_xen_page_with_guest(page);
On deallocation:
 if (test_and_clear(PGC_allocated)) put_page();
 if (page->count_info & PGC_count_mask) return -EBUSY;
 free_xenheap_page(page);

 -- Keir



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel