All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 2/2] xen: Simplify TSC domctls by removing double info field
@ 2015-05-26 11:14 Ian Campbell
  2015-05-26 12:17 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Campbell @ 2015-05-26 11:14 UTC (permalink / raw)
  To: jbeulich, andrew.cooper3; +Cc: Ian Campbell, xen-devel

There is no need to have this twice and we can simply inline
xen_guest_tsc_info into xen_domctl_tsc_info as well.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
---
 tools/libxc/xc_domain.c     |   23 ++++++++---------------
 xen/arch/x86/domctl.c       |   21 +++++++++------------
 xen/include/public/domctl.h |    9 ++-------
 3 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 7cb36d9..b01a7df 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -759,10 +759,10 @@ int xc_domain_set_tsc_info(xc_interface *xch,
     DECLARE_DOMCTL;
     domctl.cmd = XEN_DOMCTL_settscinfo;
     domctl.domain = (domid_t)domid;
-    domctl.u.tsc_info.info.tsc_mode = tsc_mode;
-    domctl.u.tsc_info.info.elapsed_nsec = elapsed_nsec;
-    domctl.u.tsc_info.info.gtsc_khz = gtsc_khz;
-    domctl.u.tsc_info.info.incarnation = incarnation;
+    domctl.u.tsc_info.tsc_mode = tsc_mode;
+    domctl.u.tsc_info.elapsed_nsec = elapsed_nsec;
+    domctl.u.tsc_info.gtsc_khz = gtsc_khz;
+    domctl.u.tsc_info.incarnation = incarnation;
     return do_domctl(xch, &domctl);
 }
 
