diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-05-15 21:12:20 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-05-15 21:12:20 +0200 |
commit | f812d3045c2385ac16237e68b156859c4005526e (patch) | |
tree | ba298a8fb0046c908913765045ad2f27765e4f0d /tools/perf/util/cgroup.c | |
parent | perf evlist: Use atomic.h for the perf_mmap refcount (diff) | |
download | linux-f812d3045c2385ac16237e68b156859c4005526e.tar.xz linux-f812d3045c2385ac16237e68b156859c4005526e.zip |
perf cgroup: Use atomic.h for refcounting
Now that we have atomic.h, we should convert all of the existing
refcounts to use it.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-t3v2uma5digcj2tpkrs3m84u@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/cgroup.c')
-rw-r--r-- | tools/perf/util/cgroup.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 88f7be399432..32e12ecfe9c5 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -115,23 +115,19 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) goto found; n++; } - if (cgrp->refcnt == 0) + if (atomic_read(&cgrp->refcnt) == 0) free(cgrp); return -1; found: - cgrp->refcnt++; + atomic_inc(&cgrp->refcnt); counter->cgrp = cgrp; return 0; } void close_cgroup(struct cgroup_sel *cgrp) { - if (!cgrp) - return; - - /* XXX: not reentrant */ - if (--cgrp->refcnt == 0) { + if (cgrp && atomic_dec_and_test(&cgrp->refcnt)) { close(cgrp->fd); zfree(&cgrp->name); free(cgrp); |