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 14 of 18] libxc: simplify performance counters API

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 14 of 18] libxc: simplify performance counters API
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Tue, 12 Oct 2010 15:16:32 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Tue, 12 Oct 2010 07:39:04 -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 5e7e8cc9642550550c576808f237f02519b2669d
# Parent  91597ec2218db759eef6916dec73ea42560c1504
libxc: simplify performance counters 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 91597ec2218d -r 5e7e8cc96425 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
@@ -167,20 +167,29 @@ int xc_mca_op(xc_interface *xch, struct 
 }
 #endif
 
-int xc_perfc_control(xc_interface *xch,
-                     uint32_t opcode,
-                     xc_perfc_desc_t *desc,
-                     xc_perfc_val_t *val,
-                     int *nbr_desc,
-                     int *nbr_val)
+int xc_perfc_reset(xc_interface *xch)
+{
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_perfc_op;
+    sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_reset;
+    set_xen_guest_handle(sysctl.u.perfc_op.desc, NULL);
+    set_xen_guest_handle(sysctl.u.perfc_op.val, NULL);
+
+    return do_sysctl(xch, &sysctl);
+}
+
+int xc_perfc_query_number(xc_interface *xch,
+                          int *nbr_desc,
+                          int *nbr_val)
 {
     int rc;
     DECLARE_SYSCTL;
 
     sysctl.cmd = XEN_SYSCTL_perfc_op;
-    sysctl.u.perfc_op.cmd = opcode;
-    set_xen_guest_handle(sysctl.u.perfc_op.desc, desc);
-    set_xen_guest_handle(sysctl.u.perfc_op.val, val);
+    sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_query;
+    set_xen_guest_handle(sysctl.u.perfc_op.desc, NULL);
+    set_xen_guest_handle(sysctl.u.perfc_op.val, NULL);
 
     rc = do_sysctl(xch, &sysctl);
 
@@ -190,6 +199,20 @@ int xc_perfc_control(xc_interface *xch,
         *nbr_val = sysctl.u.perfc_op.nr_vals;
 
     return rc;
+}
+
+int xc_perfc_query(xc_interface *xch,
+                   xc_perfc_desc_t *desc,
+                   xc_perfc_val_t *val)
+{
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_perfc_op;
+    sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_query;
+    set_xen_guest_handle(sysctl.u.perfc_op.desc, desc);
+    set_xen_guest_handle(sysctl.u.perfc_op.val, val);
+
+    return do_sysctl(xch, &sysctl);
 }
 
 int xc_lockprof_control(xc_interface *xch,
diff -r 91597ec2218d -r 5e7e8cc96425 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
@@ -887,14 +887,15 @@ unsigned long xc_make_page_below_4G(xc_i
 
 typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t;
 typedef xen_sysctl_perfc_val_t xc_perfc_val_t;
+int xc_perfc_reset(xc_interface *xch);
+int xc_perfc_query_number(xc_interface *xch,
+                          int *nbr_desc,
+                          int *nbr_val);
 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val
    arrays. */
-int xc_perfc_control(xc_interface *xch,
-                     uint32_t op,
-                     xc_perfc_desc_t *desc,
-                     xc_perfc_val_t *val,
-                     int *nbr_desc,
-                     int *nbr_val);
+int xc_perfc_query(xc_interface *xch,
+                   xc_perfc_desc_t *desc,
+                   xc_perfc_val_t *val);
 
 typedef xen_sysctl_lockprof_data_t xc_lockprof_data_t;
 /* IMPORTANT: The caller is responsible for mlock()'ing the @data array. */
diff -r 91597ec2218d -r 5e7e8cc96425 tools/misc/xenperf.c
--- a/tools/misc/xenperf.c      Tue Oct 12 15:06:42 2010 +0100
+++ b/tools/misc/xenperf.c      Tue Oct 12 15:06:42 2010 +0100
@@ -137,8 +137,7 @@ int main(int argc, char *argv[])
     
     if ( reset )
     {
-        if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_reset,
-                              NULL, NULL, NULL, NULL) != 0 )
+        if ( xc_perfc_reset(xc_handle) != 0 )
         {
             fprintf(stderr, "Error reseting performance counters: %d (%s)\n",
                     errno, strerror(errno));
@@ -148,8 +147,7 @@ int main(int argc, char *argv[])
         return 0;
     }
 
-    if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
-                          NULL, NULL, &num_desc, &num_val) != 0 )
+    if ( xc_perfc_query_number(xc_handle, &num_desc, &num_val) != 0 )
     {
         fprintf(stderr, "Error getting number of perf counters: %d (%s)\n",
                 errno, strerror(errno));
@@ -169,8 +167,7 @@ int main(int argc, char *argv[])
         exit(-1);
     }
 
-    if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
-                          pcd, pcv, NULL, NULL) != 0 )
+    if ( xc_perfc_query(xc_handle, pcd, pcv) != 0 )
     {
         fprintf(stderr, "Error getting perf counter: %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>