[libvirt] [PATCH v2 1/2] perf: get rid of pointless virPerfGetEventAttr() method

Ján Tomko jtomko at redhat.com
Wed Apr 12 13:26:36 UTC 2017


On Wed, Apr 12, 2017 at 12:27:11PM +0100, Daniel P. Berrange wrote:
>The virPerfGetEventAttr method contains a totally pointless
>loop. Remove it, verify the array size statically, and then
>just use an array index to access the perf event.
>
>Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
>---
> src/util/virperf.c | 143 +++++++++++++++++++++++++----------------------------
> 1 file changed, 66 insertions(+), 77 deletions(-)
>
>diff --git a/src/util/virperf.c b/src/util/virperf.c
>index e39cebb..7366efc 100644
>--- a/src/util/virperf.c
>+++ b/src/util/virperf.c

[...]

>+    [VIR_PERF_EVENT_STALLED_CYCLES_BACKEND] = {
>+        .attrType = PERF_TYPE_HARDWARE,
>+        .attrConfig = PERF_COUNT_HW_STALLED_CYCLES_BACKEND
>+    },
>+    [VIR_PERF_EVENT_REF_CPU_CYCLES] = {

Up to VIR_PERF_EVENT_REF_CPU_CYCLES, the initialization is indexed
by the enum value...

> # ifdef PERF_COUNT_HW_REF_CPU_CYCLES
>-     .attrType = PERF_TYPE_HARDWARE,
>-     .attrConfig = PERF_COUNT_HW_REF_CPU_CYCLES
>+        .attrType = PERF_TYPE_HARDWARE,
>+        .attrConfig = PERF_COUNT_HW_REF_CPU_CYCLES
> # else
>-     .attrType = 0,
>-     .attrConfig = 0,
>+        .attrType = 0,
>+        .attrConfig = 0,
> # endif
>     },
>-    {.type = VIR_PERF_EVENT_CPU_CLOCK,
>-     .attrType = PERF_TYPE_SOFTWARE,
>+    {.attrType = PERF_TYPE_SOFTWARE,
>      .attrConfig = PERF_COUNT_SW_CPU_CLOCK},

... but the rest does not.

ACK with the inconsitency fixed.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170412/fc2df9a4/attachment-0001.sig>


More information about the libvir-list mailing list