[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170719011839.99399-2-davidcc@google.com>
Date: Tue, 18 Jul 2017 18:18:36 -0700
From: David Carrillo-Cisneros <davidcc@...gle.com>
To: linux-kernel@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>
Cc: Kees Kook <keescook@...omium.org>,
Sudeep Holla <Sudeep.Holla@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Wang Nan <wangnan0@...wei.com>,
Elena Reshetova <elena.reshetova@...el.com>,
Stephane Eranian <eranian@...gle.com>,
Paul Turner <pjt@...gle.com>,
David Carrillo-Cisneros <davidcc@...gle.com>
Subject: [PATCH 1/4] perf tool cgroup: Initialize cgroup refcnt with refcount_set
Atomic reference counters were replaced by refcount_t in
commit 79c5fe6db8c7 ("perf/core: Fix error handling in perf_event_alloc()")
In util/cgroup.c atomic_inc was replaced by refcount_inc, but the latter
is not mean to initiliaze refcounts with zero value. Add a path
to initialize cgrp->refcnt == 0 using refcount_set.
Before this patch:
$ perf stat -e cycles -C 0 -G /
perf_before: /usr/local/.../tools/include/linux/refcount.h:108: refcount_inc: Assertion `!(!refcount_inc_not_zero(r))' failed.
Aborted (core dumped)
After this patch:
$ perf stat -e cycles -C 0 -G /
Performance counter stats for 'CPU(s) 0':
17,516,664 cycles /
Signed-off-by: David Carrillo-Cisneros <davidcc@...gle.com>
Change-Id: I8f00f61aaecce876e7df448bd7f850b20db13ef1
---
tools/perf/util/cgroup.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index 03347748f3fa..7bbc19b3caf3 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -133,7 +133,10 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
return -1;
found:
- refcount_inc(&cgrp->refcnt);
+ if (refcount_read(&cgrp->refcnt) == 0)
+ refcount_set(&cgrp->refcnt, 1);
+ else
+ refcount_inc(&cgrp->refcnt);
counter->cgrp = cgrp;
return 0;
}
--
2.13.2.932.g7449e964c-goog
Powered by blists - more mailing lists