summaryrefslogtreecommitdiffstats
path: root/kernel/tools/perf/util/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/tools/perf/util/cgroup.c')
-rw-r--r--kernel/tools/perf/util/cgroup.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/kernel/tools/perf/util/cgroup.c b/kernel/tools/perf/util/cgroup.c
index 88f7be399..32e12ecfe 100644
--- a/kernel/tools/perf/util/cgroup.c
+++ b/kernel/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);