Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf cgroup: Add evlist__add_default_cgroup()

So that tools like 'perf trace' can allow the user to set a cgroup
to be used for all the evsels still without a crgroup setup by
parse_cgroups(), such as the one to use for the syscalls, vfs_getname
and other events involved in strace like syscall tracing.

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-zf9jjsbj661r3lk6qb7g8j70@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+16
+14
tools/perf/util/cgroup.c
··· 182 182 return cgroup; 183 183 } 184 184 185 + static void evsel__set_default_cgroup(struct perf_evsel *evsel, struct cgroup *cgroup) 186 + { 187 + if (evsel->cgrp == NULL) 188 + evsel->cgrp = cgroup__get(cgroup); 189 + } 190 + 191 + void evlist__set_default_cgroup(struct perf_evlist *evlist, struct cgroup *cgroup) 192 + { 193 + struct perf_evsel *evsel; 194 + 195 + evlist__for_each_entry(evlist, evsel) 196 + evsel__set_default_cgroup(evsel, cgroup); 197 + } 198 + 185 199 int parse_cgroups(const struct option *opt, const char *str, 186 200 int unset __maybe_unused) 187 201 {
+2
tools/perf/util/cgroup.h
··· 22 22 23 23 struct cgroup *evlist__findnew_cgroup(struct perf_evlist *evlist, char *name); 24 24 25 + void evlist__set_default_cgroup(struct perf_evlist *evlist, struct cgroup *cgroup); 26 + 25 27 int parse_cgroups(const struct option *opt, const char *str, int unset); 26 28 27 29 #endif /* __CGROUP_H__ */