perf cgroup: Add evlist__add_default_cgroup()
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 483322dda03a7ad807e82f9c25fac315a4eee1c5 Gitweb: https://git.kernel.org/tip/483322dda03a7ad807e82f9c25fac315a4eee1c5 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Tue, 6 Mar 2018 15:48:10 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 7 Mar 2018 10:22:26 -0300
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 <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/cgroup.c | 14 ++++++++++++++ tools/perf/util/cgroup.h | 2 ++ 2 files changed, 16 insertions(+)
tools/perf/util/cgroup.c +14 -0
@@ -182,6 +182,20 @@ struct cgroup *cgroup__get(struct cgroup *cgroup)return cgroup; } +static void evsel__set_default_cgroup (struct perf_evsel *evsel,struct cgroup *cgroup) +{ +if (evsel->cgrp ==NULL ) + evsel->cgrp =cgroup__get (cgroup); +} + +void evlist__set_default_cgroup (struct perf_evlist *evlist,struct cgroup *cgroup) +{ +struct perf_evsel *evsel; + +evlist__for_each_entry (evlist, evsel) +evsel__set_default_cgroup (evsel, cgroup); +} +int parse_cgroups (const struct option *opt,const char *str,int unset__maybe_unused ) {
tools/perf/util/cgroup.h +2 -0
@@ -22,6 +22,8 @@ struct perf_evlist;struct cgroup *evlist__findnew_cgroup (struct perf_evlist *evlist,char *name); +void evlist__set_default_cgroup (struct perf_evlist *evlist,struct cgroup *cgroup); +int parse_cgroups (const struct option *opt,const char *str,int unset);#endif /* __CGROUP_H__ */