Skip to content

Commit

Permalink
perf cgroup: Add evlist__add_default_cgroup()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Mar 7, 2018
1 parent 69239ec commit 483322d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/perf/util/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */

0 comments on commit 483322d

Please sign in to comment.