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] xen: Fix selfballooning and ensure it doesn't go too

To: Konrad Wilk <konrad.wilk@xxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xen: Fix selfballooning and ensure it doesn't go too far
From: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Date: Sat, 24 Sep 2011 13:58:08 -0700 (PDT)
Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, David Vrabel <david.vrabel@xxxxxxxxxx>
Delivery-date: Sat, 24 Sep 2011 13:59:53 -0700
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
[PATCH] xen: Fix selfballooning and ensure it doesn't go too far

The balloon driver's "current_pages" is very different from
totalram_pages.  Self-ballooning needs to be driven by
the latter.  Also, Committed_AS doesn't account for pages
used by the kernel so enforce a floor for when there
are little or no user-space threads using memory.

Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>

diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c
index 6ea852e..e3e48f1 100644
--- a/drivers/xen/xen-selfballoon.c
+++ b/drivers/xen/xen-selfballoon.c
@@ -195,14 +195,13 @@ __setup("selfballooning", xen_selfballooning_setup);
  */
 static void selfballoon_process(struct work_struct *work)
 {
-       unsigned long cur_pages, goal_pages, tgt_pages;
+       unsigned long cur_pages, goal_pages, tgt_pages, floor_pages;
        bool reset_timer = false;
 
        if (xen_selfballooning_enabled) {
-               cur_pages = balloon_stats.current_pages;
+               cur_pages = totalram_pages;
                tgt_pages = cur_pages; /* default is no change */
-               goal_pages = percpu_counter_read_positive(&vm_committed_as) +
-                       balloon_stats.current_pages - totalram_pages;
+               goal_pages = percpu_counter_read_positive(&vm_committed_as);
 #ifdef CONFIG_FRONTSWAP
                /* allow space for frontswap pages to be repatriated */
                if (frontswap_selfshrinking && frontswap_enabled)
@@ -217,7 +216,13 @@ static void selfballoon_process(struct work_struct *work)
                                ((goal_pages - cur_pages) /
                                  selfballoon_uphysteresis);
                /* else if cur_pages == goal_pages, no change */
-               balloon_set_new_target(tgt_pages);
+               floor_pages = totalreserve_pages +
+                               (roundup_pow_of_two(max_pfn) >> 5);
+               /* don't balloon too far, lest OOMs occur... */
+               if (tgt_pages < floor_pages)
+                       tgt_pages = floor_pages;
+               balloon_set_new_target(tgt_pages +
+                       balloon_stats.current_pages - totalram_pages);
                reset_timer = true;
        }
 #ifdef CONFIG_FRONTSWAP

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

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