[libvirt] [PATCH 0/3] Clean up some perf event issues

Resolve a couple of recently filed issues regarding perf events. Details in each patch. John Ferlan (3): docs: Alter descriptions of perf cpu_cycles util: Clear up some perf error messages util: Check/ignore already disabled event docs/formatdomain.html.in | 2 +- src/libvirt-domain.c | 2 +- src/util/virperf.c | 13 ++++++++----- src/util/virperf.h | 2 +- tools/virsh.pod | 9 +++++---- 5 files changed, 16 insertions(+), 12 deletions(-) -- 2.7.4

https://bugzilla.redhat.com/show_bug.cgi?id=1381714 Alter the descriptions to match what the cpu_cycles actually is Signed-off-by: John Ferlan <jferlan@redhat.com> --- docs/formatdomain.html.in | 2 +- src/libvirt-domain.c | 2 +- src/util/virperf.h | 2 +- tools/virsh.pod | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1266e9d..b989c8f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1954,7 +1954,7 @@ </tr> <tr> <td><code>cpu_cycles</code></td> - <td>the number of cpu cycles one instruction needs</td> + <td>the count of cpu cycles (total/elapsed)</td> <td><code>perf.cpu_cycles</code></td> </tr> <tr> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 9ba9f49..f9f5a46 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11482,7 +11482,7 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * It is produced by cache_references perf event. * "perf.instructions" - The count of instructions as unsigned long long. * It is produced by instructions perf event. - * "perf.cpu_cycles" - The number of cpu cycles one instruction needs as + * "perf.cpu_cycles" - The count of cpu cycles (total/elapsed) as an * unsigned long long. It is produced by cpu_cycles * perf event. * diff --git a/src/util/virperf.h b/src/util/virperf.h index 41be878..3fca2d0 100644 --- a/src/util/virperf.h +++ b/src/util/virperf.h @@ -32,7 +32,7 @@ typedef enum { VIR_PERF_EVENT_MBMT, /* Memory Bandwidth Monitoring Total */ VIR_PERF_EVENT_MBML, /* Memory Bandwidth Monitor Limit for controller */ - VIR_PERF_EVENT_CPU_CYCLES, /* CPU Cycles per instruction */ + VIR_PERF_EVENT_CPU_CYCLES, /* Count of CPU Cycles (total/elapsed) */ VIR_PERF_EVENT_INSTRUCTIONS, /* Count of instructions for application */ VIR_PERF_EVENT_CACHE_REFERENCES, /* Cache hits by applications */ VIR_PERF_EVENT_CACHE_MISSES, /* Cache misses by applications */ diff --git a/tools/virsh.pod b/tools/virsh.pod index 227c9b2..85992de 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -934,7 +934,7 @@ I<--perf> returns the statistics of all enabled perf events: "perf.cmt" - the cache usage in Byte currently used "perf.mbmt" - total system bandwidth from one level of cache "perf.mbml" - bandwidth of memory traffic for a memory controller -"perf.cpu_cycles" - the number of cpu cycles one instruction needs +"perf.cpu_cycles" - the count of cpu cycles (total/elapsed) "perf.instructions" - the count of instructions "perf.cache_references" - the count of cache hits "perf.cache_misses" - the count of caches misses @@ -2247,9 +2247,10 @@ B<Valid perf event names> applications running on th e platform. instructions - Provides the count of instructions executed by applications running on the platform. - cpu_cycles - Provides the number of cpu_cycles for one - instruction. May be used with instructions - in order to get a cycles per instruction. + cpu_cycles - Provides the count of cpu cycles + (total/elapsed). May be used with + instructions in order to get a cycles + per instruction. B<Note>: The statistics can be retrieved using the B<domstats> command using the I<--perf> flag. -- 2.7.4

On Fri, Oct 07, 2016 at 08:35:35AM -0400, John Ferlan wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1381714
Alter the descriptions to match what the cpu_cycles actually is
Signed-off-by: John Ferlan <jferlan@redhat.com> --- docs/formatdomain.html.in | 2 +- src/libvirt-domain.c | 2 +- src/util/virperf.h | 2 +- tools/virsh.pod | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-)
Update also doc text in include/libvirt/libvirt-domain.h. ACK with the updated doc text. Pavel

On 10/07/2016 09:32 AM, Pavel Hrdina wrote:
On Fri, Oct 07, 2016 at 08:35:35AM -0400, John Ferlan wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1381714
Alter the descriptions to match what the cpu_cycles actually is
Signed-off-by: John Ferlan <jferlan@redhat.com> --- docs/formatdomain.html.in | 2 +- src/libvirt-domain.c | 2 +- src/util/virperf.h | 2 +- tools/virsh.pod | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-)
Update also doc text in include/libvirt/libvirt-domain.h.
Thanks ... I thought about this one too - it was a bit more tricky since the existing text doesn't say it's representing "cpu cycles one instruction needs" rather it's indicating the cpu cycles "which can be used"... Anyway, how about if I change from : * Macro for typed parameter name that represents cpu_cycles perf event * which can be used to measure how many cpu cycles one instruction needs. * It corresponds to the "perf.cpu_cycles" field in the *Stats APIs. To: * Macro for typed parameter name that represents cpu_cycles perf event * describing the total/elapsed cpu cycles. This can be used to measure * how many cpu cycles one instruction needs. * It corresponds to the "perf.cpu_cycles" field in the *Stats APIs. Or I could just remove the "This can be... " sentence altogether. Since it's not describing what the data is but how it can be used in conjunction with the instructions value. John

