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

[Xen-devel] [PATCH] balloon_dealloc_empty_page_range


  • To: "Keir Fraser" <Keir.Fraser@xxxxxxxxxxxx>
  • From: "Ross C Mcilroy" <mcilrorc@xxxxxxxxxxxxx>
  • Date: Mon, 22 Aug 2005 16:42:11 +0100
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 22 Aug 2005 15:40:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: AcWnBIONsAbMxc7HSPSOEgkEa/a+3wAKaWta
  • Thread-topic: [PATCH] balloon_dealloc_empty_page_range


Hi Keir,

> This could be implemented much more simply. Add a balloon interface
> function balloon_dealloc_empty_page_range(struct page *page, long
> nr_pfns).
>
> This function can simply iterate over the page range,
> balloon_append()ing each page. Then kick the balloon worker thread and
> you're done!
>
> Call that balloon function direct from your driver(s) (ie., don't
> bother defining a wrapper function in mm/hypervsior.c).
> alloc_lowmem_region will probably also get moved to the balloon driver
> at some point.
>
>   -- Keir


Yes, your right of course, thats much easier.  The patch below should do what you want.  It seems to work with my drivers fine.

The one problem with this approch is that the alloc_lowmem_region function allocates the smallest 2^x greater than the number of pages requested, therefore you either need to only allocate/dealloc in powers of 2, or remember to deallocate a different amount than was allocated. 

It might be worth having a simple wrapper in hypercall.c/h which deallocates to the nearest power to keep things semantically the same.  E.g.:

void deallocate_empty_lowmem_region(unsigned long vstart,
                                    unsigned long pages)
{
    balloon_dealloc_empty_page_range(virt_to_page((void *) vstart,
                                     (long) get_order(pages));
}


--------------------


# HG changeset patch
# User rcmcilro@xxxxxxxxxxxxxxxxxxxxx
# Node ID 787faafef2543a1cacbf98259a45bc347065b682
# Parent  7c05931c1d0b82babd600b7e3e712fc06b899ed9
balloon_dealloc_empty_page_range

Signed-of-by: Ross McIlroy <mcilrorc@xxxxxxxxxxxxx>

diff -r 7c05931c1d0b -r 787faafef254 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Mon Aug 22 14:07:43 2005
@@ -467,5 +467,18 @@
     schedule_work(&balloon_worker);
 }

+void balloon_dealloc_empty_page_range(struct page *page, long nr_pfns)
+{
+    long i;
+
+    for (i=0; i<nr_pfns; i++) {
+       balloon_append(page++);
+    }
+
+    schedule_work(&balloon_worker);
+}
+
 EXPORT_SYMBOL(balloon_update_driver_allowance);
 EXPORT_SYMBOL(balloon_put_pages);
+EXPORT_SYMBOL(balloon_dealloc_empty_page_range);
+
diff -r 7c05931c1d0b -r 787faafef254 linux-2.6-xen-sparse/include/asm-xen/balloon.h
--- a/linux-2.6-xen-sparse/include/asm-xen/balloon.h    Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/balloon.h    Mon Aug 22 14:07:43 2005
@@ -40,6 +40,9 @@
 /* Give up unmapped pages to the balloon driver. */
 extern void balloon_put_pages(unsigned long *mfn_list, unsigned long nr_mfns);

+/* deallocate an empty page ranges, freeing memory. */
+void balloon_dealloc_empty_page_range(struct page *page, long nr_pfns);
+
 /*
  * Prevent the balloon driver from changing the memory reservation during
  * a driver critical region.




_______________________________________________
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®.