xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH 18 of 20] xenpaging: improve policy mru list handling
Date: Sun, 20 Nov 2011 19:34:23 +0100	[thread overview]
Message-ID: <ba84a323f2dfbdfd2430.1321814063@probook.site> (raw)
In-Reply-To: <patchbomb.1321814045@probook.site>

# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1321804970 -3600
# Node ID ba84a323f2dfbdfd2430d3897e616a0e1dd1e4d7
# Parent  deb016f351e55e924274b4ccfbb80cb71543fc3e
xenpaging: improve policy mru list handling

Without this change it is not possible to page-out all guest pages, then
trigger a page-in for all pages, and then page-out everything once
again. All pages in the mru list can not be paged out because they
remain active in the internal bitmap of paged pages.

Use the mru list only if the number of paged-out pages is larger than
the mru list. If the number is smaller, start to clear the mru list. In
case the number of paged-out pages drops to zero the mru list and the
internal bitmap will be empty as well.

Also add a new interface for dropped pages. If a gfn was dropped there
is no need to adjust the mru list because dropping a page is not usage
of a page.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

diff -r deb016f351e5 -r ba84a323f2df tools/xenpaging/policy.h
--- a/tools/xenpaging/policy.h
+++ b/tools/xenpaging/policy.h
@@ -32,6 +32,8 @@ int policy_init(xenpaging_t *paging);
 int policy_choose_victim(xenpaging_t *paging, xenpaging_victim_t *victim);
 void policy_notify_paged_out(unsigned long gfn);
 void policy_notify_paged_in(unsigned long gfn);
+void policy_notify_paged_in_nomru(unsigned long gfn);
+void policy_notify_dropped(unsigned long gfn);
 
 #endif // __XEN_PAGING_POLICY_H__
 
diff -r deb016f351e5 -r ba84a323f2df tools/xenpaging/policy_default.c
--- a/tools/xenpaging/policy_default.c
+++ b/tools/xenpaging/policy_default.c
@@ -57,7 +57,7 @@ int policy_init(xenpaging_t *paging)
     if ( paging->policy_mru_size > 0 )
         mru_size = paging->policy_mru_size;
     else
-        mru_size = DEFAULT_MRU_SIZE;
+        mru_size = paging->policy_mru_size = DEFAULT_MRU_SIZE;
 
     mru = malloc(sizeof(*mru) * mru_size);
     if ( mru == NULL )
@@ -120,17 +120,38 @@ void policy_notify_paged_out(unsigned lo
     clear_bit(gfn, unconsumed);
 }
 
-void policy_notify_paged_in(unsigned long gfn)
+static void policy_handle_paged_in(unsigned long gfn, int do_mru)
 {
     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;
+    if (do_mru) {
+        mru[i_mru & (mru_size - 1)] = gfn;
+    } else {
+        clear_bit(gfn, bitmap);
+        mru[i_mru & (mru_size - 1)] = INVALID_MFN;
+    }
+
     i_mru++;
 }
 
+void policy_notify_paged_in(unsigned long gfn)
+{
+    policy_handle_paged_in(gfn, 1);
+}
+
+void policy_notify_paged_in_nomru(unsigned long gfn)
+{
+    policy_handle_paged_in(gfn, 0);
+}
+
+void policy_notify_dropped(unsigned long gfn)
+{
+    clear_bit(gfn, bitmap);
+}
+
 
 /*
  * Local variables:
diff -r deb016f351e5 -r ba84a323f2df tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -615,7 +615,14 @@ static int xenpaging_resume_page(xenpagi
     /* Notify policy of page being paged in */
     if ( notify_policy )
     {
-        policy_notify_paged_in(rsp->gfn);
+        /*
+         * Do not add gfn to mru list if the target is lower than mru size.
+         * This allows page-out of these gfns if the target grows again.
+         */
+        if (paging->num_paged_out > paging->policy_mru_size)
+            policy_notify_paged_in(rsp->gfn);
+        else
+            policy_notify_paged_in_nomru(rsp->gfn);
 
        /* Record number of resumed pages */
        paging->num_paged_out--;
@@ -869,7 +876,7 @@ int main(int argc, char *argv[])
                 {
                     DPRINTF("drop_page ^ gfn %"PRIx64" pageslot %d\n", req.gfn, i);
                     /* Notify policy of page being dropped */
-                    policy_notify_paged_in(req.gfn);
+                    policy_notify_dropped(req.gfn);
                 }
                 else
                 {

  parent reply	other threads:[~2011-11-20 18:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-20 18:34 [PATCH 00 of 20] tools/xenpaging changes Olaf Hering
2011-11-20 18:34 ` [PATCH 01 of 20] xenpaging: remove filename from comment Olaf Hering
2011-11-20 18:34 ` [PATCH 02 of 20] xenpaging: remove obsolete comment in resume path Olaf Hering
2011-11-20 18:34 ` [PATCH 03 of 20] xenpaging: use PERROR to print errno Olaf Hering
2011-11-20 18:34 ` [PATCH 04 of 20] xenpaging: simplify file_op Olaf Hering
2011-11-20 18:34 ` [PATCH 05 of 20] xenpaging: print gfn in failure case Olaf Hering
2011-11-20 18:34 ` [PATCH 06 of 20] xenpaging: update xenpaging_init Olaf Hering
2011-11-20 18:34 ` [PATCH 07 of 20] xenpaging: remove xc_dominfo_t from paging_t Olaf Hering
2011-11-20 18:34 ` [PATCH 08 of 20] xenpaging: track the number of paged-out pages Olaf Hering
2011-11-20 18:34 ` [PATCH 09 of 20] xenpaging: move page add/resume loops into its own function Olaf Hering
2011-11-20 18:34 ` [PATCH 10 of 20] xenpaging: improve mainloop exit handling Olaf Hering
2011-11-20 18:34 ` [PATCH 11 of 20] libxc: add bitmap_clear function Olaf Hering
2011-11-20 18:34 ` [PATCH 12 of 20] xenpaging: retry unpageable gfns Olaf Hering
2011-11-20 18:34 ` [PATCH 13 of 20] xenpaging: install into LIBEXEC dir Olaf Hering
2011-11-20 18:34 ` [PATCH 14 of 20] xenpaging: add XEN_PAGING_DIR / libxl_xenpaging_dir_path() Olaf Hering
2011-11-20 18:34 ` [PATCH 15 of 20] xenpaging: use guests tot_pages as working target Olaf Hering
2011-11-20 18:34 ` [PATCH 16 of 20] xenpaging: watch the guests memory/target-tot_pages xenstore value Olaf Hering
2011-11-20 18:34 ` [PATCH 17 of 20] xenpaging: add cmdline interface for pager Olaf Hering
2011-11-20 18:34 ` Olaf Hering [this message]
2011-11-20 18:34 ` [PATCH 19 of 20] xenpaging: add debug to show received watch event Olaf Hering
2011-11-20 18:34 ` [PATCH 20 of 20] xenpaging: restrict pagefile permissions Olaf Hering
2011-11-24 19:22 ` [PATCH 00 of 20] tools/xenpaging changes 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=ba84a323f2dfbdfd2430.1321814063@probook.site \
    --to=olaf@aepfle.de \
    --cc=Ian.Jackson@eu.citrix.com \
    --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 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).