Skip to contentSkip to conversation

xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf

PATCH In review Gage Eads 2 participants 2 messages Oct 2, 2013 – Oct 14, 2013

lore
Share & tools
lore

Gage Eads

author
#0 lore raw

PATCH 1/1 xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf

---
 tools/xenpaging/xenpaging.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/xenpaging/xenpaging.c +5 -2
index 5ef2f09..8467818 100644
@@ -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;
Signature · 1 line
1.8.1.2
#1 lore raw

Gage Eads writes ("[PATCH] xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf"):

Quoted 1 line

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.