xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xenpaging:add a new array to speed up page-in in xenpaging
@ 2012-01-05  3:08 hongkaixing
  2012-01-05 18:27 ` Ian Jackson
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: hongkaixing @ 2012-01-05  3:08 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 3997 bytes --]

# HG changeset patch
# User hongkaixing<hongkaixing@huawei.com>
# Date 1325149704 -28800
# Node ID 052727b8165ce6e05002184ae894096214c8b537
# Parent  54a5e994a241a506900ee0e197bb42e5f1d8e759
xenpaging:add a new array to speed up page-in in xenpaging

This patch adds a new array named page_out_index to reserve the victim's index.
When page in a page,it has to go through a for loop from 0 to num_pages to find
the right page to read,and it costs much time in this loop.After adding the
page_out_index array,it just reads the arrry to get the right page,and saves much time.

The following is a xenpaging test on suse11-64 with 4G memories.

Nums of page_out pages	Page out time	Page in time(in unstable code) Page in time(apply this patch)
512M(131072)		    2.6s		           540s			             530s
2G(524288)		    15.5s		           2088s			     2055s

Signed-off-by£ºhongkaixing<hongkaixing@huawei.com>,shizhen<bicky.shi@huawei.com>

diff -r 54a5e994a241 -r 052727b8165c tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c	Wed Nov 02 17:09:09 2011 +0000
+++ b/tools/xenpaging/xenpaging.c	Thu Dec 29 17:08:24 2011 +0800
@@ -599,6 +599,7 @@
     struct sigaction act;
     xenpaging_t *paging;
     xenpaging_victim_t *victims;
+    victim_to_i_t *page_out_index = NULL;
     mem_event_request_t req;
     mem_event_response_t rsp;
     int i;
@@ -637,6 +638,17 @@
     }
 
     victims = calloc(paging->num_pages, sizeof(xenpaging_victim_t));
+    if (NULL == victims)
+    {
+        ERROR("Failed to alloc memory\n");
+        goto out;
+    }
+    page_out_index = (victim_to_i_t *)calloc(paging->domain_info->max_pages, sizeof(victim_to_i_t));
+    if ( NULL == page_out_index )
+    {
+        ERROR("Failed to alloc memory\n");
+        goto out;
+    }
 
     /* ensure that if we get a signal, we'll do cleanup, then exit */
     act.sa_handler = close_handler;
@@ -660,6 +672,7 @@
             break;
         if ( i % 100 == 0 )
             DPRINTF("%d pages evicted\n", i);
+        page_out_index[victims[i].gfn].index=i;
     }
 
     DPRINTF("%d pages evicted. Done.\n", i);
@@ -687,17 +700,7 @@
             if ( test_and_clear_bit(req.gfn, paging->bitmap) )
             {
                 /* Find where in the paging file to read from */
-                for ( i = 0; i < paging->num_pages; i++ )
-                {
-                    if ( victims[i].gfn == req.gfn )
-                        break;
-                }
-    
-                if ( i >= paging->num_pages )
-                {
-                    DPRINTF("Couldn't find page %"PRIx64"\n", req.gfn);
-                    goto out;
-                }
+                i = page_out_index[req.gfn].index ;
                 
                 if ( req.flags & MEM_EVENT_FLAG_DROP_PAGE )
                 {
@@ -733,7 +736,11 @@
                 if ( interrupted )
                     victims[i].gfn = INVALID_MFN;
                 else
+                {
                     evict_victim(paging, &victims[i], fd, i);
+                    if( victims[i].gfn !=INVALID_MFN )
+                        page_out_index[victims[i].gfn].index = i;
+                }
             }
             else
             {
@@ -798,7 +805,15 @@
  out:
     close(fd);
     unlink_pagefile();
-    free(victims);
+    if ( NULL != victims )
+    {
+        free(victims);
+    }
+
+    if ( NULL != page_out_index )
+    {
+        free(page_out_index);
+    }
 
     /* Tear down domain paging */
     rc1 = xenpaging_teardown(paging);
diff -r 54a5e994a241 -r 052727b8165c tools/xenpaging/xenpaging.h
--- a/tools/xenpaging/xenpaging.h	Wed Nov 02 17:09:09 2011 +0000
+++ b/tools/xenpaging/xenpaging.h	Thu Dec 29 17:08:24 2011 +0800
@@ -54,6 +54,10 @@
     unsigned long pagein_queue[XENPAGING_PAGEIN_QUEUE_SIZE];
 } xenpaging_t;
 
+typedef struct victim_to_i {
+    /* the index of victim array to read from */
+    int index;
+} victim_to_i_t;
 
 typedef struct xenpaging_victim {
     /* the gfn of the page to evict */


[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-01-12 14:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-05  3:08 [PATCH] xenpaging:add a new array to speed up page-in in xenpaging hongkaixing
2012-01-05 18:27 ` Ian Jackson
2012-01-06  2:35   ` Hongkaixing
2012-01-05 18:31 ` Ian Jackson
2012-01-06  2:35   ` Hongkaixing
2012-01-10 17:39     ` Olaf Hering
2012-01-11  7:15       ` Hongkaixing
2012-01-12 14:20         ` Olaf Hering
2012-01-09 11:50   ` Olaf Hering
2012-01-05 20:59 ` Olaf Hering
2012-01-06  2:35   ` Hongkaixing
2012-01-06 13:07   ` Olaf Hering
2012-01-07  8:55     ` Hongkaixing
2012-01-09 13:13       ` Olaf Hering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).