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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 69239ec8
...@@ -182,6 +182,20 @@ struct cgroup *cgroup__get(struct cgroup *cgroup) ...@@ -182,6 +182,20 @@ struct cgroup *cgroup__get(struct cgroup *cgroup)
return 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 parse_cgroups(const struct option *opt, const char *str,
int unset __maybe_unused) int unset __maybe_unused)
{ {
......
...@@ -22,6 +22,8 @@ struct perf_evlist; ...@@ -22,6 +22,8 @@ struct perf_evlist;
struct cgroup *evlist__findnew_cgroup(struct perf_evlist *evlist, char *name); 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); int parse_cgroups(const struct option *opt, const char *str, int unset);
#endif /* __CGROUP_H__ */ #endif /* __CGROUP_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment