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-changelog

[Xen-changelog] [xen-unstable] Use a static page for the frame_list in t

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Use a static page for the frame_list in the balloon driver.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Jun 2006 15:40:26 +0000
Delivery-date: Fri, 30 Jun 2006 08:43:59 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User shand@xxxxxxxxxxxxxxxxxxxxxxxx
# Node ID 9b35fada9e65417a72eae5cb7b7397b29cb8bdf1
# Parent  cb9443bfdff811619a94bebb5346ee74e936eee8
Use a static page for the frame_list in the balloon driver. 
Simplifies code and robustifies against oom situations. 

Signed-off-by: Steven Hand <steven@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c |   35 +++++----------------
 1 files changed, 9 insertions(+), 26 deletions(-)

diff -r cb9443bfdff8 -r 9b35fada9e65 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Jun 29 
10:48:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Jun 29 
11:17:24 2006 +0100
@@ -75,6 +75,9 @@ static unsigned long current_pages;
 static unsigned long current_pages;
 static unsigned long target_pages;
 
+/* We increase/decrease in batches which fit in a page */
+static unsigned long frame_list[PAGE_SIZE / sizeof(unsigned long)]; 
+
 /* VM /proc information for memory */
 extern unsigned long totalram_pages;
 
@@ -172,7 +175,7 @@ static unsigned long current_target(void
 
 static int increase_reservation(unsigned long nr_pages)
 {
-       unsigned long *frame_list, frame, pfn, i, flags;
+       unsigned long  pfn, i, flags;
        struct page   *page;
        long           rc;
        struct xen_memory_reservation reservation = {
@@ -181,15 +184,8 @@ static int increase_reservation(unsigned
                .domid        = DOMID_SELF
        };
 
-       if (nr_pages > (PAGE_SIZE / sizeof(unsigned long)))
-               nr_pages = PAGE_SIZE / sizeof(unsigned long);
-
-       frame_list = (unsigned long *)__get_free_page(GFP_KERNEL);
-       if (frame_list == NULL) {
-               frame_list = &frame;
-               if (nr_pages > 1)
-                       nr_pages = 1;
-       }
+       if (nr_pages > ARRAY_SIZE(frame_list))
+               nr_pages = ARRAY_SIZE(frame_list);
 
        balloon_lock(flags);
 
@@ -253,15 +249,12 @@ static int increase_reservation(unsigned
  out:
        balloon_unlock(flags);
 
-       if (frame_list != &frame)
-               free_page((unsigned long)frame_list);
-
        return 0;
 }
 
 static int decrease_reservation(unsigned long nr_pages)
 {
-       unsigned long *frame_list, frame, pfn, i, flags;
+       unsigned long  pfn, i, flags;
        struct page   *page;
        void          *v;
        int            need_sleep = 0;
@@ -272,15 +265,8 @@ static int decrease_reservation(unsigned
                .domid        = DOMID_SELF
        };
 
-       if (nr_pages > (PAGE_SIZE / sizeof(unsigned long)))
-               nr_pages = PAGE_SIZE / sizeof(unsigned long);
-
-       frame_list = (unsigned long *)__get_free_page(GFP_KERNEL);
-       if (frame_list == NULL) {
-               frame_list = &frame;
-               if (nr_pages > 1)
-                       nr_pages = 1;
-       }
+       if (nr_pages > ARRAY_SIZE(frame_list))
+               nr_pages = ARRAY_SIZE(frame_list);
 
        for (i = 0; i < nr_pages; i++) {
                if ((page = alloc_page(GFP_HIGHUSER)) == NULL) {
@@ -330,9 +316,6 @@ static int decrease_reservation(unsigned
        totalram_pages = current_pages;
 
        balloon_unlock(flags);
-
-       if (frame_list != &frame)
-               free_page((unsigned long)frame_list);
 
        return need_sleep;
 }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Use a static page for the frame_list in the balloon driver., Xen patchbot-unstable <=