[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xenpaging:add a new array to speed up page-in in xenpaging
# HG changeset patch # User hongkaixing<hongkaixing@xxxxxxxxxx> # 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@xxxxxxxxxx>,shizhen<bicky.shi@xxxxxxxxxx> 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 */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |