<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 10, 2017 at 3:10 AM, John Ferlan <span dir="ltr"><<a href="mailto:jferlan@redhat.com" target="_blank">jferlan@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br>
On 01/27/2017 06:01 AM, Nitesh Konkar wrote:<br>
> This patch adds support and documentation for<br>
> the cpu_clock perf event.<br>
><br>
> Signed-off-by: Nitesh Konkar <<a href="mailto:nitkon12@linux.vnet.ibm.com">nitkon12@linux.vnet.ibm.com</a>><br>
> ---<br>
>  docs/<a href="http://formatdomain.html.in" rel="noreferrer" target="_blank">formatdomain.html.in</a>                   |  6 ++++++<br>
>  docs/news.xml                               |  4 ++--<br>
>  docs/schemas/domaincommon.rng               |  1 +<br>
>  include/libvirt/libvirt-<wbr>domain.h            | 10 ++++++++++<br>
>  src/libvirt-domain.c                        |  2 ++<br>
>  src/qemu/qemu_driver.c                      |  1 +<br>
>  src/util/virperf.c                          |  6 +++++-<br>
>  src/util/virperf.h                          |  1 +<br>
>  tests/genericxml2xmlindata/<wbr>generic-perf.xml |  1 +<br>
>  tools/virsh.pod                             |  3 +++<br>
>  10 files changed, 32 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/docs/<a href="http://formatdomain.html.in" rel="noreferrer" target="_blank">formatdomain.html.in</a> b/docs/<a href="http://formatdomain.html.in" rel="noreferrer" target="_blank">formatdomain.html.in</a><br>
> index 3f7f875..e44e758 100644<br>
> --- a/docs/<a href="http://formatdomain.html.in" rel="noreferrer" target="_blank">formatdomain.html.in</a><br>
> +++ b/docs/<a href="http://formatdomain.html.in" rel="noreferrer" target="_blank">formatdomain.html.in</a><br>
> @@ -1937,6 +1937,7 @@<br>
>    &lt;event name='stalled_cycles_frontend' enabled='no'/&gt;<br>
>    &lt;event name='stalled_cycles_backend' enabled='no'/&gt;<br>
>    &lt;event name='ref_cpu_cycles' enabled='no'/&gt;<br>
> +  &lt;event name='cpu_clock' enabled='no'/&gt;<br>
>  &lt;/perf&gt;<br>
>  ...<br>
>  </pre><br>
> @@ -2015,6 +2016,11 @@<br>
>           by applications running on the platform</td><br>
>        <td><code>perf.ref_cpu_cycles<<wbr>/code></td><br>
>      </tr><br>
> +    <tr><br>
> +      <td><code>cpu_clock</code></<wbr>td><br>
> +      <td>the count of cpu clock by applications running on the platform</td><br>
> +      <td><code>perf.cpu_clock</<wbr>code></td><br>
> +    </tr><br>
>    </table><br>
<br>
</div></div>"the count of cpu clock by applications..."<br>
<br>
doesn't convey enough meaning. Is that cycles? Time?  something else?<br>
<br>
The virsh.pod description seems to give the best hint...<br>
<br>
Some subsequent patches had longer descriptions in the virsh.pod, which<br>
got me thinking - where is the best place to have the longer<br>
description. I would think either in formatdomain or the<br>
libvirt-domain.{c|} description.  At least that way you don't need to<br>
mess with the 80 column formatting that is "nice" to have in virsh.pod<br>
output<br></blockquote><div>Lets keep the virsh.pod and libvirt-domain.c explanantion terse and let <br>formatdomain have detailed explanation of the events. Do you agree?<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
<br>
><br>
>      <h3><a name="elementsDevices"><wbr>Devices</a></h3><br>
> diff --git a/docs/news.xml b/docs/news.xml<br>
> index ef7e2db..ec113ab 100644<br>
> --- a/docs/news.xml<br>
> +++ b/docs/news.xml<br>
> @@ -136,8 +136,8 @@<br>
>          <description><br>
>            Add support to get the count of branch instructions<br>
>            executed, branch misses, bus cycles, stalled frontend<br>
> -          cpu cycles, stalled backend cpu cycles, and ref cpu<br>
> -          cycles by applications running on the platform.<br>
> +          cpu cycles, stalled backend cpu cycles, ref cpu cycles<br>
> +          and cpu clock by applications running on the platform.<br>
>          </description><br>
>        </change><br>
>        <change><br>
<br>
</span>So the latest decree is to not integrate news.xml into the patches with<br>
the code.  So just make one patch at the end that summarizes all the<br>
adjustments.<br>
<br>
Also this patch is wrong because it describes the additions in the 3.0.0<br>
section while this code would be available in 3.1.0.<br></blockquote><div>Noted. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
> diff --git a/docs/schemas/domaincommon.<wbr>rng b/docs/schemas/domaincommon.<wbr>rng<br>
> index 4d76315..86a39c8 100644<br>
> --- a/docs/schemas/domaincommon.<wbr>rng<br>
> +++ b/docs/schemas/domaincommon.<wbr>rng<br>
> @@ -433,6 +433,7 @@<br>
>                <value>stalled_cycles_<wbr>frontend</value><br>
>                <value>stalled_cycles_backend<<wbr>/value><br>
>                <value>ref_cpu_cycles</value><br>
> +              <value>cpu_clock</value><br>
>              </choice><br>
>            </attribute><br>
>            <attribute name="enabled"><br>
> diff --git a/include/libvirt/libvirt-<wbr>domain.h b/include/libvirt/libvirt-<wbr>domain.h<br>
> index e303140..bffe955 100644<br>
> --- a/include/libvirt/libvirt-<wbr>domain.h<br>
> +++ b/include/libvirt/libvirt-<wbr>domain.h<br>
> @@ -2188,6 +2188,16 @@ void virDomainStatsRecordListFree(<wbr>virDomainStatsRecordPtr *stats);<br>
>   */<br>
>  # define VIR_PERF_PARAM_REF_CPU_CYCLES "ref_cpu_cycles"<br>
><br>
> +/**<br>
> + * VIR_PERF_PARAM_CPU_CLOCK:<br>
> + *<br>
> + * Macro for typed parameter name that represents cpu_clock<br>
> + * perf event which can be used to measure the count of cpu<br>
> + * clock by applications running on the platform. It corresponds<br>
> + * to the "perf.cpu_clock" field in the *Stats APIs.<br>
> + */<br>
> +# define VIR_PERF_PARAM_CPU_CLOCK "cpu_clock"<br>
> +<br>
>  int virDomainGetPerfEvents(<wbr>virDomainPtr dom,<br>
>                             virTypedParameterPtr *params,<br>
>                             int *nparams,<br>
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c<br>
> index 5b3e842..001cdd7 100644<br>
> --- a/src/libvirt-domain.c<br>
> +++ b/src/libvirt-domain.c<br>
> @@ -11250,6 +11250,8 @@ virConnectGetDomainCapabilitie<wbr>s(virConnectPtr conn,<br>
>   *                             CPU frequency scaling by applications running<br>
>   *                             as unsigned long long. It is produced by the<br>
>   *                             ref_cpu_cycles perf event.<br>
> + *     "perf.cpu_clock" - The count of cpu clock as unsigned long long. It is<br>
> + *                        produced by the cpu_clock perf event.<br>
>   *<br>
>   * Note that entire stats groups or individual stat fields may be missing from<br>
>   * the output in case they are not supported by the given hypervisor, are not<br>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c<br>
> index 516a851..ff4803c 100644<br>
> --- a/src/qemu/qemu_driver.c<br>
> +++ b/src/qemu/qemu_driver.c<br>
> @@ -9549,6 +9549,7 @@ qemuDomainSetPerfEvents(<wbr>virDomainPtr dom,<br>
>                                 VIR_PERF_PARAM_STALLED_CYCLES_<wbr>FRONTEND, VIR_TYPED_PARAM_BOOLEAN,<br>
>                                 VIR_PERF_PARAM_STALLED_CYCLES_<wbr>BACKEND, VIR_TYPED_PARAM_BOOLEAN,<br>
>                                 VIR_PERF_PARAM_REF_CPU_CYCLES, VIR_TYPED_PARAM_BOOLEAN,<br>
> +                               VIR_PERF_PARAM_CPU_CLOCK, VIR_TYPED_PARAM_BOOLEAN,<br>
>                                 NULL) < 0)<br>
>          return -1;<br>
><br>
> diff --git a/src/util/virperf.c b/src/util/virperf.c<br>
> index f64692b..3629e5b 100644<br>
> --- a/src/util/virperf.c<br>
> +++ b/src/util/virperf.c<br>
> @@ -43,7 +43,8 @@ VIR_ENUM_IMPL(virPerfEvent, VIR_PERF_EVENT_LAST,<br>
>                "cache_references", "cache_misses",<br>
>                "branch_instructions", "branch_misses",<br>
>                "bus_cycles", "stalled_cycles_frontend",<br>
> -              "stalled_cycles_backend", "ref_cpu_cycles");<br>
> +              "stalled_cycles_backend", "ref_cpu_cycles",<br>
> +              "cpu_clock");<br>
><br>
>  struct virPerfEvent {<br>
>      int type;<br>
> @@ -112,6 +113,9 @@ static struct virPerfEventAttr attrs[] = {<br>
>       .attrConfig = 0,<br>
>  # endif<br>
>      },<br>
> +    {.type = VIR_PERF_EVENT_CPU_CLOCK,<br>
> +     .attrType = PERF_TYPE_SOFTWARE,<br>
> +     .attrConfig = PERF_COUNT_SW_CPU_CLOCK},<br>
>  };<br>
>  typedef struct virPerfEventAttr *virPerfEventAttrPtr;<br>
><br>
> diff --git a/src/util/virperf.h b/src/util/virperf.h<br>
> index 1f43c92..81f1e20 100644<br>
> --- a/src/util/virperf.h<br>
> +++ b/src/util/virperf.h<br>
> @@ -47,6 +47,7 @@ typedef enum {<br>
>                                                the backend of the instruction<br>
>                                                processor pipeline */<br>
>      VIR_PERF_EVENT_REF_CPU_CYCLES,   /* Count of ref cpu cycles */<br>
> +    VIR_PERF_EVENT_CPU_CLOCK,   /* Count of cpu clock */<br>
><br>
>      VIR_PERF_EVENT_LAST<br>
>  } virPerfEventType;<br>
> diff --git a/tests/genericxml2xmlindata/<wbr>generic-perf.xml b/tests/genericxml2xmlindata/<wbr>generic-perf.xml<br>
> index 437cd65..3e7834e 100644<br>
> --- a/tests/genericxml2xmlindata/<wbr>generic-perf.xml<br>
> +++ b/tests/genericxml2xmlindata/<wbr>generic-perf.xml<br>
> @@ -26,6 +26,7 @@<br>
>      <event name='stalled_cycles_frontend' enabled='yes'/><br>
>      <event name='stalled_cycles_backend' enabled='yes'/><br>
>      <event name='ref_cpu_cycles' enabled='yes'/><br>
> +    <event name='cpu_clock' enabled='yes'/><br>
>    </perf><br>
>    <devices><br>
>    </devices><br>
> diff --git a/tools/virsh.pod b/tools/virsh.pod<br>
> index 290f508..2f0bf36 100644<br>
> --- a/tools/virsh.pod<br>
> +++ b/tools/virsh.pod<br>
> @@ -946,6 +946,7 @@ I<--perf> returns the statistics of all enabled perf events:<br>
>  "perf.stalled_cycles_frontend" - the count of stalled frontend cpu cycles,<br>
>  "perf.stalled_cycles_backend" - the count of stalled backend cpu cycles,<br>
>  "perf.ref_cpu_cycles" - the count of ref cpu cycles<br>
> +"perf.cpu_clock" - the count of cpu clock<br>
<br>
<br>
</div></div>If you do a 'man tools/virsh.1' using an 80 column wide terminal, you'll<br>
note that starting with perf.stalled_cycles_frontend things go a bit<br>
haywire.<br>
<br>
I sent a patch to "fix" the existing format issues and make things a bit<br>
more consistent in this space.<br></blockquote><div>Noted. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If that's ACK'd then this will be affected. Still the text here still<br>
doesn't convey enough meaning.<br>
<span class=""><br>
><br>
>  See the B<perf> command for more details about each event.<br>
><br>
> @@ -2310,6 +2311,8 @@ B<Valid perf event names><br>
>    ref_cpu_cycles   -  Provides the count of total cpu cycles<br>
>                        not affected by CPU frequency scaling by<br>
>                        applications running on the platform.<br>
> +  cpu_clock - Provides the cpu clock time consumed by applications<br>
> +              running on the platform.<br>
<br>
</span>Now this is a little bit better w/r/t meaning, but needs to be fit in<br>
else where as well.<br></blockquote><div>Sure. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
John<br>
</font></span><div class="HOEnZb"><div class="h5">><br>
>  B<Note>: The statistics can be retrieved using the B<domstats> command using<br>
>  the I<--perf> flag.<br>
><br></div></div></blockquote><div>Thanks.  <br></div></div><br></div></div>