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 <berra...@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

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to