[libvirt] [PATCH] perf: Prevent enabling of already enabled perf event

Currently, on every --enable perf_event command, a new event->fd is created and counting of perf event counter starts from zero and previous event->fd is lost. This patch prevents this behaviour. Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com> --- src/util/virperf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virperf.c b/src/util/virperf.c index 788b817..57c2081 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -230,6 +230,9 @@ virPerfEventEnable(virPerfPtr perf, if (!event || !event_attr) return -1; + if (event->enabled) + return 0; + if (event_attr->attrType == 0 && (type == VIR_PERF_EVENT_CMT || type == VIR_PERF_EVENT_MBMT || type == VIR_PERF_EVENT_MBML)) { -- 1.9.3

On 01/24/2017 04:12 AM, Nitesh Konkar wrote:
Currently, on every --enable perf_event command, a new event->fd is created and counting of perf event counter starts from zero and previous event->fd is lost. This patch prevents this behaviour.
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com> --- src/util/virperf.c | 3 +++ 1 file changed, 3 insertions(+)
ACK and pushed, John
participants (2)
-
John Ferlan
-
Nitesh Konkar