All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: xen-devel@lists.xensource.com
Subject: [PATCH 02/12] xenpaging: specify policy mru_size at runtime
Date: Mon, 10 Jan 2011 17:43:47 +0100	[thread overview]
Message-ID: <20110110164346.280482913@aepfle.de> (raw)
In-Reply-To: 20110110164345.521919826@aepfle.de

[-- Attachment #1: xen-unstable.xenpaging.runtime_mru_size.patch --]
[-- Type: text/plain, Size: 3213 bytes --]

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>

---

Note: some work is still required to actually get the value into the
      environment of the process. Maybe it will become an config option
      at some point.

 tools/xenpaging/policy_default.c |   23 ++++++++++++++++++-----
 tools/xenpaging/xenpaging.c      |    8 ++++++++
 tools/xenpaging/xenpaging.h      |    1 +
 3 files changed, 27 insertions(+), 5 deletions(-)

--- xen-unstable.hg-4.1.22571.orig/tools/xenpaging/policy_default.c
+++ xen-unstable.hg-4.1.22571/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 lo
 
 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++;
 }
 
--- xen-unstable.hg-4.1.22571.orig/tools/xenpaging/xenpaging.c
+++ xen-unstable.hg-4.1.22571/tools/xenpaging/xenpaging.c
@@ -78,6 +78,7 @@ xenpaging_t *xenpaging_init(domid_t doma
     xenpaging_t *paging;
     xc_interface *xch;
     xentoollog_logger *dbg = NULL;
+    char *p;
     int rc;
 
     if ( getenv("XENPAGING_DEBUG") )
@@ -92,6 +93,13 @@ xenpaging_t *xenpaging_init(domid_t doma
     paging = malloc(sizeof(xenpaging_t));
     memset(paging, 0, sizeof(xenpaging_t));
 
+    p = getenv("XENPAGING_POLICY_MRU_SIZE");
+    if ( p && *p )
+    {
+         paging->policy_mru_size = atoi(p);
+         DPRINTF("Setting policy mru_size to %d\n", paging->policy_mru_size);
+    }
+
     /* Open connection to xen */
     paging->xc_handle = xch;
 
--- xen-unstable.hg-4.1.22571.orig/tools/xenpaging/xenpaging.h
+++ xen-unstable.hg-4.1.22571/tools/xenpaging/xenpaging.h
@@ -45,6 +45,7 @@ typedef struct xenpaging {
     unsigned long *bitmap;
 
     mem_event_t mem_event;
+    int policy_mru_size;
 } xenpaging_t;

  parent reply	other threads:[~2011-01-10 16:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 16:43 [PATCH 00/12] xenpaging changes for xen-unstable Olaf Hering
2011-01-10 16:43 ` [PATCH 01/12] xenpaging: remove domain_id and mfn from struct xenpaging_victim Olaf Hering
2011-01-10 16:43 ` Olaf Hering [this message]
2011-01-10 16:43 ` [PATCH 03/12] xenpaging: mkdir /var/lib/xen/xenpaging during make install Olaf Hering
2011-01-10 16:43 ` [PATCH 04/12] xenpaging: print page-in/page-out progress Olaf Hering
2011-01-10 16:43 ` [PATCH 05/12] xenpaging: make three functions static Olaf Hering
2011-01-11 18:36   ` Ian Jackson
2011-01-10 16:43 ` [PATCH 06/12] xenpaging: update machine_to_phys_mapping[] during page deallocation Olaf Hering
2011-01-11 10:37   ` Keir Fraser
2011-01-11 11:00     ` Olaf Hering
2011-01-11 11:29       ` Keir Fraser
2011-01-10 16:43 ` [PATCH 07/12] xenpaging: update machine_to_phys_mapping[] during page-in Olaf Hering
2011-01-10 16:43 ` [PATCH 08/12] xenpaging: drop paged pages in guest_remove_page Olaf Hering
2011-01-14 16:53   ` Olaf Hering
2011-01-10 16:43 ` [PATCH 09/12] xenpaging: prevent page-out of gfn 0x80 Olaf Hering
2011-01-10 16:43 ` [PATCH 10/12] xenpaging: handle HVMCOPY_gfn_paged_out in copy_from/to_user Olaf Hering
2011-01-10 16:43 ` [PATCH 11/12] xenpaging: start xenpaging via config option Olaf Hering
2011-01-10 16:43 ` [PATCH 12/12] xenpaging: document missing live migration Olaf Hering
2011-01-11 17:20 ` [PATCH 00/12] xenpaging changes for xen-unstable 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=20110110164346.280482913@aepfle.de \
    --to=olaf@aepfle.de \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.