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

[Xen-devel] [PATCH] linux/balloon: Fix hugepage-related bugs

To: Jeremy Fitzhardinge <jeremy@xxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux/balloon: Fix hugepage-related bugs
From: Dave McCracken <dcm@xxxxxxxx>
Date: Mon, 21 Dec 2009 13:50:52 -0600
Cc: Xen Developers List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 21 Dec 2009 11:51:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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
Fix a couple of bugs in the hugepage changes to the Xen balloon driver.

Signed-off-by: Dave McCracken <dave.mccracken@xxxxxxxxxx>

--------

 balloon.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

--- 2.6-xen/drivers/xen/balloon.c       2009-12-17 14:20:57.000000000 -0600
+++ 2.6-xen-balloon//drivers/xen/balloon.c      2009-12-18 15:26:12.000000000 
-0600
@@ -283,7 +283,7 @@ static int increase_reservation(unsigned
                /* Relinquish the page back to the allocator. */
                ClearPageReserved(page);
                init_page_count(page);
-               __free_page(page);
+               __free_pages(page, balloon_order);
        }
 
        balloon_stats.current_pages += rc;
@@ -531,12 +531,13 @@ struct page **alloc_empty_pages_and_page
        /* Round up to next number of balloon_order pages */
        npages = (nr_pages + (balloon_npages-1)) >> balloon_order;
 
-       pagevec = kmalloc(sizeof(page) * nr_pages << balloon_order, GFP_KERNEL);
+       pagevec = kmalloc(sizeof(page) * nr_pages, GFP_KERNEL);
        if (pagevec == NULL)
                return NULL;
 
-       for (i = 0; i < nr_pages; i++) {
+       for (i = 0; i < npages; i++) {
                void *v;
+               int limit;
 
                page = alloc_pages(GFP_KERNEL|__GFP_COLD, balloon_order);
                if (page == NULL)
@@ -555,10 +556,14 @@ struct page **alloc_empty_pages_and_page
                if (ret != 0) {
                        mutex_unlock(&balloon_mutex);
                        //balloon_free_page(page); /* tries to use 
free_cold_page */
-                       __free_page(page);
+                       __free_pages(page, balloon_order);
                        goto err;
                }
-               for (j = 0; j < balloon_npages; j++)
+               if (i == (npages-1))
+                       limit = nr_pages - (i << balloon_order);
+               else
+                       limit = balloon_npages;
+               for (j = 0; j < limit; j++)
                        pagevec[(i<<balloon_order)+j] = page++;
 
                totalram_pages = balloon_stats.current_pages -= balloon_npages;
@@ -595,7 +600,7 @@ void free_empty_pages_and_pagevec(struct
        npages = (nr_pages + (balloon_npages-1)) >> balloon_order;
 
        mutex_lock(&balloon_mutex);
-       for (i = 0; i < nr_pages; i++) {
+       for (i = 0; i < npages; i++) {
                page = pagevec[i << balloon_order];
                BUG_ON(page_count(page) != 1);
                balloon_append(page);

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

<Prev in Thread] Current Thread [Next in Thread>