xenpaging: use flat index for pagefile and page-in requests
PATCH 1/1 xenpaging: use flat index for pagefile and page-in requests
# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1326290042 -3600
# Node ID 83cc7a3fbf4feb1f2a4492b1dcca4778ad81226a # Parent 9cdcedc133e5227c635dbb00bd4779015311107a
xenpaging: use flat index for pagefile and page-in requests
This change is based on an idea by <[email protected]> and <[email protected]>.
Scanning the victims[] array is time consuming with a large number of target pages. Replace the loop to find the slot in the pagefile which holds the requested gfn with an index.
Remove the victims array and replace it with a flat array. This array holds the gfn for a given slot in the pagefile. Adjust all users of the victims array.
Rename variable in main() from i to slot to clearify the meaning.
Update xenpaging_evict_page() to pass a pointer to xen_pfn_t to xc_map_foreign_pages().
Update policy_choose_victim() to return either a gfn or INVALID_MFN.
tools/xenpaging/policy.h +1 -1
@@ -29,7 +29,7 @@int policy_init (struct xenpaging *paging); -int policy_choose_victim (struct xenpaging *paging,struct victim *victim); +unsigned long policy_choose_victim (struct xenpaging *paging);void policy_notify_paged_out (unsigned long gfn);void policy_notify_paged_in (unsigned long gfn);void policy_notify_paged_in_nomru (unsigned long gfn);
tools/xenpaging/policy_default.c +3 -6
@@ -77,7 +77,7 @@ int policy_init(struct xenpaging *pagingreturn rc; } -int policy_choose_victim (struct xenpaging *paging,struct victim *victim) +unsigned long policy_choose_victim (struct xenpaging *paging) {xc_interface *xch = paging->xc_handle;unsigned long wrap = current_gfn;
@@ -102,16 +102,13 @@ int policy_choose_victim(struct xenpagin/* One more round before returning ENOSPC */ continue ; } - victim->gfn =INVALID_MFN ; -return -ENOSPC ; +return INVALID_MFN ; } }while (test_bit (current_gfn, bitmap) ||test_bit (current_gfn, unconsumed) );set_bit (current_gfn, unconsumed); - victim->gfn = current_gfn; - -return 0 ; +return current_gfn; }void policy_notify_paged_out (unsigned long gfn)
tools/xenpaging/xenpaging.c +49 -49
240 lines not on this page · raw message
tools/xenpaging/xenpaging.h +3 -7
@@ -46,6 +46,9 @@ struct xenpaging {unsigned long *bitmap; +unsigned long *slot_to_gfn; +int *gfn_to_slot; +struct mem_event mem_event;/* number of pages for which data structures were allocated */ int max_pages;
@@ -56,13 +59,6 @@ struct xenpaging {unsigned long pagein_queue[XENPAGING_PAGEIN_QUEUE_SIZE ]; }; - -struct victim { -/* the gfn of the page to evict */ -unsigned long gfn; -}; - -extern void create_page_in_thread (struct xenpaging *paging);extern void page_in_trigger (void );