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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux