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] xenpaging: handle temporary out-of-memory

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xenpaging: handle temporary out-of-memory conditions during page-in
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 27 Nov 2010 06:25:25 -0800
Delivery-date: Sat, 27 Nov 2010 06:27:53 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 Keir Fraser <keir@xxxxxxx>
# Date 1290781411 0
# Node ID 08158f001f19d158c523cb14c39e354a805e7e65
# Parent  c7b08fc1cb8df8e3f3ccf719a1a62bd8157472de
xenpaging: handle temporary out-of-memory conditions during page-in

p2m_mem_paging_prep() should return -ENOMEM if a new page could not be
allocated. This can be handled in xenpaging to retry the
page-in. Right now such condition would stall the guest because the
requested page will not come back, xenpaging simply exits. So
xenpaging could very well retry the allocation forever to rescue the
guest.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
---
 tools/xenpaging/xenpaging.c |   33 +++++++++++++++++++++++----------
 xen/arch/x86/mm/p2m.c       |    2 +-
 2 files changed, 24 insertions(+), 11 deletions(-)

diff -r c7b08fc1cb8d -r 08158f001f19 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c       Fri Nov 26 14:22:38 2010 +0000
+++ b/tools/xenpaging/xenpaging.c       Fri Nov 26 14:23:31 2010 +0000
@@ -26,6 +26,7 @@
 #include <stdarg.h>
 #include <time.h>
 #include <signal.h>
+#include <unistd.h>
 #include <xc_private.h>
 
 #include <xen/mem_event.h>
@@ -415,19 +416,31 @@ static int xenpaging_populate_page(
     unsigned long _gfn;
     void *page;
     int ret;
-
-    /* Tell Xen to allocate a page for the domain */
-    ret = xc_mem_paging_prep(paging->xc_handle, paging->mem_event.domain_id,
-                             *gfn);
-    if ( ret != 0 )
-    {
-        ERROR("Error preparing for page in");
-        goto out_map;
-    }
+    unsigned char oom = 0;
+
+    _gfn = *gfn;
+    do
+    {
+        /* Tell Xen to allocate a page for the domain */
+        ret = xc_mem_paging_prep(paging->xc_handle, 
paging->mem_event.domain_id,
+                                 _gfn);
+        if ( ret != 0 )
+        {
+            if ( errno == ENOMEM )
+            {
+                if ( oom++ == 0 )
+                    DPRINTF("ENOMEM while preparing gfn %lx\n", _gfn);
+                sleep(1);
+                continue;
+            }
+            ERROR("Error preparing for page in");
+            goto out_map;
+        }
+    }
+    while ( ret && !interrupted );
 
     /* Map page */
     ret = -EFAULT;
-    _gfn = *gfn;
     page = xc_map_foreign_pages(paging->xc_handle, paging->mem_event.domain_id,
                                 PROT_READ | PROT_WRITE, &_gfn, 1);
     *gfn = _gfn;
diff -r c7b08fc1cb8d -r 08158f001f19 xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c     Fri Nov 26 14:22:38 2010 +0000
+++ b/xen/arch/x86/mm/p2m.c     Fri Nov 26 14:23:31 2010 +0000
@@ -2802,7 +2802,7 @@ int p2m_mem_paging_prep(struct p2m_domai
     /* Get a free page */
     page = alloc_domheap_page(p2m->domain, 0);
     if ( unlikely(page == NULL) )
-        return -EINVAL;
+        return -ENOMEM;
 
     /* Fix p2m mapping */
     p2m_lock(p2m);

_______________________________________________
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] xenpaging: handle temporary out-of-memory conditions during page-in, Xen patchbot-unstable <=