]> xenbits.xensource.com Git - libvirt.git/commitdiff
perf: add bus_cycles perf event support
authorNitesh Konkar <niteshkonkar.libvirt@gmail.com>
Tue, 13 Dec 2016 16:01:38 +0000 (21:31 +0530)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 15 Dec 2016 21:47:05 +0000 (16:47 -0500)
This patch adds support and documentation
for the bus_cycles perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
docs/formatdomain.html.in
docs/news.html.in
docs/schemas/domaincommon.rng
include/libvirt/libvirt-domain.h
src/libvirt-domain.c
src/qemu/qemu_driver.c
src/util/virperf.c
src/util/virperf.h
tests/genericxml2xmlindata/generic-perf.xml
tools/virsh.pod

index 086af551d4713dc8ff533cae80ce7208b9680e68..cd3182bb6f40d7580c936d6e6f86d20034c1b6b7 100644 (file)
   &lt;event name='cache_misses' enabled='no'/&gt;
   &lt;event name='branch_instructions' enabled='no'/&gt;
   &lt;event name='branch_misses' enabled='no'/&gt;
+  &lt;event name='bus_cycles' enabled='no'/&gt;
 &lt;/perf&gt;
 ...
 </pre>
       <td>the count of branch misses by applications running on the platform</td>
       <td><code>perf.branch_misses</code></td>
     </tr>
+    <tr>
+      <td><code>bus_cycles</code></td>
+      <td>the count of bus cycles by applications running on the platform</td>
+      <td><code>perf.bus_cycles</code></td>
+    </tr>
   </table>
 
     <h3><a name="elementsDevices">Devices</a></h3>
index 7f5f8b5a9e87ba2ac30b02244ea5d660fcbcb3c2..09e4c9544ac2870aca5d3101bd4c0115108a8f3e 100644 (file)
@@ -35,8 +35,9 @@
       <li><strong>Improvements</strong>
         <ul>
           <li>perf: Add more perf statistics<br/>
-          Add support to get the count of branch instructions executed
-          and branch misses by applications running on the platform
+          Add support to get the count of branch instructions executed,
+          branch misses, and bus cycles by applications running on
+          the platform
           </li>
         </ul>
       </li>
index bf8818dc0067216b78dced76ce76da710f1ec8e7..21a7afa47fd450f609b378bb909fc75bbf6a9df7 100644 (file)
               <value>cache_misses</value>
               <value>branch_instructions</value>
               <value>branch_misses</value>
+              <value>bus_cycles</value>
             </choice>
           </attribute>
           <attribute name="enabled">
index 3290b10ea82b9f2d3c918ac4d517a85f26f4ef19..6d74238bbd2c4928fccf69cfb3c161e860e9f878 100644 (file)
@@ -2145,6 +2145,16 @@ void virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats);
  */
 # define VIR_PERF_PARAM_BRANCH_MISSES "branch_misses"
 
+/**
+ * VIR_PERF_PARAM_BUS_CYCLES:
+ *
+ * Macro for typed parameter name that represents bus_cycles
+ * perf event which can be used to measure the count of bus cycles
+ * by applications running on the platform. It corresponds to the
+ * "perf.bus_cycles" field in the *Stats APIs.
+ */
+# define VIR_PERF_PARAM_BUS_CYCLES "bus_cycles"
+
 int virDomainGetPerfEvents(virDomainPtr dom,
                            virTypedParameterPtr *params,
                            int *nparams,
index dd9b8006638bbb59797d2a5850a253e9e18cc802..821801126706c6c59ad391cf8bf7925a5d341e8f 100644 (file)
@@ -11234,6 +11234,8 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
  *                                  branch_instructions perf event.
  *     "perf.branch_misses" - The count of branch misses as unsigned long
  *                            long. It is produced by branch_misses perf event.
+ *     "perf.bus_cycles" - The count of bus cycles as unsigned long
+ *                         long. It is produced by bus_cycles perf event.
  *
  * Note that entire stats groups or individual stat fields may be missing from
  * the output in case they are not supported by the given hypervisor, are not
index 8dc318a3884f956daea2881c0dc7d79e1e59786d..ee99d6f805bf2a4f3573bff00571b2b48dc89920 100644 (file)
@@ -9855,6 +9855,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
                                VIR_PERF_PARAM_CACHE_MISSES, VIR_TYPED_PARAM_BOOLEAN,
                                VIR_PERF_PARAM_BRANCH_INSTRUCTIONS, VIR_TYPED_PARAM_BOOLEAN,
                                VIR_PERF_PARAM_BRANCH_MISSES, VIR_TYPED_PARAM_BOOLEAN,
+                               VIR_PERF_PARAM_BUS_CYCLES, VIR_TYPED_PARAM_BOOLEAN,
                                NULL) < 0)
         return -1;
 
