All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: Patrick Colp <pjcolp@cs.ubc.ca>
Cc: xen-devel@lists.xensource.com
Subject: [PATCH] xenpaging: handle XENMEM_decrease_reservation
Date: Wed, 22 Sep 2010 17:38:40 +0200	[thread overview]
Message-ID: <20100922153839.GA25088@aepfle.de> (raw)
In-Reply-To: <20100915160521.GA16644@aepfle.de>


Handle paged-out pages for XENMEM_decrease_reservation memory op.

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

---
 tools/libxc/xc_domain.c |   38 ++++++++++++++++++++++++++------------
 xen/common/memory.c     |    4 ++++
 2 files changed, 30 insertions(+), 12 deletions(-)

--- xen-unstable.hg-4.1.22155.orig/tools/libxc/xc_domain.c
+++ xen-unstable.hg-4.1.22155/tools/libxc/xc_domain.c
@@ -620,15 +620,15 @@ int xc_domain_memory_decrease_reservatio
                                           xen_pfn_t *extent_start)
 {
     int err;
+    unsigned long delay = 0;
+    unsigned long start = 0;
+    unsigned long count= nr_extents;
     struct xen_memory_reservation reservation = {
-        .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .mem_flags    = 0,
         .domid        = domid
     };
 
-    set_xen_guest_handle(reservation.extent_start, extent_start);
-
     if ( extent_start == NULL )
     {
         DPRINTF("decrease_reservation extent_start is NULL!\n");
@@ -636,16 +636,30 @@ int xc_domain_memory_decrease_reservatio
         return -1;
     }
 
-    err = xc_memory_op(xch, XENMEM_decrease_reservation, &reservation);
-    if ( err == nr_extents )
-        return 0;
+    while (1) {
+        set_xen_guest_handle(reservation.extent_start, extent_start + start);
+        reservation.nr_extents = count;
 
-    if ( err >= 0 )
-    {
-        DPRINTF("Failed deallocation for dom %d: %ld extents of order %d\n",
-                domid, nr_extents, extent_order);
-        errno = EINVAL;
-        err = -1;
+        err = xc_memory_op(xch, XENMEM_decrease_reservation, &reservation);
+        if ( err == count )
+        {
+            err = 0;
+            break;
+        }
+
+        if ( err > count || err <= 0 || delay > 1000 * 1000)
+        {
+            DPRINTF("Failed deallocation for dom %d: %ld extents of order %d: 0x%x\n",
+                    domid, nr_extents, extent_order, err);
+            errno = EINVAL;
+            err = -1;
+            break;
+        }
+
+        start += err;
+        count -= err;
+        usleep(delay);
+        delay += 666; /* 1500 iterations, 12 seconds */
     }
 
     return err;
--- xen-unstable.hg-4.1.22155.orig/xen/common/memory.c
+++ xen-unstable.hg-4.1.22155/xen/common/memory.c
@@ -162,6 +162,10 @@ int guest_remove_page(struct domain *d,
 
 #ifdef CONFIG_X86
     mfn = mfn_x(gfn_to_mfn(p2m_get_hostp2m(d), gmfn, &p2mt)); 
+    if ( p2m_is_paged(p2mt) )
+        p2m_mem_paging_populate(p2m_get_hostp2m(d), gmfn);
+    if ( p2m_is_paging(p2mt) )
+        return -ENOENT;
 #else
     mfn = gmfn_to_mfn(d, gmfn);
 #endif

  parent reply	other threads:[~2010-09-22 15:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-15 16:05 xenpaging fixes for kernel and hypervisor Olaf Hering
2010-09-15 16:08 ` [PATCH] xenpaging: handle GNTST_eagain in kernel drivers Olaf Hering
2010-09-16  3:44   ` Patrick Colp
2010-09-16  9:05     ` Keir Fraser
2010-09-16 13:33     ` Olaf Hering
2010-09-15 16:10 ` [PATCH] xenpaging: page-in granttable entries Olaf Hering
2010-09-15 16:11 ` [PATCH] xenpaging: fix crash in notify_via_xen_event_channel Olaf Hering
2010-09-15 16:12 ` [PATCH] xenpaging: avoid empty pagefile on unsupported hardware Olaf Hering
2010-09-22 15:38 ` Olaf Hering [this message]
2010-09-22 15:40 ` [PATCH] xenpaging: break endless loop during inital page-out with large pagefiles Olaf Hering
2010-09-22 15:41 ` [PATCH] xenpaging: allow only one xenpaging call per guest Olaf Hering
2010-09-22 15:48 ` xenpaging fixes for kernel and hypervisor Olaf Hering
2010-09-22 16:49   ` Patrick Colp
2010-09-22 17:13     ` Keir Fraser
2010-09-22 17:14     ` Keir Fraser
2010-09-22 17:20     ` Olaf Hering

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=20100922153839.GA25088@aepfle.de \
    --to=olaf@aepfle.de \
    --cc=pjcolp@cs.ubc.ca \
    --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.