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-devel

[Xen-devel] [PATCH 15 of 18] libxc: simplify lock profiling API

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 15 of 18] libxc: simplify lock profiling API
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Tue, 12 Oct 2010 15:16:33 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Tue, 12 Oct 2010 07:41:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1286892978@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1286892402 -3600
# Node ID af3e98227d919192f9cce637343c6163ecb23daa
# Parent  5e7e8cc9642550550c576808f237f02519b2669d
libxc: simplify lock profiling API

Current function has heavily overloaded semantics for the various
arguments. Separate out into more specific functions.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 5e7e8cc96425 -r af3e98227d91 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Tue Oct 12 15:06:42 2010 +0100
+++ b/tools/libxc/xc_misc.c     Tue Oct 12 15:06:42 2010 +0100
@@ -215,8 +215,35 @@ int xc_perfc_query(xc_interface *xch,
     return do_sysctl(xch, &sysctl);
 }
 
-int xc_lockprof_control(xc_interface *xch,
-                        uint32_t opcode,
+int xc_lockprof_reset(xc_interface *xch)
+{
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_lockprof_op;
+    sysctl.u.lockprof_op.cmd = XEN_SYSCTL_LOCKPROF_reset;
+    set_xen_guest_handle(sysctl.u.lockprof_op.data, NULL);
+
+    return do_sysctl(xch, &sysctl);
+}
+
+int xc_lockprof_query_number(xc_interface *xch,
+                             uint32_t *n_elems)
+{
+    int rc;
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_lockprof_op;
+    sysctl.u.lockprof_op.cmd = XEN_SYSCTL_LOCKPROF_query;
+    set_xen_guest_handle(sysctl.u.lockprof_op.data, NULL);
+
+    rc = do_sysctl(xch, &sysctl);
+
+    *n_elems = sysctl.u.lockprof_op.nr_elem;
+
+    return rc;
+}
+
+int xc_lockprof_query(xc_interface *xch,
                         uint32_t *n_elems,
                         uint64_t *time,
                         xc_lockprof_data_t *data)
@@ -225,16 +252,13 @@ int xc_lockprof_control(xc_interface *xc
     DECLARE_SYSCTL;
 
     sysctl.cmd = XEN_SYSCTL_lockprof_op;
-    sysctl.u.lockprof_op.cmd = opcode;
-    sysctl.u.lockprof_op.max_elem = n_elems ? *n_elems : 0;
+    sysctl.u.lockprof_op.cmd = XEN_SYSCTL_LOCKPROF_query;
+    sysctl.u.lockprof_op.max_elem = *n_elems;
     set_xen_guest_handle(sysctl.u.lockprof_op.data, data);
 
     rc = do_sysctl(xch, &sysctl);
 
-    if (n_elems)
-        *n_elems = sysctl.u.lockprof_op.nr_elem;
-    if (time)
-        *time = sysctl.u.lockprof_op.time;
+    *n_elems = sysctl.u.lockprof_op.nr_elem;
 
     return rc;
 }
diff -r 5e7e8cc96425 -r af3e98227d91 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Tue Oct 12 15:06:42 2010 +0100
+++ b/tools/libxc/xenctrl.h     Tue Oct 12 15:06:42 2010 +0100
@@ -898,12 +898,14 @@ int xc_perfc_query(xc_interface *xch,
                    xc_perfc_val_t *val);
 
 typedef xen_sysctl_lockprof_data_t xc_lockprof_data_t;
+int xc_lockprof_reset(xc_interface *xch);
+int xc_lockprof_query_number(xc_interface *xch,
+                             uint32_t *n_elems);
 /* IMPORTANT: The caller is responsible for mlock()'ing the @data array. */
-int xc_lockprof_control(xc_interface *xch,
-                        uint32_t opcode,
-                        uint32_t *n_elems,
-                        uint64_t *time,
-                        xc_lockprof_data_t *data);
+int xc_lockprof_query(xc_interface *xch,
+                      uint32_t *n_elems,
+                      uint64_t *time,
+                      xc_lockprof_data_t *data);
 
 /**
  * Memory maps a range within one domain to a local address range.  Mappings
diff -r 5e7e8cc96425 -r af3e98227d91 tools/misc/xenlockprof.c
--- a/tools/misc/xenlockprof.c  Tue Oct 12 15:06:42 2010 +0100
+++ b/tools/misc/xenlockprof.c  Tue Oct 12 15:06:42 2010 +0100
@@ -60,8 +60,7 @@ int main(int argc, char *argv[])
 
     if ( argc > 1 )
     {
-        if ( xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_reset, NULL,
-                                 NULL, NULL) != 0 )
+        if ( xc_lockprof_reset(xc_handle) != 0 )
         {
             fprintf(stderr, "Error reseting profile data: %d (%s)\n",
                     errno, strerror(errno));
@@ -71,8 +70,7 @@ int main(int argc, char *argv[])
     }
 
     n = 0;
-    if ( xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_query, &n,
-                             NULL, NULL) != 0 )
+    if ( xc_lockprof_query_number(xc_handle, &n) != 0 )
     {
         fprintf(stderr, "Error getting number of profile records: %d (%s)\n",
                 errno, strerror(errno));
@@ -89,8 +87,7 @@ int main(int argc, char *argv[])
     }
 
     i = n;
-    if ( xc_lockprof_control(xc_handle, XEN_SYSCTL_LOCKPROF_query, &i,
-                             &time, data) != 0 )
+    if ( xc_lockprof_query(xc_handle, &i, &time, data) != 0 )
     {
         fprintf(stderr, "Error getting profile records: %d (%s)\n",
                 errno, strerror(errno));

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

<Prev in Thread] Current Thread [Next in Thread>