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 16 of 20] xenpaging: watch the guests memory/target-tot_pages xenstore value
Date: Sun, 20 Nov 2011 19:34:21 +0100	[thread overview]
Message-ID: <bbe679f21208fd8f3341.1321814061@probook.site> (raw)
In-Reply-To: <patchbomb.1321814045@probook.site>

# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1321804967 -3600
# Node ID bbe679f21208fd8f3341e2d8556469c7b1e29d57
# Parent  827fcaf0d610dd0c54d3f1f305b2b8f12bd4240a
xenpaging: watch the guests memory/target-tot_pages xenstore value

Subsequent patches will use xenstored to store the numbers of pages
xenpaging is suppose to page-out.
Remove num_pages and use target_pages instead.

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

diff -r 827fcaf0d610 -r bbe679f21208 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -19,8 +19,10 @@
  */
 
 #define _XOPEN_SOURCE	600
+#define _GNU_SOURCE
 
 #include <inttypes.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <time.h>
@@ -35,6 +37,10 @@
 #include "policy.h"
 #include "xenpaging.h"
 
+/* Defines number of mfns a guest should use at a time, in KiB */
+#define WATCH_TARGETPAGES "memory/target-tot_pages"
+static char *watch_target_tot_pages;
+static char *dom_path;
 static char watch_token[16];
 static char filename[80];
 static int interrupted;
@@ -72,7 +78,7 @@ static int xenpaging_wait_for_event_or_t
 {
     xc_interface *xch = paging->xc_handle;
     xc_evtchn *xce = paging->mem_event.xce_handle;
-    char **vec;
+    char **vec, *val;
     unsigned int num;
     struct pollfd fd[2];
     int port;
@@ -111,6 +117,25 @@ static int xenpaging_wait_for_event_or_t
                     rc = 0;
                 }
             }
+            else if ( strcmp(vec[XS_WATCH_PATH], watch_target_tot_pages) == 0 )
+            {
+                int ret, target_tot_pages;
+                val = xs_read(paging->xs_handle, XBT_NULL, vec[XS_WATCH_PATH], NULL);
+                if ( val )
+                {
+                    ret = sscanf(val, "%d", &target_tot_pages);
+                    if ( ret > 0 )
+                    {
+                        /* KiB to pages */
+                        target_tot_pages >>= 2;
+                        if ( target_tot_pages < 0 || target_tot_pages > paging->max_pages )
+                            target_tot_pages = paging->max_pages;
+                        paging->target_tot_pages = target_tot_pages;
+                        DPRINTF("new target_tot_pages %d\n", target_tot_pages);
+                    }
+                    free(val);
+                }
+            }
             free(vec);
         }
     }
@@ -216,6 +241,25 @@ static xenpaging_t *xenpaging_init(domid
         goto err;
     }
 
+    /* Watch xenpagings working target */
+    dom_path = xs_get_domain_path(paging->xs_handle, domain_id);
+    if ( !dom_path )
+    {
+        PERROR("Could not find domain path\n");
+        goto err;
+    }
+    if ( asprintf(&watch_target_tot_pages, "%s/%s", dom_path, WATCH_TARGETPAGES) < 0 )
+    {
+        PERROR("Could not alloc watch path\n");
+        goto err;
+    }
+    DPRINTF("watching '%s'\n", watch_target_tot_pages);
+    if ( xs_watch(paging->xs_handle, watch_target_tot_pages, "") == false )
+    {
+        PERROR("Could not bind to xenpaging watch\n");
+        goto err;
+    }
+
     p = getenv("XENPAGING_POLICY_MRU_SIZE");
     if ( p && *p )
     {
@@ -342,6 +386,8 @@ static xenpaging_t *xenpaging_init(domid
             free(paging->mem_event.ring_page);
         }
 
+        free(dom_path);
+        free(watch_target_tot_pages);
         free(paging->bitmap);
         free(paging);
     }
@@ -357,6 +403,9 @@ static int xenpaging_teardown(xenpaging_
     if ( paging == NULL )
         return 0;
 
+    xs_unwatch(paging->xs_handle, watch_target_tot_pages, "");
+    xs_unwatch(paging->xs_handle, "@releaseDomain", watch_token);
+
     xch = paging->xc_handle;
     paging->xc_handle = NULL;
     /* Tear down domain paging in Xen */

  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 ` Olaf Hering [this message]
2011-11-20 18:34 ` [PATCH 17 of 20] xenpaging: add cmdline interface for pager Olaf Hering
2011-11-20 18:34 ` [PATCH 18 of 20] xenpaging: improve policy mru list handling Olaf Hering
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=bbe679f21208fd8f3341.1321814061@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).