index 7f630da0f746153c26591281e76e12ca61dc3dcf..31a55859651d3632e9744029cc69a2ed8f14f533 100644 (file)
@@ -41,7 +41,8 @@ VIR_ENUM_IMPL(virPerfEvent, VIR_PERF_EVENT_LAST,
               "cmt", "mbmt", "mbml",
               "cpu_cycles", "instructions",
               "cache_references", "cache_misses",
-              "branch_instructions", "branch_misses");
+              "branch_instructions", "branch_misses",
+              "bus_cycles");
 
 struct virPerfEvent {
     int type;
@@ -92,6 +93,9 @@ static struct virPerfEventAttr attrs[] = {
     {.type = VIR_PERF_EVENT_BRANCH_MISSES,
      .attrType = PERF_TYPE_HARDWARE,
      .attrConfig = PERF_COUNT_HW_BRANCH_MISSES},
+    {.type = VIR_PERF_EVENT_BUS_CYCLES,
+     .attrType = PERF_TYPE_HARDWARE,
+     .attrConfig = PERF_COUNT_HW_BUS_CYCLES},
 };
 typedef struct virPerfEventAttr *virPerfEventAttrPtr;
 
index 7049a5b47e3f51fbacd985c14facb6a297b3a902..ac6d7895186b7d46969b65f0c3a50d10ec2fee20 100644 (file)
@@ -39,6 +39,7 @@ typedef enum {
     VIR_PERF_EVENT_BRANCH_INSTRUCTIONS, /* Count of branch instructions
                                            for applications */
     VIR_PERF_EVENT_BRANCH_MISSES,  /* Count of branch misses for applications */
+    VIR_PERF_EVENT_BUS_CYCLES,       /* Count of bus cycles for applications*/
 
     VIR_PERF_EVENT_LAST
 } virPerfEventType;
index a1e4e1c968a6359b6c3431bf9bbdc07e7b058fb2..56a6173796bde9409623c58388098e0d1a499974 100644 (file)
@@ -22,6 +22,7 @@
     <event name='cache_misses' enabled='no'/>
     <event name='branch_instructions' enabled='yes'/>
     <event name='branch_misses' enabled='yes'/>
+    <event name='bus_cycles' enabled='yes'/>
   </perf>
   <devices>
   </devices>
index 74c05c935cb9e699b3b6145949f504e66bbc4fef..7b3cb74cb41c14dfde41ac7a17cc995c25c382f1 100644 (file)
@@ -947,7 +947,8 @@ I<--perf> returns the statistics of all enabled perf events:
 "perf.cache_references" - the count of cache hits,
 "perf.cache_misses" - the count of caches misses,
 "perf.branch_instructions" - the count of branch instructions,
-"perf.branch_misses" - the count of branch misses
+"perf.branch_misses" - the count of branch misses,
+"perf.bus_cycles" - the count of bus cycles
 
 See the B<perf> command for more details about each event.
 
@@ -2299,6 +2300,8 @@ B<Valid perf event names>
                         platform.
   branch_misses    - Provides the count of branch misses executed
                      by applications running on the platform.
+  bus_cycles       - Provides the count of bus cycles executed
+                     by applications running on the platform.
 
 B<Note>: The statistics can be retrieved using the B<domstats> command using
 the I<--perf> flag.