diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-06 10:27:00 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-07 10:22:25 -0300 |
commit | b80271f76ac5fe498f8fb701b2745dcd841627cc (patch) | |
tree | 7093c498410f56cf118f30414791036e374728b0 /tools/perf/util/cgroup.c | |
parent | fc9ffb9cf085c78f49d4d1a602d723504c0d9c75 (diff) |
perf cgroup: Introduce find_cgroup() method
To break down complexity in add_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-5yqshcf5hm837n7c86u7lhjf@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 | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 8ea964461eb7..84dfc34a6d0f 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -90,11 +90,10 @@ static int open_cgroup(char *name) return fd; } -static int add_cgroup(struct perf_evlist *evlist, char *str) +static struct cgroup *evlist__find_cgroup(struct perf_evlist *evlist, char *str) { struct perf_evsel *counter; struct cgroup *cgrp = NULL; - int n; /* * check if cgrp is already defined, if so we reuse it */ @@ -107,6 +106,15 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) } } + return cgrp; +} + +static int add_cgroup(struct perf_evlist *evlist, char *str) +{ + struct perf_evsel *counter; + struct cgroup *cgrp = evlist__find_cgroup(evlist, str); + int n; + if (!cgrp) { cgrp = zalloc(sizeof(*cgrp)); if (!cgrp) |