From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] domctl: do away with tool stack based retrying Date: Wed, 11 Feb 2015 14:02:11 +0000 Message-ID: <54DB60E3.1040402@citrix.com> References: <54DB6B6D020000780005F100@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0481852775969718368==" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YLXrs-000782-Ub for xen-devel@lists.xenproject.org; Wed, 11 Feb 2015 14:02:17 +0000 In-Reply-To: <54DB6B6D020000780005F100@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel Cc: Wei Liu , Stefano Stabellini , Ian Jackson , Tim Deegan , Ian Campbell , Keir Fraser List-Id: xen-devel@lists.xenproject.org --===============0481852775969718368== Content-Type: multipart/alternative; boundary="------------040805060105080104030101" --------------040805060105080104030101 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable On 11/02/15 13:47, Jan Beulich wrote: > XEN_DOMCTL_destroydomain so far is being special cased in libxc to > reinvoke the operation when getting back EAGAIN. Quite a few other > domctl-s have gained continuations, so I see no reason not to use them > here too. > > Signed-off-by: Jan Beulich In particular, it ought to be much more efficient as it avoids the kernel/user context switches, and associated TLB flushes. Reviewed-by: Andrew Cooper > > --- a/tools/libxc/xc_domain.c > +++ b/tools/libxc/xc_domain.c > @@ -112,14 +112,10 @@ int xc_domain_unpause(xc_interface *xch, > int xc_domain_destroy(xc_interface *xch, > uint32_t domid) > { > - int ret; > DECLARE_DOMCTL; > domctl.cmd =3D XEN_DOMCTL_destroydomain; > domctl.domain =3D (domid_t)domid; > - do { > - ret =3D do_domctl(xch, &domctl); > - } while ( ret && (errno =3D=3D EAGAIN) ); > - return ret; > + return do_domctl(xch, &domctl); > } > =20 > int xc_domain_shutdown(xc_interface *xch, > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -617,13 +617,9 @@ int domain_kill(struct domain *d) > case DOMDYING_dying: > rc =3D domain_relinquish_resources(d); > if ( rc !=3D 0 ) > - { > - if ( rc =3D=3D -ERESTART ) > - rc =3D -EAGAIN; > break; > - } > if ( cpupool_move_domain(d, cpupool0) ) > - return -EAGAIN; > + return -ERESTART; > for_each_vcpu ( d, v ) > unmap_vcpu_info(v); > d->is_dying =3D DOMDYING_dead; > --- a/xen/common/domctl.c > +++ b/xen/common/domctl.c > @@ -692,10 +692,11 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe > break; > =20 > case XEN_DOMCTL_destroydomain: > - { > ret =3D domain_kill(d); > - } > - break; > + if ( ret =3D=3D -ERESTART ) > + ret =3D hypercall_create_continuation( > + __HYPERVISOR_domctl, "h", u_domctl); > + break; > =20 > case XEN_DOMCTL_setnodeaffinity: > { > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------040805060105080104030101 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: 8bit
On 11/02/15 13:47, Jan Beulich wrote:
XEN_DOMCTL_destroydomain so far is being special cased in libxc to
reinvoke the operation when getting back EAGAIN. Quite a few other
domctl-s have gained continuations, so I see no reason not to use them
here too.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

In particular, it ought to be much more efficient as it avoids the kernel/user context switches, and associated TLB flushes.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -112,14 +112,10 @@ int xc_domain_unpause(xc_interface *xch,
 int xc_domain_destroy(xc_interface *xch,
                       uint32_t domid)
 {
-    int ret;
     DECLARE_DOMCTL;
     domctl.cmd = XEN_DOMCTL_destroydomain;
     domctl.domain = (domid_t)domid;
-    do {
-        ret = do_domctl(xch, &domctl);
-    } while ( ret && (errno == EAGAIN) );
-    return ret;
+    return do_domctl(xch, &domctl);
 }
 
 int xc_domain_shutdown(xc_interface *xch,
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -617,13 +617,9 @@ int domain_kill(struct domain *d)
     case DOMDYING_dying:
         rc = domain_relinquish_resources(d);
         if ( rc != 0 )
-        {
-            if ( rc == -ERESTART )
-                rc = -EAGAIN;
             break;
-        }
         if ( cpupool_move_domain(d, cpupool0) )
-            return -EAGAIN;
+            return -ERESTART;
         for_each_vcpu ( d, v )
             unmap_vcpu_info(v);
         d->is_dying = DOMDYING_dead;
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -692,10 +692,11 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
     break;
 
     case XEN_DOMCTL_destroydomain:
-    {
         ret = domain_kill(d);
-    }
-    break;
+        if ( ret == -ERESTART )
+            ret = hypercall_create_continuation(
+                __HYPERVISOR_domctl, "h", u_domctl);
+        break;
 
     case XEN_DOMCTL_setnodeaffinity:
     {





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

--------------040805060105080104030101-- --===============0481852775969718368== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============0481852775969718368==--