[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xenpaging: implement stack of free slots in pagefile



# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1329769124 -3600
# Node ID 4566a48436878af248dd8693c00bd1e3221d4150
# Parent  97a6ccbe6a1aa363c772f979a84ab10d681c19d6
xenpaging: implement stack of free slots in pagefile

Scanning the slot_to_gfn[] array for a free slot is expensive because
evict_pages() always needs to scan the whole array. Remember the last
slots freed during page-in requests and reuse them in evict_pages().

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---


diff -r 97a6ccbe6a1a -r 4566a4843687 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c       Mon Feb 20 21:18:44 2012 +0100
+++ b/tools/xenpaging/xenpaging.c       Mon Feb 20 21:18:44 2012 +0100
@@ -432,6 +432,11 @@
     if ( !paging->slot_to_gfn || !paging->gfn_to_slot )
         goto err;
 
+    /* Allocate stack for known free slots in pagefile */
+    paging->free_slot_stack = calloc(paging->max_pages, 
sizeof(*paging->free_slot_stack));
+    if ( !paging->free_slot_stack )
+        goto err;
+
     /* Initialise policy */
     rc = policy_init(paging);
     if ( rc != 0 )
@@ -483,6 +488,7 @@
 
         free(dom_path);
         free(watch_target_tot_pages);
+        free(paging->free_slot_stack);
         free(paging->slot_to_gfn);
         free(paging->gfn_to_slot);
         free(paging->bitmap);
@@ -807,6 +813,20 @@
     xc_interface *xch = paging->xc_handle;
     int rc, slot, num = 0;
 
+    /* Reuse known free slots */
+    while ( paging->stack_count > 0 && num < num_pages )
+    {
+        slot = paging->free_slot_stack[--paging->stack_count];
+        rc = evict_victim(paging, slot);
+        if ( rc )
+        {
+            num = rc < 0 ? -1 : num;
+            return num;
+        }
+        num++;
+    }
+
+    /* Scan all slots slots for remainders */
     for ( slot = 0; slot < paging->max_pages && num < num_pages; slot++ )
     {
         /* Slot is allocated */
@@ -930,6 +950,9 @@
 
                 /* Clear this pagefile slot */
                 paging->slot_to_gfn[slot] = 0;
+
+                /* Record this free slot */
+                paging->free_slot_stack[paging->stack_count++] = slot;
             }
             else
             {
diff -r 97a6ccbe6a1a -r 4566a4843687 tools/xenpaging/xenpaging.h
--- a/tools/xenpaging/xenpaging.h       Mon Feb 20 21:18:44 2012 +0100
+++ b/tools/xenpaging/xenpaging.h       Mon Feb 20 21:18:44 2012 +0100
@@ -60,6 +60,8 @@
     int policy_mru_size;
     int use_poll_timeout;
     int debug;
+    int stack_count;
+    int *free_slot_stack;
     unsigned long pagein_queue[XENPAGING_PAGEIN_QUEUE_SIZE];
 };
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.