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

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



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


 


Rackspace

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