debuggers.hg
changeset 22746:f87b1c194eb8
xenpaging: specify policy mru_size at runtime
The environment variable XENPAGING_POLICY_MRU_SIZE will change the
mru_size in the policy at runtime. Specifying the mru_size at runtime
allows the admin to keep more pages in memory so guests can make more
progress. Its also good for development to reduce the value to put
more pressure on the paging related code paths.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
The environment variable XENPAGING_POLICY_MRU_SIZE will change the
mru_size in the policy at runtime. Specifying the mru_size at runtime
allows the admin to keep more pages in memory so guests can make more
progress. Its also good for development to reduce the value to put
more pressure on the paging related code paths.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
author | Keir Fraser <keir@xen.org> |
---|---|
date | Tue Jan 11 10:32:05 2011 +0000 (2011-01-11) |
parents | f84ae053b7da |
children | af807bf09d1f |
files | tools/xenpaging/policy_default.c tools/xenpaging/xenpaging.c tools/xenpaging/xenpaging.h |
line diff
1.1 --- a/tools/xenpaging/policy_default.c Tue Jan 11 10:31:33 2011 +0000 1.2 +++ b/tools/xenpaging/policy_default.c Tue Jan 11 10:32:05 2011 +0000 1.3 @@ -26,11 +26,12 @@ 1.4 #include "policy.h" 1.5 1.6 1.7 -#define MRU_SIZE (1024 * 16) 1.8 +#define DEFAULT_MRU_SIZE (1024 * 16) 1.9 1.10 1.11 -static unsigned long mru[MRU_SIZE]; 1.12 +static unsigned long *mru; 1.13 static unsigned int i_mru; 1.14 +static unsigned int mru_size; 1.15 static unsigned long *bitmap; 1.16 static unsigned long *unconsumed; 1.17 static unsigned long current_gfn; 1.18 @@ -57,7 +58,19 @@ int policy_init(xenpaging_t *paging) 1.19 max_pages = paging->domain_info->max_pages; 1.20 1.21 /* Initialise MRU list of paged in pages */ 1.22 - for ( i = 0; i < MRU_SIZE; i++ ) 1.23 + if ( paging->policy_mru_size > 0 ) 1.24 + mru_size = paging->policy_mru_size; 1.25 + else 1.26 + mru_size = DEFAULT_MRU_SIZE; 1.27 + 1.28 + mru = malloc(sizeof(*mru) * mru_size); 1.29 + if ( mru == NULL ) 1.30 + { 1.31 + rc = -ENOMEM; 1.32 + goto out; 1.33 + } 1.34 + 1.35 + for ( i = 0; i < mru_size; i++ ) 1.36 mru[i] = INVALID_MFN; 1.37 1.38 /* Don't page out page 0 */ 1.39 @@ -100,12 +113,12 @@ void policy_notify_paged_out(unsigned lo 1.40 1.41 void policy_notify_paged_in(unsigned long gfn) 1.42 { 1.43 - unsigned long old_gfn = mru[i_mru & (MRU_SIZE - 1)]; 1.44 + unsigned long old_gfn = mru[i_mru & (mru_size - 1)]; 1.45 1.46 if ( old_gfn != INVALID_MFN ) 1.47 clear_bit(old_gfn, bitmap); 1.48 1.49 - mru[i_mru & (MRU_SIZE - 1)] = gfn; 1.50 + mru[i_mru & (mru_size - 1)] = gfn; 1.51 i_mru++; 1.52 } 1.53
2.1 --- a/tools/xenpaging/xenpaging.c Tue Jan 11 10:31:33 2011 +0000 2.2 +++ b/tools/xenpaging/xenpaging.c Tue Jan 11 10:32:05 2011 +0000 2.3 @@ -78,6 +78,7 @@ xenpaging_t *xenpaging_init(domid_t doma 2.4 xenpaging_t *paging; 2.5 xc_interface *xch; 2.6 xentoollog_logger *dbg = NULL; 2.7 + char *p; 2.8 int rc; 2.9 2.10 if ( getenv("XENPAGING_DEBUG") ) 2.11 @@ -92,6 +93,13 @@ xenpaging_t *xenpaging_init(domid_t doma 2.12 paging = malloc(sizeof(xenpaging_t)); 2.13 memset(paging, 0, sizeof(xenpaging_t)); 2.14 2.15 + p = getenv("XENPAGING_POLICY_MRU_SIZE"); 2.16 + if ( p && *p ) 2.17 + { 2.18 + paging->policy_mru_size = atoi(p); 2.19 + DPRINTF("Setting policy mru_size to %d\n", paging->policy_mru_size); 2.20 + } 2.21 + 2.22 /* Open connection to xen */ 2.23 paging->xc_handle = xch; 2.24