aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-03-15 14:27:27 -0400
committerIngo Molnar <mingo@kernel.org>2017-03-15 14:27:27 -0400
commitffa86c2f1a8862cf58c873f6f14d4b2c3250fb48 (patch)
tree9e15f9494d9a70bd0d2295311f0c56a04113070c /tools/perf/builtin-script.c
parent84e5b549214f2160c12318aac549de85f600c79a (diff)
parent5f6bee34707973ea7879a7857fd63ddccc92fff3 (diff)
Merge tag 'perf-core-for-mingo-4.12-20170314' 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: New features: - Add PERF_RECORD_NAMESPACES so that the kernel can record information required to associate samples to namespaces, helping in container problem characterization. Now the 'perf record has a --namespace' option to ask for such info, and when present, it can be used, initially, via a new sort order, 'cgroup_id', allowing histogram entry bucketization by a (device, inode) based cgroup identifier (Hari Bathini) - Add --next option to 'perf sched timehist', showing what is the next thread to run (Brendan Gregg) Fixes: - Fix segfault with basic block 'cycles' sort dimension (Changbin Du) - Add c2c to command-list.txt, making it appear in the 'perf help' output (Changbin Du) - Fix zeroing of 'abs_path' variable in the perf hists browser switch file code (Changbin Du) - Hide tips messages when -q/--quiet is given to 'perf report' (Namhyung Kim) Infrastructure changes: - Use ref_reloc_sym + offset to setup kretprobes (Naveen Rao) - Ignore generated files pmu-events/{jevents,pmu-events.c} for git (Changbin Du) Documentation changes: - Document +field style argument support for --field option (Changbin Du) - Clarify 'perf c2c --stats' help message (Namhyung Kim) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c0783b4f7b6c..66d62c98dff9 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -830,6 +830,7 @@ struct perf_script {
830 bool show_task_events; 830 bool show_task_events;
831 bool show_mmap_events; 831 bool show_mmap_events;
832 bool show_switch_events; 832 bool show_switch_events;
833 bool show_namespace_events;
833 bool allocated; 834 bool allocated;
834 struct cpu_map *cpus; 835 struct cpu_map *cpus;
835 struct thread_map *threads; 836 struct thread_map *threads;
@@ -1118,6 +1119,41 @@ out:
1118 return ret; 1119 return ret;
1119} 1120}
1120 1121
1122static int process_namespaces_event(struct perf_tool *tool,
1123 union perf_event *event,
1124 struct perf_sample *sample,
1125 struct machine *machine)
1126{
1127 struct thread *thread;
1128 struct perf_script *script = container_of(tool, struct perf_script, tool);
1129 struct perf_session *session = script->session;
1130 struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
1131 int ret = -1;
1132
1133 thread = machine__findnew_thread(machine, event->namespaces.pid,
1134 event->namespaces.tid);
1135 if (thread == NULL) {
1136 pr_debug("problem processing NAMESPACES event, skipping it.\n");
1137 return -1;
1138 }
1139
1140 if (perf_event__process_namespaces(tool, event, sample, machine) < 0)
1141 goto out;
1142
1143 if (!evsel->attr.sample_id_all) {
1144 sample->cpu = 0;
1145 sample->time = 0;
1146 sample->tid = event->namespaces.tid;
1147 sample->pid = event->namespaces.pid;
1148 }
1149 print_sample_start(sample, thread, evsel);
1150 perf_event__fprintf(event, stdout);
1151 ret = 0;
1152out:
1153 thread__put(thread);
1154 return ret;
1155}
1156
1121static int process_fork_event(struct perf_tool *tool, 1157static int process_fork_event(struct perf_tool *tool,
1122 union perf_event *event, 1158 union perf_event *event,
1123 struct perf_sample *sample, 1159 struct perf_sample *sample,
@@ -1293,6 +1329,8 @@ static int __cmd_script(struct perf_script *script)
1293 } 1329 }
1294 if (script->show_switch_events) 1330 if (script->show_switch_events)
1295 script->tool.context_switch = process_switch_event; 1331 script->tool.context_switch = process_switch_event;
1332 if (script->show_namespace_events)
1333 script->tool.namespaces = process_namespaces_event;
1296 1334
1297 ret = perf_session__process_events(script->session); 1335 ret = perf_session__process_events(script->session);
1298 1336
@@ -2097,6 +2135,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
2097 .mmap = perf_event__process_mmap, 2135 .mmap = perf_event__process_mmap,
2098 .mmap2 = perf_event__process_mmap2, 2136 .mmap2 = perf_event__process_mmap2,
2099 .comm = perf_event__process_comm, 2137 .comm = perf_event__process_comm,
2138 .namespaces = perf_event__process_namespaces,
2100 .exit = perf_event__process_exit, 2139 .exit = perf_event__process_exit,
2101 .fork = perf_event__process_fork, 2140 .fork = perf_event__process_fork,
2102 .attr = process_attr, 2141 .attr = process_attr,
@@ -2180,6 +2219,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
2180 "Show the mmap events"), 2219 "Show the mmap events"),
2181 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events, 2220 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
2182 "Show context switch events (if recorded)"), 2221 "Show context switch events (if recorded)"),
2222 OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
2223 "Show namespace events (if recorded)"),
2183 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), 2224 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
2184 OPT_BOOLEAN(0, "ns", &nanosecs, 2225 OPT_BOOLEAN(0, "ns", &nanosecs,
2185 "Use 9 decimal places when displaying time"), 2226 "Use 9 decimal places when displaying time"),