xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Gage Eads <geads@eecs.berkeley.edu>
To: xen-devel@lists.xen.org
Cc: ian.jackson@eu.citrix.com, ian.campbell@citrix.com,
	Gage Eads <geads@eecs.berkeley.edu>,
	stefano.stabellini@eu.citrix.com
Subject: [PATCH] xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf
Date: Wed,  2 Oct 2013 16:22:55 -0700	[thread overview]
Message-ID: <1380756175-23581-1-git-send-email-geads@eecs.berkeley.edu> (raw)

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

             reply	other threads:[~2013-10-02 23:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 23:22 Gage Eads [this message]
2013-10-14 14:33 ` [PATCH] xenpaging: removed hard-coded 4 KiB page size, now calculates page size with sysconf Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380756175-23581-1-git-send-email-geads@eecs.berkeley.edu \
    --to=geads@eecs.berkeley.edu \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).