WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxc support of memory paging.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxc support of memory paging.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Dec 2009 22:40:40 -0800
Delivery-date: Wed, 16 Dec 2009 22:43:19 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1261031275 0
# Node ID 5d2f68eab8dc504b91ee5876cfaf1dca6c8d636c
# Parent  9e67c0a752006cd169a67f9c7f5fdc3eac5194f4
libxc support of memory paging.

libxc accepts the new return code from privcmd mmap, which indicates a page
being mapped is actually paged out. Spin until the page is paged in and return
as normal to the caller. This allows memory paging to work transparently with
existing tools.

Since libxc runs in user-space, as does the pager, both processes will be
scheduled and run. This enables the page to be paged in without needing to
spin in kernel mode (which would cause a dead-lock).

Signed-off-by: Patrick Colp <Patrick.Colp@xxxxxxxxxx>
---
 tools/libxc/xc_linux.c |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletion(-)

diff -r 9e67c0a75200 -r 5d2f68eab8dc tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Thu Dec 17 06:27:55 2009 +0000
+++ b/tools/libxc/xc_linux.c    Thu Dec 17 06:27:55 2009 +0000
@@ -64,11 +64,34 @@ int xc_interface_close(int xc_handle)
     return close(xc_handle);
 }
 
+static int xc_map_foreign_batch_single(int xc_handle, uint32_t dom, int prot,
+                                       xen_pfn_t *mfn, unsigned long addr)
+{
+    privcmd_mmapbatch_t ioctlx;
+    int rc;
+
+    ioctlx.num = 1;
+    ioctlx.dom = dom;
+    ioctlx.addr = addr;
+    ioctlx.arr = mfn;
+
+    do
+    {
+        *mfn ^= XEN_DOMCTL_PFINFO_PAGEDTAB;
+        usleep(100);
+        rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
+    }
+    while ( (rc < 0) && (errno == ENOENT) );
+
+    return rc;
+}
+
 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
                            xen_pfn_t *arr, int num)
 {
     privcmd_mmapbatch_t ioctlx;
     void *addr;
+    int rc;
 
     addr = mmap(NULL, num << PAGE_SHIFT, prot, MAP_SHARED, xc_handle, 0);
     if ( addr == MAP_FAILED )
@@ -82,7 +105,27 @@ void *xc_map_foreign_batch(int xc_handle
     ioctlx.addr = (unsigned long)addr;
     ioctlx.arr = arr;
 
-    if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
+    rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
+    if ( (rc < 0) && (errno == ENOENT) )
+    {
+        int i;
+
+        for ( i = 0; i < num; i++ )
+        {
+            if ( (arr[i] & XEN_DOMCTL_PFINFO_LTAB_MASK) ==
+                 XEN_DOMCTL_PFINFO_PAGEDTAB )
+            {
+                unsigned long paged_addr = (unsigned long)addr + (i << 
PAGE_SHIFT);
+                rc = xc_map_foreign_batch_single(xc_handle, dom, prot, &arr[i],
+                                                 paged_addr);
+                if ( rc < 0 )
+                    goto out;
+            }
+        }
+    }
+
+ out:
+    if ( rc < 0 )
     {
         int saved_errno = errno;
         perror("xc_map_foreign_batch: ioctl failed");

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxc support of memory paging., Xen patchbot-unstable <=