aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenpaging/policy_default.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2011-01-11 10:32:05 +0000
committerKeir Fraser <keir@xen.org>2011-01-11 10:32:05 +0000
commit2dc5d916ff3b77a44bff7c5cef97c723eaf01367 (patch)
treeca0e281264e3604838c4e2dab815d010b6b55d83 /tools/xenpaging/policy_default.c
parent56f2a91b86c48d976d9e7908b218575da740016d (diff)
downloadxen-2dc5d916ff3b77a44bff7c5cef97c723eaf01367.tar.gz
xen-2dc5d916ff3b77a44bff7c5cef97c723eaf01367.tar.bz2
xen-2dc5d916ff3b77a44bff7c5cef97c723eaf01367.zip
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>
Diffstat (limited to 'tools/xenpaging/policy_default.c')
-rw-r--r--tools/xenpaging/policy_default.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/xenpaging/policy_default.c b/tools/xenpaging/policy_default.c
index 2ab96b79c5..a53f5560f6 100644
--- a/tools/xenpaging/policy_default.c
+++ b/tools/xenpaging/policy_default.c
@@ -26,11 +26,12 @@
#include "policy.h"
-#define MRU_SIZE (1024 * 16)
+#define DEFAULT_MRU_SIZE (1024 * 16)
-static unsigned long mru[MRU_SIZE];
+static unsigned long *mru;
static unsigned int i_mru;
+static unsigned int mru_size;
static unsigned long *bitmap;
static unsigned long *unconsumed;
static unsigned long current_gfn;
@@ -57,7 +58,19 @@ int policy_init(xenpaging_t *paging)
max_pages = paging->domain_info->max_pages;
/* Initialise MRU list of paged in pages */
- for ( i = 0; i < MRU_SIZE; i++ )
+ if ( paging->policy_mru_size > 0 )
+ mru_size = paging->policy_mru_size;
+ else
+ mru_size = DEFAULT_MRU_SIZE;
+
+ mru = malloc(sizeof(*mru) * mru_size);
+ if ( mru == NULL )
+ {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ for ( i = 0; i < mru_size; i++ )
mru[i] = INVALID_MFN;
/* Don't page out page 0 */
@@ -100,12 +113,12 @@ void policy_notify_paged_out(unsigned long gfn)
void policy_notify_paged_in(unsigned long gfn)
{
- unsigned long old_gfn = mru[i_mru & (MRU_SIZE - 1)];
+ unsigned long old_gfn = mru[i_mru & (mru_size - 1)];
if ( old_gfn != INVALID_MFN )
clear_bit(old_gfn, bitmap);
- mru[i_mru & (MRU_SIZE - 1)] = gfn;
+ mru[i_mru & (mru_size - 1)] = gfn;
i_mru++;
}