Gage Eads
2013-Oct-02 23:22 UTC
[PATCH] xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf
Signed-off-by: Gage Eads <geads@eecs.berkeley.edu> --- tools/xenpaging/xenpaging.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index 5ef2f09..8467818 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -44,6 +44,7 @@ static char *dom_path; static char watch_token[16]; static char *filename; static int interrupted; +static int page_size_KiB; static void unlink_pagefile(void) { @@ -129,7 +130,7 @@ static int xenpaging_wait_for_event_or_timeout(struct xenpaging *paging) if ( ret > 0 ) { /* KiB to pages */ - target_tot_pages >>= 2; + target_tot_pages /= page_size_KiB; if ( target_tot_pages < 0 || target_tot_pages > paging->max_pages ) target_tot_pages = paging->max_pages; paging->target_tot_pages = target_tot_pages; @@ -238,7 +239,7 @@ static int xenpaging_getopts(struct xenpaging *paging, int argc, char *argv[]) break; case ''m'': /* KiB to pages */ - paging->max_pages = atoi(optarg) >> 2; + paging->max_pages = atoi(optarg) / page_size_KiB; break; case ''r'': paging->policy_mru_size = atoi(optarg); @@ -288,6 +289,8 @@ static struct xenpaging *xenpaging_init(int argc, char *argv[]) if ( !paging ) goto err; + int page_size_KiB = sysconf(_SC_PAGESIZE)/1024; + /* Get cmdline options and domain_id */ if ( xenpaging_getopts(paging, argc, argv) ) goto err; -- 1.8.1.2
Ian Jackson
2013-Oct-14 14:33 UTC
Re: [PATCH] xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf
Gage Eads writes ("[PATCH] xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf"):> Signed-off-by: Gage Eads <geads@eecs.berkeley.edu>Is sysconf really the right place to get this from ? Surely what is relevant is the Xen page size, which is available from one of the Xen headers. Ian.