All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xensource.com
Cc: ian.jackson@citrix.com, andres@gridcentric.ca, tim@xen.org,
	olaf@aepfle.de, adin@gridcentric.ca
Subject: [PATCH 3 of 3] Teach xenpaging to use the new and non-racy xc_mem_paging_load
Date: Thu, 01 Dec 2011 12:21:14 -0500	[thread overview]
Message-ID: <90ded86b0a30c34e1644.1322760074@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1322760071@xdev.gridcentric.ca>

 tools/xenpaging/xenpaging.c |  43 +++++++++++++++++++++----------------------
 1 files changed, 21 insertions(+), 22 deletions(-)


interface.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r e71f880c0518 -r 90ded86b0a30 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -45,6 +45,7 @@ static char *dom_path;
 static char watch_token[16];
 static char *filename;
 static int interrupted;
+static void *paging_buffer = NULL;
 
 static void unlink_pagefile(void)
 {
@@ -438,6 +439,13 @@ static xenpaging_t *xenpaging_init(int a
         goto err;
     }
 
+    paging_buffer = init_page();
+    if ( !paging_buffer )
+    {
+        ERROR("Creating page aligned load buffer");
+        goto err;
+    }
+
     return paging;
 
  err:
@@ -649,10 +657,20 @@ static int xenpaging_populate_page(xenpa
     unsigned char oom = 0;
 
     DPRINTF("populate_page < gfn %"PRI_xen_pfn" pageslot %d\n", gfn, i);
+
+    /* Read page */
+    ret = read_page(fd, paging_buffer, i);
+    if ( ret != 0 )
+    {
+        ERROR("Error reading page");
+        goto out;
+    }
+
     do
     {
         /* Tell Xen to allocate a page for the domain */
-        ret = xc_mem_paging_prep(xch, paging->mem_event.domain_id, gfn);
+        ret = xc_mem_paging_load(xch, paging->mem_event.domain_id, gfn,
+                                    paging_buffer);
         if ( ret != 0 )
         {
             if ( errno == ENOMEM )
@@ -662,33 +680,14 @@ static int xenpaging_populate_page(xenpa
                 sleep(1);
                 continue;
             }
-            PERROR("Error preparing %"PRI_xen_pfn" for page-in", gfn);
-            goto out_map;
+            PERROR("Error loading %"PRI_xen_pfn" during page-in", gfn);
+            goto out;
         }
     }
     while ( ret && !interrupted );
 
-    /* Map page */
-    ret = -EFAULT;
-    page = xc_map_foreign_pages(xch, paging->mem_event.domain_id,
-                                PROT_READ | PROT_WRITE, &gfn, 1);
-    if ( page == NULL )
-    {
-        PERROR("Error mapping page %"PRI_xen_pfn": page is null", gfn);
-        goto out_map;
-    }
-
-    /* Read page */
-    ret = read_page(fd, page, i);
-    if ( ret != 0 )
-    {
-        PERROR("Error reading page %"PRI_xen_pfn"", gfn);
-        goto out;
-    }
 
  out:
-    munmap(page, PAGE_SIZE);
- out_map:
     return ret;
 }

  parent reply	other threads:[~2011-12-01 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-01 17:21 [PATCH 0 of 3] Resend: correctness race when paging-in Andres Lagar-Cavilla
2011-12-01 17:21 ` [PATCH 1 of 3] After preparing a page for page-in, allow immediate fill-in of the page contents Andres Lagar-Cavilla
2011-12-01 17:39   ` Tim Deegan
2011-12-01 17:21 ` [PATCH 2 of 3] Tools: Libxc wrappers to automatically fill in page oud page contents on prepare Andres Lagar-Cavilla
2011-12-01 17:23   ` Ian Jackson
2011-12-01 17:21 ` Andres Lagar-Cavilla [this message]
2011-12-01 17:24   ` [PATCH 3 of 3] Teach xenpaging to use the new and non-racy xc_mem_paging_load Ian Jackson
2011-12-01 18:00   ` Olaf Hering
2011-12-01 18:21 ` [PATCH 0 of 3] Resend: correctness race when paging-in Tim Deegan

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=90ded86b0a30c34e1644.1322760074@xdev.gridcentric.ca \
    --to=andres@lagarcavilla.org \
    --cc=adin@gridcentric.ca \
    --cc=andres@gridcentric.ca \
    --cc=ian.jackson@citrix.com \
    --cc=olaf@aepfle.de \
    --cc=tim@xen.org \
    --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.