diff options
author | Olaf Hering <olaf@aepfle.de> | 2012-02-20 21:18:44 +0100 |
---|---|---|
committer | Olaf Hering <olaf@aepfle.de> | 2012-02-20 21:18:44 +0100 |
commit | 9245411c958f4c4a1e77e76b2e1fde699a56929e (patch) | |
tree | 3abb796d4b0b4df153d48518f1edb2a410ef3be7 /tools/xenpaging/policy_default.c | |
parent | 057d014a288437fef4d58379f1aabcc59a99ea57 (diff) | |
download | xen-9245411c958f4c4a1e77e76b2e1fde699a56929e.tar.gz xen-9245411c958f4c4a1e77e76b2e1fde699a56929e.tar.bz2 xen-9245411c958f4c4a1e77e76b2e1fde699a56929e.zip |
xenpaging: use flat index for pagefile and page-in requests
This change is based on an idea by <hongkaixing@huawei.com> and
<bicky.shi@huawei.com>.
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.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/xenpaging/policy_default.c')
-rw-r--r-- | tools/xenpaging/policy_default.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/tools/xenpaging/policy_default.c b/tools/xenpaging/policy_default.c index c5c71f1b37..596afc7d9a 100644 --- a/tools/xenpaging/policy_default.c +++ b/tools/xenpaging/policy_default.c @@ -77,7 +77,7 @@ int policy_init(struct xenpaging *paging) return 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 xenpaging *paging, struct victim *victim) /* 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) |