All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH 00 of 25] libxc: Hypercall buffers
Date: Tue, 26 Oct 2010 17:37:13 +0200	[thread overview]
Message-ID: <20101026153713.GA17044@aepfle.de> (raw)
In-Reply-To: <patchbomb.1287756942@localhost.localdomain>


Ian,

is the usage like shown below ok, adding an offset +start to the
initial buffer? 

Olaf

--- xen-unstable.hg-4.1.22313.orig/tools/libxc/xc_domain.c
+++ xen-unstable.hg-4.1.22313/tools/libxc/xc_domain.c
@@ -572,6 +572,55 @@ int xc_domain_get_tsc_info(xc_interface
     return rc;
 }
 
+static int do_xenmem_op_retry(xc_interface *xch, int cmd, struct xen_memory_reservation *reservation, size_t len, unsigned long nr_extents, xen_pfn_t *extent_start)
+{
+    xen_pfn_t *es = extent_start;
+    DECLARE_HYPERCALL_BOUNCE(es, nr_extents * sizeof(*es), XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    int err = 0;
+    unsigned long count = nr_extents;
+    unsigned long delay = 0;
+    unsigned long start = 0;
+
+    fprintf(stderr, "%s: %d count %lx\n",__func__,cmd,count);
+
+    if ( xc_hypercall_bounce_pre(xch, es) )
+    {
+        PERROR("Could not bounce memory for XENMEM_* hypercall");
+        return -1;
+    }
+
+    while ( start < nr_extents )
+    {
+        es = extent_start + start;
+        set_xen_guest_handle(reservation->extent_start, es);
+        reservation->nr_extents = count;
+
+        err = do_memory_op(xch, cmd, reservation, len);
+        if ( err == count )
+            break;
+
+        if ( err > count || err < 0 )
+            break;
+
+        if ( delay > 1000 * 1000)
+        {
+            err = start;
+            break;
+        }
+
+        if ( err )
+            delay = 0;
+
+        start += err;
+        count -= err;
+        usleep(delay);
+        delay += 666; /* 1500 iterations, 12 seconds */
+    }
+    fprintf(stderr, "%s: %d err %x count %lx start %lx delay %lu/%lu\n",__func__,cmd,err,count,start,delay,delay/666);
+
+    xc_hypercall_bounce_post(xch, es);
+    return err;
+}
 
 int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid)
 {
@@ -643,10 +692,7 @@ int xc_domain_decrease_reservation(xc_in
                                    unsigned int extent_order,
                                    xen_pfn_t *extent_start)
 {
-    int err;
-    DECLARE_HYPERCALL_BOUNCE(extent_start, nr_extents * sizeof(*extent_start), XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
     struct xen_memory_reservation reservation = {
-        .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .mem_flags    = 0,
         .domid        = domid
@@ -659,18 +705,7 @@ int xc_domain_decrease_reservation(xc_in
         return -1;
     }
 
-    if ( xc_hypercall_bounce_pre(xch, extent_start) )
-    {
-        PERROR("Could not bounce memory for XENMEM_decrease_reservation hypercall");
-        return -1;
-    }
-    set_xen_guest_handle(reservation.extent_start, extent_start);
-
-    err = do_memory_op(xch, XENMEM_decrease_reservation, &reservation, sizeof(reservation));
-
-    xc_hypercall_bounce_post(xch, extent_start);
-
-    return err;
+    return do_xenmem_op_retry(xch, XENMEM_decrease_reservation, &reservation, sizeof(reservation), nr_extents, extent_start);
 }
 
 int xc_domain_decrease_reservation_exact(xc_interface *xch,
@@ -704,13 +739,20 @@ int xc_domain_add_to_physmap(xc_interfac
                              unsigned long idx,
                              xen_pfn_t gpfn)
 {
+    uint8_t delay = 0;
+    int rc;
     struct xen_add_to_physmap xatp = {
         .domid = domid,
         .space = space,
         .idx = idx,
         .gpfn = gpfn,
     };
-    return do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
+    do {
+        rc = do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
+        if ( rc < 0 && errno == ENOENT )
+            usleep(1000);
+    } while ( rc < 0 && errno == ENOENT && ++delay );
+    return rc;
 }
 
 int xc_domain_populate_physmap(xc_interface *xch,
@@ -720,26 +762,13 @@ int xc_domain_populate_physmap(xc_interf
                                unsigned int mem_flags,
                                xen_pfn_t *extent_start)
 {
-    int err;
-    DECLARE_HYPERCALL_BOUNCE(extent_start, nr_extents * sizeof(*extent_start), XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
     struct xen_memory_reservation reservation = {
-        .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .mem_flags    = mem_flags,
         .domid        = domid
     };
 
-    if ( xc_hypercall_bounce_pre(xch, extent_start) )
-    {
-        PERROR("Could not bounce memory for XENMEM_populate_physmap hypercall");
-        return -1;
-    }
-    set_xen_guest_handle(reservation.extent_start, extent_start);
-
-    err = do_memory_op(xch, XENMEM_populate_physmap, &reservation, sizeof(reservation));
-
-    xc_hypercall_bounce_post(xch, extent_start);
-    return err;
+    return do_xenmem_op_retry(xch, XENMEM_populate_physmap, &reservation, sizeof(reservation), nr_extents, extent_start);
 }
 
 int xc_domain_populate_physmap_exact(xc_interface *xch,
@@ -799,6 +828,7 @@ int xc_domain_memory_exchange_pages(xc_i
     set_xen_guest_handle(exchange.in.extent_start, in_extents);
     set_xen_guest_handle(exchange.out.extent_start, out_extents);
 
+    /* FIXME use do_xenmem_op_retry or some retry loop??? */
     rc = do_memory_op(xch, XENMEM_exchange, &exchange, sizeof(exchange));
 
 out:

  parent reply	other threads:[~2010-10-26 15:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 14:15 [PATCH 00 of 25] libxc: Hypercall buffers Ian Campbell
2010-10-22 14:15 ` [PATCH 01 of 25] libxc: infrastructure for hypercall safe data buffers Ian Campbell
2010-10-25 16:04   ` Ian Campbell
2010-10-26 11:23     ` Ian Jackson
2010-10-26 15:17       ` Olaf Hering
2010-10-26 15:24         ` Ian Campbell
2010-10-26 16:38           ` Ian Campbell
2010-10-26 18:47             ` Ian Campbell
2010-10-27  6:30               ` Olaf Hering
2010-10-27 11:25               ` Ian Jackson
2010-10-25 16:05   ` Ian Campbell
2010-10-22 14:15 ` [PATCH 02 of 25] libxc: convert xc_version over to hypercall buffers Ian Campbell
2010-10-22 14:15 ` [PATCH 03 of 25] libxc: convert domctl interfaces " Ian Campbell
2010-10-22 14:15 ` [PATCH 04 of 25] libxc: convert shadow domctl interfaces and save/restore " Ian Campbell
2010-10-22 14:15 ` [PATCH 05 of 25] libxc: convert sysctl interfaces " Ian Campbell
2010-10-22 14:15 ` [PATCH 06 of 25] libxc: convert watchdog interface " Ian Campbell
2010-10-22 14:15 ` [PATCH 07 of 25] libxc: convert acm interfaces " Ian Campbell
2010-10-22 14:15 ` [PATCH 08 of 25] libxc: convert evtchn " Ian Campbell
2010-10-22 14:15 ` [PATCH 09 of 25] libxc: convert schedop " Ian Campbell
2010-10-22 14:15 ` [PATCH 10 of 25] libxc: convert physdevop interface " Ian Campbell
2010-10-22 14:15 ` [PATCH 11 of 25] libxc: convert flask interfaces " Ian Campbell
2010-10-22 14:15 ` [PATCH 12 of 25] libxc: convert hvmop " Ian Campbell
2010-10-22 14:15 ` [PATCH 13 of 25] libxc: convert mca interface " Ian Campbell
2010-10-22 14:15 ` [PATCH 14 of 25] libxc: convert tmem " Ian Campbell
2010-10-22 14:15 ` [PATCH 15 of 25] libxc: convert gnttab interfaces " Ian Campbell
2010-10-22 14:15 ` [PATCH 16 of 25] libxc: convert memory op interface " Ian Campbell
2010-10-22 14:15 ` [PATCH 17 of 25] libxc: convert mmuext " Ian Campbell
2010-10-22 14:16 ` [PATCH 18 of 25] libxc: switch page offlining interfaces " Ian Campbell
2010-10-22 14:16 ` [PATCH 19 of 25] libxc: convert ia64 dom0vp interface " Ian Campbell
2010-10-22 14:16 ` [PATCH 20 of 25] python acm: use hypercall buffer interface Ian Campbell
2010-10-22 14:16 ` [PATCH 21 of 25] python xc: " Ian Campbell
2010-10-22 14:16 ` [PATCH 22 of 25] xenpm: use hypercall buffers Ian Campbell
2010-10-22 14:16 ` [PATCH 23 of 25] secpol: " Ian Campbell
2010-10-22 14:16 ` [PATCH 24 of 25] libxc: do not align/lock buffers which do not need it Ian Campbell
2010-10-22 14:16 ` [PATCH 25 of 25] libxc: finalise transition to hypercall buffers Ian Campbell
2010-10-26 15:37 ` Olaf Hering [this message]
2010-10-26 16:25   ` [PATCH 00 of 25] libxc: Hypercall buffers Ian Campbell
2010-10-27 14:53     ` Olaf Hering
2010-10-27 15:45       ` Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2010-10-21 10:58 Ian Campbell
2010-10-22 12:06 ` Ian Campbell

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=20101026153713.GA17044@aepfle.de \
    --to=olaf@aepfle.de \
    --cc=ian.campbell@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 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.