diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-06 16:18:40 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-07 16:22:25 +0300 |
commit | fc9ffb9cf085c78f49d4d1a602d723504c0d9c75 (patch) | |
tree | d123a1a52891cb9a9d44323e50e6168a508ef073 /tools/perf/util/cgroup.c | |
parent | a53b646030ee6f65accdc49e772823b8134a37f6 (diff) | |
download | linux-fc9ffb9cf085c78f49d4d1a602d723504c0d9c75.tar.xz |
perf cgroup: Introduce cgroup__get()
The refcount operation counterpart to cgroup__put(), use it when reusing
a cgroup.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-14ynvrl7y2cz8gyuy5q5v41g@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 | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index b078d54d4245..8ea964461eb7 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -99,15 +99,12 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) * check if cgrp is already defined, if so we reuse it */ evlist__for_each_entry(evlist, counter) { - cgrp = counter->cgrp; - if (!cgrp) + if (!counter->cgrp) continue; - if (!strcmp(cgrp->name, str)) { - refcount_inc(&cgrp->refcnt); + if (!strcmp(counter->cgrp->name, str)) { + cgrp = cgroup__get(counter->cgrp); break; } - - cgrp = NULL; } if (!cgrp) { @@ -157,6 +154,13 @@ void cgroup__put(struct cgroup *cgrp) } } +struct cgroup *cgroup__get(struct cgroup *cgroup) +{ + if (cgroup) + refcount_inc(&cgroup->refcnt); + return cgroup; +} + int parse_cgroups(const struct option *opt, const char *str, int unset __maybe_unused) { |