xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: xen-devel@lists.xensource.com
Cc: george.dunlap@eu.citrix.com
Subject: [PATCH 3 of 4] tools: Introduce "allocate-only" page type for	migration
Date: Fri, 13 Jul 2012 11:21:19 +0200	[thread overview]
Message-ID: <0d1fbddee973517d24dc.1342171279@nehalem1> (raw)
In-Reply-To: <patchbomb.1342171276@nehalem1>

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

To detect presence of superpages on the receiver side, we need
to have strings of sequential pfns sent across on the first iteration
through the memory.  However, as we go through the memory, more and
more of it will be marked dirty, making it wasteful to send those pages.

This patch introduces a new PFINFO type, "XALLOC".  Like PFINFO_XTAB, it
indicates that there is no corresponding page present in the subsquent
page buffer.  However, unlike PFINFO_XTAB, it contains a pfn which should be
allocated.

This new type is only used for migration; but it's placed in
xen/public/domctl.h so that the value isn't reused.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>


3 files changed, 33 insertions(+), 22 deletions(-)
tools/libxc/xc_domain_restore.c |   35 +++++++++++++++++++----------------
tools/libxc/xc_domain_save.c    |   19 +++++++++++++------
xen/include/public/domctl.h     |    1 +



[-- Attachment #2: xen-4.1-testing.hg-4.patch --]
[-- Type: text/x-patch, Size: 7610 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1342171240 -7200
# Node ID 0d1fbddee973517d24dcc080be93d2e10a42b98f
# Parent  80c3e053c1726eeeddf11204ce7f25aefc2fd021
tools: Introduce "allocate-only" page type for migration

To detect presence of superpages on the receiver side, we need
to have strings of sequential pfns sent across on the first iteration
through the memory.  However, as we go through the memory, more and
more of it will be marked dirty, making it wasteful to send those pages.

This patch introduces a new PFINFO type, "XALLOC".  Like PFINFO_XTAB, it
indicates that there is no corresponding page present in the subsquent
page buffer.  However, unlike PFINFO_XTAB, it contains a pfn which should be
allocated.

This new type is only used for migration; but it's placed in
xen/public/domctl.h so that the value isn't reused.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>

diff -r 80c3e053c172 -r 0d1fbddee973 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c	Fri Jul 13 11:20:39 2012 +0200
+++ b/tools/libxc/xc_domain_restore.c	Fri Jul 13 11:20:40 2012 +0200
@@ -850,7 +850,8 @@ static int pagebuf_get_one(xc_interface 
 
     countpages = count;
     for (i = oldcount; i < buf->nr_pages; ++i)
-        if ((buf->pfn_types[i] & XEN_DOMCTL_PFINFO_LTAB_MASK) == XEN_DOMCTL_PFINFO_XTAB)
+        if ((buf->pfn_types[i] & XEN_DOMCTL_PFINFO_LTAB_MASK) == XEN_DOMCTL_PFINFO_XTAB
+            ||(buf->pfn_types[i] & XEN_DOMCTL_PFINFO_LTAB_MASK) == XEN_DOMCTL_PFINFO_XALLOC)
             --countpages;
 
     if (!countpages)
@@ -928,6 +929,7 @@ static int apply_batch(xc_interface *xch
         pfn      = pagebuf->pfn_types[i + curbatch] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
         pagetype = pagebuf->pfn_types[i + curbatch] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
+        /* For allocation purposes, treat XEN_DOMCTL_PFINFO_XALLOC as a normal page */
         if ( (pagetype != XEN_DOMCTL_PFINFO_XTAB) && 
              (ctx->p2m[pfn] == INVALID_P2M_ENTRY) )
         {
@@ -1039,21 +1041,21 @@ static int apply_batch(xc_interface *xch
         pfn      = pagebuf->pfn_types[i + curbatch] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
         pagetype = pagebuf->pfn_types[i + curbatch] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
-        if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
+        if ( pagetype != XEN_DOMCTL_PFINFO_XTAB
+             && ctx->p2m[pfn] == (INVALID_P2M_ENTRY-1) )
+        {
+            /* We just allocated a new mfn above; update p2m */
+            ctx->p2m[pfn] = ctx->p2m_batch[nr_mfns++]; 
+            ctx->nr_pfns++; 
+        }
+
+        /* setup region_mfn[] for batch map, if necessary.
+         * For HVM guests, this interface takes PFNs, not MFNs */
+        if ( pagetype == XEN_DOMCTL_PFINFO_XTAB
+             || pagetype == XEN_DOMCTL_PFINFO_XALLOC )
             region_mfn[i] = ~0UL; /* map will fail but we don't care */
-        else 
-        {
-            if ( ctx->p2m[pfn] == (INVALID_P2M_ENTRY-1) )
-            {
-                /* We just allocated a new mfn above; update p2m */
-                ctx->p2m[pfn] = ctx->p2m_batch[nr_mfns++]; 
-                ctx->nr_pfns++; 
-            }
-
-            /* setup region_mfn[] for batch map.
-             * For HVM guests, this interface takes PFNs, not MFNs */
+        else
             region_mfn[i] = hvm ? pfn : ctx->p2m[pfn]; 
-        }
     }
 
     /* Map relevant mfns */
@@ -1073,8 +1075,9 @@ static int apply_batch(xc_interface *xch
         pfn      = pagebuf->pfn_types[i + curbatch] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
         pagetype = pagebuf->pfn_types[i + curbatch] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
-        if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
-            /* a bogus/unmapped page: skip it */
+        if ( pagetype == XEN_DOMCTL_PFINFO_XTAB 
+             || pagetype == XEN_DOMCTL_PFINFO_XALLOC)
+            /* a bogus/unmapped/allocate-only page: skip it */
             continue;
 
         if (pfn_err[i])
diff -r 80c3e053c172 -r 0d1fbddee973 tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c	Fri Jul 13 11:20:39 2012 +0200
+++ b/tools/libxc/xc_domain_save.c	Fri Jul 13 11:20:40 2012 +0200
@@ -1258,13 +1258,15 @@ int xc_domain_save(xc_interface *xch, in
                 }
                 else
                 {
-                    if ( !last_iter &&
+                    int dont_skip = (last_iter || (superpages && iter==1));
+
+                    if ( !dont_skip &&
                          test_bit(n, to_send) &&
                          test_bit(n, to_skip) )
                         skip_this_iter++; /* stats keeping */
 
                     if ( !((test_bit(n, to_send) && !test_bit(n, to_skip)) ||
-                           (test_bit(n, to_send) && last_iter) ||
+                           (test_bit(n, to_send) && dont_skip) ||
                            (test_bit(n, to_fix)  && last_iter)) )
                         continue;
 
@@ -1277,7 +1279,7 @@ int xc_domain_save(xc_interface *xch, in
                     /*
                     ** we get here if:
                     **  1. page is marked to_send & hasn't already been re-dirtied
-                    **  2. (ignore to_skip in last iteration)
+                    **  2. (ignore to_skip in first and last iterations)
                     **  3. add in pages that still need fixup (net bufs)
                     */
 
@@ -1301,7 +1303,7 @@ int xc_domain_save(xc_interface *xch, in
                         set_bit(n, to_fix);
                         continue;
                     }
-
+                    
                     if ( last_iter &&
                          test_bit(n, to_fix) &&
                          !test_bit(n, to_send) )
@@ -1346,6 +1348,7 @@ int xc_domain_save(xc_interface *xch, in
                 {
                     if ( pfn_type[j] == XEN_DOMCTL_PFINFO_XTAB )
                         continue;
+
                     DPRINTF("map fail: page %i mfn %08lx err %d\n",
                             j, gmfn, pfn_err[j]);
                     pfn_type[j] = XEN_DOMCTL_PFINFO_XTAB;
@@ -1357,6 +1360,9 @@ int xc_domain_save(xc_interface *xch, in
                     DPRINTF("type fail: page %i mfn %08lx\n", j, gmfn);
                     continue;
                 }
+
+                if ( superpages && iter==1 && test_bit(gmfn, to_skip))
+                    pfn_type[j] = XEN_DOMCTL_PFINFO_XALLOC;
 
                 /* canonicalise mfn->pfn */
                 pfn_type[j] |= pfn_batch[j];
@@ -1432,8 +1438,9 @@ int xc_domain_save(xc_interface *xch, in
                     }
                 }
 
-                /* skip pages that aren't present */
-                if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
+                /* skip pages that aren't present or are alloc-only */
+                if ( pagetype == XEN_DOMCTL_PFINFO_XTAB
+                    || pagetype == XEN_DOMCTL_PFINFO_XALLOC )
                     continue;
 
                 pagetype &= XEN_DOMCTL_PFINFO_LTABTYPE_MASK;
diff -r 80c3e053c172 -r 0d1fbddee973 xen/include/public/domctl.h
--- a/xen/include/public/domctl.h	Fri Jul 13 11:20:39 2012 +0200
+++ b/xen/include/public/domctl.h	Fri Jul 13 11:20:40 2012 +0200
@@ -133,6 +133,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_getme
 #define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7U<<28)
 #define XEN_DOMCTL_PFINFO_LPINTAB (0x1U<<31)
 #define XEN_DOMCTL_PFINFO_XTAB    (0xfU<<28) /* invalid page */
+#define XEN_DOMCTL_PFINFO_XALLOC  (0xeU<<28) /* allocate-only page */
 #define XEN_DOMCTL_PFINFO_PAGEDTAB (0x8U<<28)
 #define XEN_DOMCTL_PFINFO_LTAB_MASK (0xfU<<28)
 

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2012-07-13  9:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13  9:21 [PATCH 0 of 4] Xen 4.1 backport of cs 23420-23423 Juergen Gross
2012-07-13  9:21 ` [PATCH 1 of 4] tools: libxc: Detect superpages on domain restore Juergen Gross
2012-07-13  9:21 ` [PATCH 2 of 4] tools: Save superpages in the same batch, to make detection easier Juergen Gross
2012-07-13  9:21 ` Juergen Gross [this message]
2012-07-13  9:21 ` [PATCH 4 of 4] tools: Enable superpages for HVM domains by default Juergen Gross
  -- strict thread matches above, loose matches on Subject: below --
2011-05-16 10:51 [PATCH 0 of 4] RESEND Use superpages on restore/migrate George Dunlap
2011-05-16 10:51 ` [PATCH 3 of 4] tools: Introduce "allocate-only" page type for migration George Dunlap

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=0d1fbddee973517d24dc.1342171279@nehalem1 \
    --to=juergen.gross@ts.fujitsu.com \
    --cc=george.dunlap@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).