@@ -775,24 +775,17 @@ int xc_domain_get_tsc_info(xc_interface *xch,
 {
     int rc;
     DECLARE_DOMCTL;
-    DECLARE_HYPERCALL_BUFFER(xen_guest_tsc_info_t, info);
-
-    info = xc_hypercall_buffer_alloc(xch, info, sizeof(*info));
-    if ( info == NULL )
-        return -1;
 
     domctl.cmd = XEN_DOMCTL_gettscinfo;
     domctl.domain = (domid_t)domid;
-    set_xen_guest_handle(domctl.u.tsc_info.out_info, info);
     rc = do_domctl(xch, &domctl);
     if ( rc == 0 )
     {
-        *tsc_mode = info->tsc_mode;
-        *elapsed_nsec = info->elapsed_nsec;
-        *gtsc_khz = info->gtsc_khz;
-        *incarnation = info->incarnation;
+        *tsc_mode = domctl.u.tsc_info.tsc_mode;
+        *elapsed_nsec = domctl.u.tsc_info.elapsed_nsec;
+        *gtsc_khz = domctl.u.tsc_info.gtsc_khz;
+        *incarnation = domctl.u.tsc_info.incarnation;
     }
-    xc_hypercall_buffer_free(xch, info);
     return rc;
 }
 
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 6d3fe91..5ea9409 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -856,16 +856,13 @@ long arch_do_domctl(
             ret = -EINVAL;
         else
         {
-            xen_guest_tsc_info_t info = { 0 };
-
             domain_pause(d);
-            tsc_get_info(d, &info.tsc_mode,
-                            &info.elapsed_nsec,
-                            &info.gtsc_khz,
-                            &info.incarnation);
+            tsc_get_info(d, &domctl->u.tsc_info.tsc_mode,
+                         &domctl->u.tsc_info.elapsed_nsec,
+                         &domctl->u.tsc_info.gtsc_khz,
+                         &domctl->u.tsc_info.incarnation);
             domain_unpause(d);
-            if ( copy_to_guest(domctl->u.tsc_info.out_info, &info, 1) )
-                ret = -EFAULT;
+            copyback = 1;
         }
         break;
 
@@ -875,10 +872,10 @@ long arch_do_domctl(
         else
         {
             domain_pause(d);
-            tsc_set_info(d, domctl->u.tsc_info.info.tsc_mode,
-                         domctl->u.tsc_info.info.elapsed_nsec,
-                         domctl->u.tsc_info.info.gtsc_khz,
-                         domctl->u.tsc_info.info.incarnation);
+            tsc_set_info(d, domctl->u.tsc_info.tsc_mode,
+                         domctl->u.tsc_info.elapsed_nsec,
+                         domctl->u.tsc_info.gtsc_khz,
+                         domctl->u.tsc_info.incarnation);
             domain_unpause(d);
         }
         break;
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 10b51ef..9eb5eb5 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -698,18 +698,13 @@ typedef struct xen_domctl_disable_migrate {
 
 /* XEN_DOMCTL_gettscinfo */
 /* XEN_DOMCTL_settscinfo */
-struct xen_guest_tsc_info {
+typedef struct xen_domctl_tsc_info {
+    /* IN/OUT */
     uint32_t tsc_mode;
     uint32_t gtsc_khz;
     uint32_t incarnation;
     uint32_t pad;
     uint64_aligned_t elapsed_nsec;
-};
-typedef struct xen_guest_tsc_info xen_guest_tsc_info_t;
-DEFINE_XEN_GUEST_HANDLE(xen_guest_tsc_info_t);
-typedef struct xen_domctl_tsc_info {
-    XEN_GUEST_HANDLE_64(xen_guest_tsc_info_t) out_info; /* OUT */
-    xen_guest_tsc_info_t info; /* IN */
 } xen_domctl_tsc_info_t;
 
 /* XEN_DOMCTL_gdbsx_guestmemio      guest mem io */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 2/2] xen: Simplify TSC domctls by removing double info field
  2015-05-26 11:14 [PATCH v2 2/2] xen: Simplify TSC domctls by removing double info field Ian Campbell
@ 2015-05-26 12:17 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2015-05-26 12:17 UTC (permalink / raw)
  To: Ian Campbell, jbeulich; +Cc: xen-devel

On 26/05/15 12:14, Ian Campbell wrote:
> There is no need to have this twice and we can simply inline
> xen_guest_tsc_info into xen_domctl_tsc_info as well.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

Nice diffstat.

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

> ---
> ---
>  tools/libxc/xc_domain.c     |   23 ++++++++---------------
>  xen/arch/x86/domctl.c       |   21 +++++++++------------
>  xen/include/public/domctl.h |    9 ++-------
>  3 files changed, 19 insertions(+), 34 deletions(-)
>
> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
> index 7cb36d9..b01a7df 100644
> --- a/tools/libxc/xc_domain.c
> +++ b/tools/libxc/xc_domain.c
> @@ -759,10 +759,10 @@ int xc_domain_set_tsc_info(xc_interface *xch,
>      DECLARE_DOMCTL;
>      domctl.cmd = XEN_DOMCTL_settscinfo;
>      domctl.domain = (domid_t)domid;
> -    domctl.u.tsc_info.info.tsc_mode = tsc_mode;
> -    domctl.u.tsc_info.info.elapsed_nsec = elapsed_nsec;
> -    domctl.u.tsc_info.info.gtsc_khz = gtsc_khz;
> -    domctl.u.tsc_info.info.incarnation = incarnation;
> +    domctl.u.tsc_info.tsc_mode = tsc_mode;
> +    domctl.u.tsc_info.elapsed_nsec = elapsed_nsec;
> +    domctl.u.tsc_info.gtsc_khz = gtsc_khz;
> +    domctl.u.tsc_info.incarnation = incarnation;
>      return do_domctl(xch, &domctl);
>  }
>  
> @@ -775,24 +775,17 @@ int xc_domain_get_tsc_info(xc_interface *xch,
>  {
>      int rc;
>      DECLARE_DOMCTL;
> -    DECLARE_HYPERCALL_BUFFER(xen_guest_tsc_info_t, info);
> -
> -    info = xc_hypercall_buffer_alloc(xch, info, sizeof(*info));
> -    if ( info == NULL )
> -        return -1;
>  
>      domctl.cmd = XEN_DOMCTL_gettscinfo;
>      domctl.domain = (domid_t)domid;
> -    set_xen_guest_handle(domctl.u.tsc_info.out_info, info);
>      rc = do_domctl(xch, &domctl);
>      if ( rc == 0 )
>      {
> -        *tsc_mode = info->tsc_mode;
> -        *elapsed_nsec = info->elapsed_nsec;
> -        *gtsc_khz = info->gtsc_khz;
> -        *incarnation = info->incarnation;
> +        *tsc_mode = domctl.u.tsc_info.tsc_mode;
> +        *elapsed_nsec = domctl.u.tsc_info.elapsed_nsec;
> +        *gtsc_khz = domctl.u.tsc_info.gtsc_khz;
> +        *incarnation = domctl.u.tsc_info.incarnation;
>      }
> -    xc_hypercall_buffer_free(xch, info);
>      return rc;
>  }
>  
> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> index 6d3fe91..5ea9409 100644
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -856,16 +856,13 @@ long arch_do_domctl(
>              ret = -EINVAL;
>          else
>          {
> -            xen_guest_tsc_info_t info = { 0 };
> -
>              domain_pause(d);
> -            tsc_get_info(d, &info.tsc_mode,
> -                            &info.elapsed_nsec,
> -                            &info.gtsc_khz,
> -                            &info.incarnation);
> +            tsc_get_info(d, &domctl->u.tsc_info.tsc_mode,
> +                         &domctl->u.tsc_info.elapsed_nsec,
> +                         &domctl->u.tsc_info.gtsc_khz,
> +                         &domctl->u.tsc_info.incarnation);
>              domain_unpause(d);
> -            if ( copy_to_guest(domctl->u.tsc_info.out_info, &info, 1) )
> -                ret = -EFAULT;
> +            copyback = 1;
>          }
>          break;
>  
> @@ -875,10 +872,10 @@ long arch_do_domctl(
>          else
>          {
>              domain_pause(d);
> -            tsc_set_info(d, domctl->u.tsc_info.info.tsc_mode,
> -                         domctl->u.tsc_info.info.elapsed_nsec,
> -                         domctl->u.tsc_info.info.gtsc_khz,
> -                         domctl->u.tsc_info.info.incarnation);
> +            tsc_set_info(d, domctl->u.tsc_info.tsc_mode,
> +                         domctl->u.tsc_info.elapsed_nsec,
> +                         domctl->u.tsc_info.gtsc_khz,
> +                         domctl->u.tsc_info.incarnation);
>              domain_unpause(d);
>          }
>          break;
> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
> index 10b51ef..9eb5eb5 100644
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -698,18 +698,13 @@ typedef struct xen_domctl_disable_migrate {
>  
>  /* XEN_DOMCTL_gettscinfo */
>  /* XEN_DOMCTL_settscinfo */
> -struct xen_guest_tsc_info {
> +typedef struct xen_domctl_tsc_info {
> +    /* IN/OUT */
>      uint32_t tsc_mode;
>      uint32_t gtsc_khz;
>      uint32_t incarnation;
>      uint32_t pad;
>      uint64_aligned_t elapsed_nsec;
> -};
> -typedef struct xen_guest_tsc_info xen_guest_tsc_info_t;
> -DEFINE_XEN_GUEST_HANDLE(xen_guest_tsc_info_t);
> -typedef struct xen_domctl_tsc_info {
> -    XEN_GUEST_HANDLE_64(xen_guest_tsc_info_t) out_info; /* OUT */
> -    xen_guest_tsc_info_t info; /* IN */
>  } xen_domctl_tsc_info_t;
>  
>  /* XEN_DOMCTL_gdbsx_guestmemio      guest mem io */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-26 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 11:14 [PATCH v2 2/2] xen: Simplify TSC domctls by removing double info field Ian Campbell
2015-05-26 12:17 ` Andrew Cooper

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.