On Fri, Oct 07, 2016 at 09:48:24AM -0400, John Ferlan wrote:
On 10/07/2016 09:32 AM, Pavel Hrdina wrote:
On Fri, Oct 07, 2016 at 08:35:35AM -0400, John Ferlan wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1381714
Alter the descriptions to match what the cpu_cycles actually is
Signed-off-by: John Ferlan <jferlan@redhat.com> --- docs/formatdomain.html.in | 2 +- src/libvirt-domain.c | 2 +- src/util/virperf.h | 2 +- tools/virsh.pod | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-)
Update also doc text in include/libvirt/libvirt-domain.h.
Thanks ...
I thought about this one too - it was a bit more tricky since the existing text doesn't say it's representing "cpu cycles one instruction needs" rather it's indicating the cpu cycles "which can be used"...
Anyway, how about if I change from :
* Macro for typed parameter name that represents cpu_cycles perf event * which can be used to measure how many cpu cycles one instruction needs. * It corresponds to the "perf.cpu_cycles" field in the *Stats APIs.
To:
* Macro for typed parameter name that represents cpu_cycles perf event * describing the total/elapsed cpu cycles. This can be used to measure * how many cpu cycles one instruction needs. * It corresponds to the "perf.cpu_cycles" field in the *Stats APIs.
Or I could just remove the "This can be... " sentence altogether. Since it's not describing what the data is but how it can be used in conjunction with the instructions value.
I'm OK with both versions, I guess you don't have to remove that part, it's nice to have that example how it can be used. Pavel

Make it clearer that the perf event is based/for the host cpu and use the virPerfEventTypeToString to convert the type to a string Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/util/virperf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/virperf.c b/src/util/virperf.c index a65a4bf..6387430 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -175,7 +175,7 @@ virPerfEventEnable(virPerfPtr perf, type == VIR_PERF_EVENT_MBMT || type == VIR_PERF_EVENT_MBML)) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, - _("unable to enable perf event for %s"), + _("unable to enable host cpu perf event for %s"), virPerfEventTypeToString(event->type)); return -1; } @@ -205,14 +205,14 @@ virPerfEventEnable(virPerfPtr perf, event->fd = syscall(__NR_perf_event_open, &attr, pid, -1, -1, 0); if (event->fd < 0) { virReportSystemError(errno, - _("Unable to open perf event for %s"), + _("unable to open host cpu perf event for %s"), virPerfEventTypeToString(event->type)); goto error; } if (ioctl(event->fd, PERF_EVENT_IOC_ENABLE) < 0) { virReportSystemError(errno, - _("Unable to enable perf event for %s"), + _("unable to enable host cpu perf event for %s"), virPerfEventTypeToString(event->type)); goto error; } @@ -236,8 +236,8 @@ virPerfEventDisable(virPerfPtr perf, if (ioctl(event->fd, PERF_EVENT_IOC_DISABLE) < 0) { virReportSystemError(errno, - _("Unable to disable perf event type=%d"), - event->type); + _("unable to disable host cpu perf event for %s"), + virPerfEventTypeToString(event->type)); return -1; } -- 2.7.4

On Fri, Oct 07, 2016 at 08:35:36AM -0400, John Ferlan wrote:
Make it clearer that the perf event is based/for the host cpu and use the virPerfEventTypeToString to convert the type to a string
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/util/virperf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
ACK Pavel

If the event is already disabled, then don't bother with setting it disabled again. Causes unnecessary error on systems that don't support the feature anyway. Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/util/virperf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virperf.c b/src/util/virperf.c index 6387430..5d57962 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -234,6 +234,9 @@ virPerfEventDisable(virPerfPtr perf, if (event == NULL) return -1; + if (!event->enabled) + return 0; + if (ioctl(event->fd, PERF_EVENT_IOC_DISABLE) < 0) { virReportSystemError(errno, _("unable to disable host cpu perf event for %s"), -- 2.7.4

On Fri, Oct 07, 2016 at 08:35:37AM -0400, John Ferlan wrote:
If the event is already disabled, then don't bother with setting it disabled again. Causes unnecessary error on systems that don't support the feature anyway.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/util/virperf.c | 3 +++ 1 file changed, 3 insertions(+)
ACK Pavel
participants (2)
-
John Ferlan
-
Pavel Hrdina