From 483322dda03a7ad807e82f9c25fac315a4eee1c5 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 6 Mar 2018 15:48:10 -0300 Subject: [PATCH] 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 Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-zf9jjsbj661r3lk6qb7g8j70@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cgroup.c | 14 ++++++++++++++ tools/perf/util/cgroup.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 6fd33ffc2488..d8cd0e601c56 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -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) { diff --git a/tools/perf/util/cgroup.h b/tools/perf/util/cgroup.h index 0e377e6340dd..b213f5e9a3ed 100644 --- a/tools/perf/util/cgroup.h +++ b/tools/perf/util/cgroup.h @@ -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__ */ -- GitLab