xenpaging: retry unpageable gfns
authorOlaf Hering <olaf@aepfle.de>
Sun, 20 Nov 2011 16:02:41 +0000 (17:02 +0100)
committerOlaf Hering <olaf@aepfle.de>
Sun, 20 Nov 2011 16:02:41 +0000 (17:02 +0100)
Nomination of gfns can fail, but may succeed later.
Thats the case for a guest that starts ballooned.

v2:
 - print debug when clearing uncosumed happens

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
tools/xenpaging/policy_default.c

index 55a77b84032ed9e0ce366c5c418e3642f8698d3f..57da85d0762bdb5f80bb9528e1b0be79c64c04f6 100644 (file)
@@ -32,6 +32,7 @@ static unsigned int i_mru;
 static unsigned int mru_size;
 static unsigned long *bitmap;
 static unsigned long *unconsumed;
+static unsigned int unconsumed_cleared;
 static unsigned long current_gfn;
 static unsigned long max_pages;
 
@@ -87,8 +88,21 @@ int policy_choose_victim(xenpaging_t *paging, xenpaging_victim_t *victim)
         current_gfn++;
         if ( current_gfn >= max_pages )
             current_gfn = 0;
+        /* Could not nominate any gfn */
         if ( wrap == current_gfn )
         {
+            /* Count wrap arounds */
+            unconsumed_cleared++;
+            /* Force retry every few seconds (depends on poll() timeout) */
+            if ( unconsumed_cleared > 123)
+            {
+                /* Force retry of unconsumed gfns */
+                bitmap_clear(unconsumed, max_pages);
+                unconsumed_cleared = 0;
+                DPRINTF("clearing unconsumed, wrap %lx", wrap);
+                /* One more round before returning ENOSPC */
+                continue;
+            }
             victim->gfn = INVALID_MFN;
             return -ENOSPC;
         }