diff options
author | Ingo Molnar <mingo@kernel.org> | 2018-03-09 08:27:55 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-03-09 08:27:55 +0100 |
commit | fbf8a1e12c3ba3afdf0804bc80f5f13dfec1cffe (patch) | |
tree | 6b0dd23c7646cd4ec13b0636cdda11188d6845a3 /tools/perf/builtin-trace.c | |
parent | 1af22eba248efe2de25658041a80a3d40fb3e92e (diff) | |
parent | 2427b432e63b4b911100f717c48289195b7a7d62 (diff) |
Merge tag 'perf-core-for-mingo-4.17-20180308' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
- Support to display the IPC/Cycle in 'annotate' TUI, for systems
where this info can be obtained, like Intel's >= Skylake (Jin Yao)
- Support wildcards on PMU name in dynamic PMU events (Agustin Vega-Frias)
- Display pmu name when printing unmerged events in stat (Agustin Vega-Frias)
- Auto-merge PMU events created by prefix or glob match (Agustin Vega-Frias)
- Fix s390 'call' operations target function annotation (Thomas Richter)
- Handle s390 PC relative load and store instruction in the augmented
'annotate', code, used so far in the TUI modes of 'perf report' and
'perf annotate' (Thomas Richter)
- Provide libtraceevent with a kernel symbol resolver, so that
symbols in tracepoint fields can be resolved when showing them in
tools such as 'perf report' (Wang YanQing)
- Refactor the cgroups code to look more like other code in tools/perf,
using cgroup__{put,get} for refcount operations instead of its
open-coded equivalent, breaking larger functions, etc (Arnaldo Carvalho de Melo)
- Implement support for the -G/--cgroup target in 'perf trace', allowing
strace like tracing (plus other events, backtraces, etc) for cgroups
(Arnaldo Carvalho de Melo)
- Update thread shortname in 'perf sched map' when the thread's COMM
changes (Changbin Du)
- refcount 'struct mem_info', for better sharing it over several
users, avoid duplicating structs and fixing crashes related to
use after free (Jiri Olsa)
- Display perf.data version, offsets in 'perf report --header' (Jiri Olsa)
- Record the machine's memory topology information in a perf.data
feature section, to be used by tools such as 'perf c2c' (Jiri Olsa)
- Fix output of forced groups in the header for 'perf report' --stdio
and --tui (Jiri Olsa)
- Better support llvm, clang, cxx make tests in the build process (Jiri Olsa)
- Streamline the 'struct perf_mmap' methods, storing some info in the
struct instead of passing it via various methods, shortening its
signatures (Kan Liang)
- Update the quipper perf.data parser library site information (Stephane Eranian)
- Correct perf's man pages title markers for asciidoctor (Takashi Iwai)
- Intel PT fixes and refactorings paving the way for implementing
support for AUX area sampling (Adrian Hunter)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r-- | tools/perf/builtin-trace.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 1a93debc1e8d..87b95c9410b4 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -19,6 +19,7 @@ #include <traceevent/event-parse.h> #include <api/fs/tracing_path.h> #include "builtin.h" +#include "util/cgroup.h" #include "util/color.h" #include "util/debug.h" #include "util/env.h" @@ -83,6 +84,7 @@ struct trace { struct perf_evlist *evlist; struct machine *host; struct thread *current; + struct cgroup *cgroup; u64 base_time; FILE *output; unsigned long nr_events; @@ -2370,6 +2372,34 @@ static int trace__run(struct trace *trace, int argc, const char **argv) trace__sched_stat_runtime)) goto out_error_sched_stat_runtime; + /* + * If a global cgroup was set, apply it to all the events without an + * explicit cgroup. I.e.: + * + * trace -G A -e sched:*switch + * + * Will set all raw_syscalls:sys_{enter,exit}, pgfault, vfs_getname, etc + * _and_ sched:sched_switch to the 'A' cgroup, while: + * + * trace -e sched:*switch -G A + * + * will only set the sched:sched_switch event to the 'A' cgroup, all the + * other events (raw_syscalls:sys_{enter,exit}, etc are left "without" + * a cgroup (on the root cgroup, sys wide, etc). + * + * Multiple cgroups: + * + * trace -G A -e sched:*switch -G B + * + * the syscall ones go to the 'A' cgroup, the sched:sched_switch goes + * to the 'B' cgroup. + * + * evlist__set_default_cgroup() grabs a reference of the passed cgroup + * only for the evsels still without a cgroup, i.e. evsel->cgroup == NULL. + */ + if (trace->cgroup) + evlist__set_default_cgroup(trace->evlist, trace->cgroup); + err = perf_evlist__create_maps(evlist, &trace->opts.target); if (err < 0) { fprintf(trace->output, "Problems parsing the target to trace, check your options!\n"); @@ -2473,13 +2503,12 @@ again: for (i = 0; i < evlist->nr_mmaps; i++) { union perf_event *event; struct perf_mmap *md; - u64 end, start; md = &evlist->mmap[i]; - if (perf_mmap__read_init(md, false, &start, &end) < 0) + if (perf_mmap__read_init(md) < 0) continue; - while ((event = perf_mmap__read_event(md, false, &start, end)) != NULL) { + while ((event = perf_mmap__read_event(md)) != NULL) { struct perf_sample sample; ++trace->nr_events; @@ -2492,7 +2521,7 @@ again: trace__handle_event(trace, event, &sample); next_event: - perf_mmap__consume(md, false); + perf_mmap__consume(md); if (interrupted) goto out_disable; @@ -2540,6 +2569,7 @@ out_delete_evlist: trace__symbols__exit(trace); perf_evlist__delete(evlist); + cgroup__put(trace->cgroup); trace->evlist = NULL; trace->live = false; return err; @@ -2979,6 +3009,18 @@ out: return err; } +static int trace__parse_cgroups(const struct option *opt, const char *str, int unset) +{ + struct trace *trace = opt->value; + + if (!list_empty(&trace->evlist->entries)) + return parse_cgroups(opt, str, unset); + + trace->cgroup = evlist__findnew_cgroup(trace->evlist, str); + + return 0; +} + int cmd_trace(int argc, const char **argv) { const char *trace_usage[] = { @@ -3069,6 +3111,8 @@ int cmd_trace(int argc, const char **argv) "print the PERF_RECORD_SAMPLE PERF_SAMPLE_ info, for debugging"), OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout, "per thread proc mmap processing timeout in ms"), + OPT_CALLBACK('G', "cgroup", &trace, "name", "monitor event in cgroup name only", + trace__parse_cgroups), OPT_UINTEGER('D', "delay", &trace.opts.initial_delay, "ms to wait before starting measurement after program " "start"), @@ -3095,6 +3139,11 @@ int cmd_trace(int argc, const char **argv) argc = parse_options_subcommand(argc, argv, trace_options, trace_subcommands, trace_usage, PARSE_OPT_STOP_AT_NON_OPTION); + if ((nr_cgroups || trace.cgroup) && !trace.opts.target.system_wide) { + usage_with_options_msg(trace_usage, trace_options, + "cgroup monitoring only available in system-wide mode"); + } + err = bpf__setup_stdout(trace.evlist); if (err) { bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); |