diff options
author | Avi Kivity <avi@redhat.com> | 2011-12-25 08:44:43 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 04:22:24 -0500 |
commit | 9e31905f293ae84e4f120ed9e414031eaefa0bdf (patch) | |
tree | 153204ff0dca820e760007bc24075ec7fb46a276 /tools/perf/builtin-script.c | |
parent | ff5c2c0316ff0e3e2dba3ca14167d994453df093 (diff) | |
parent | b3d9468a8bd218a695e3a0ff112cd4efd27b670a (diff) |
Merge remote-tracking branch 'tip/perf/core' into kvm-updates/3.3
* tip/perf/core: (66 commits)
perf, x86: Expose perf capability to other modules
perf, x86: Implement arch event mask as quirk
x86, perf: Disable non available architectural events
jump_label: Provide jump_label_key initializers
jump_label, x86: Fix section mismatch
perf, core: Rate limit perf_sched_events jump_label patching
perf: Fix enable_on_exec for sibling events
perf: Remove superfluous arguments
perf, x86: Prefer fixed-purpose counters when scheduling
perf, x86: Fix event scheduler for constraints with overlapping counters
perf, x86: Implement event scheduler helper functions
perf: Avoid a useless pmu_disable() in the perf-tick
x86/tools: Add decoded instruction dump mode
x86: Update instruction decoder to support new AVX formats
x86/tools: Fix insn_sanity message outputs
x86/tools: Fix instruction decoder message output
x86: Fix instruction decoder to handle grouped AVX instructions
x86/tools: Fix Makefile to build all test tools
perf test: Soft errors shouldn't stop the "Validate PERF_RECORD_" test
perf test: Validate PERF_RECORD_ events and perf_sample fields
...
Signed-off-by: Avi Kivity <avi@redhat.com>
* commit 'b3d9468a8bd218a695e3a0ff112cd4efd27b670a': (66 commits)
perf, x86: Expose perf capability to other modules
perf, x86: Implement arch event mask as quirk
x86, perf: Disable non available architectural events
jump_label: Provide jump_label_key initializers
jump_label, x86: Fix section mismatch
perf, core: Rate limit perf_sched_events jump_label patching
perf: Fix enable_on_exec for sibling events
perf: Remove superfluous arguments
perf, x86: Prefer fixed-purpose counters when scheduling
perf, x86: Fix event scheduler for constraints with overlapping counters
perf, x86: Implement event scheduler helper functions
perf: Avoid a useless pmu_disable() in the perf-tick
x86/tools: Add decoded instruction dump mode
x86: Update instruction decoder to support new AVX formats
x86/tools: Fix insn_sanity message outputs
x86/tools: Fix instruction decoder message output
x86: Fix instruction decoder to handle grouped AVX instructions
x86/tools: Fix Makefile to build all test tools
perf test: Soft errors shouldn't stop the "Validate PERF_RECORD_" test
perf test: Validate PERF_RECORD_ events and perf_sample fields
...
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 2f62a2952269..619d6dcaa1d9 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "util/header.h" | 7 | #include "util/header.h" |
8 | #include "util/parse-options.h" | 8 | #include "util/parse-options.h" |
9 | #include "util/session.h" | 9 | #include "util/session.h" |
10 | #include "util/tool.h" | ||
10 | #include "util/symbol.h" | 11 | #include "util/symbol.h" |
11 | #include "util/thread.h" | 12 | #include "util/thread.h" |
12 | #include "util/trace-event.h" | 13 | #include "util/trace-event.h" |
@@ -315,7 +316,7 @@ static bool sample_addr_correlates_sym(struct perf_event_attr *attr) | |||
315 | 316 | ||
316 | static void print_sample_addr(union perf_event *event, | 317 | static void print_sample_addr(union perf_event *event, |
317 | struct perf_sample *sample, | 318 | struct perf_sample *sample, |
318 | struct perf_session *session, | 319 | struct machine *machine, |
319 | struct thread *thread, | 320 | struct thread *thread, |
320 | struct perf_event_attr *attr) | 321 | struct perf_event_attr *attr) |
321 | { | 322 | { |
@@ -328,11 +329,11 @@ static void print_sample_addr(union perf_event *event, | |||
328 | if (!sample_addr_correlates_sym(attr)) | 329 | if (!sample_addr_correlates_sym(attr)) |
329 | return; | 330 | return; |
330 | 331 | ||
331 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, | 332 | thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, |
332 | event->ip.pid, sample->addr, &al); | 333 | sample->addr, &al); |
333 | if (!al.map) | 334 | if (!al.map) |
334 | thread__find_addr_map(thread, session, cpumode, MAP__VARIABLE, | 335 | thread__find_addr_map(thread, machine, cpumode, MAP__VARIABLE, |
335 | event->ip.pid, sample->addr, &al); | 336 | sample->addr, &al); |
336 | 337 | ||
337 | al.cpu = sample->cpu; | 338 | al.cpu = sample->cpu; |
338 | al.sym = NULL; | 339 | al.sym = NULL; |
@@ -362,7 +363,7 @@ static void print_sample_addr(union perf_event *event, | |||
362 | static void process_event(union perf_event *event __unused, | 363 | static void process_event(union perf_event *event __unused, |
363 | struct perf_sample *sample, | 364 | struct perf_sample *sample, |
364 | struct perf_evsel *evsel, | 365 | struct perf_evsel *evsel, |
365 | struct perf_session *session, | 366 | struct machine *machine, |
366 | struct thread *thread) | 367 | struct thread *thread) |
367 | { | 368 | { |
368 | struct perf_event_attr *attr = &evsel->attr; | 369 | struct perf_event_attr *attr = &evsel->attr; |
@@ -377,15 +378,15 @@ static void process_event(union perf_event *event __unused, | |||
377 | sample->raw_size); | 378 | sample->raw_size); |
378 | 379 | ||
379 | if (PRINT_FIELD(ADDR)) | 380 | if (PRINT_FIELD(ADDR)) |
380 | print_sample_addr(event, sample, session, thread, attr); | 381 | print_sample_addr(event, sample, machine, thread, attr); |
381 | 382 | ||
382 | if (PRINT_FIELD(IP)) { | 383 | if (PRINT_FIELD(IP)) { |
383 | if (!symbol_conf.use_callchain) | 384 | if (!symbol_conf.use_callchain) |
384 | printf(" "); | 385 | printf(" "); |
385 | else | 386 | else |
386 | printf("\n"); | 387 | printf("\n"); |
387 | perf_session__print_ip(event, sample, session, | 388 | perf_event__print_ip(event, sample, machine, evsel, |
388 | PRINT_FIELD(SYM), PRINT_FIELD(DSO)); | 389 | PRINT_FIELD(SYM), PRINT_FIELD(DSO)); |
389 | } | 390 | } |
390 | 391 | ||
391 | printf("\n"); | 392 | printf("\n"); |
@@ -434,12 +435,14 @@ static int cleanup_scripting(void) | |||
434 | 435 | ||
435 | static char const *input_name = "perf.data"; | 436 | static char const *input_name = "perf.data"; |
436 | 437 | ||
437 | static int process_sample_event(union perf_event *event, | 438 | static int process_sample_event(struct perf_tool *tool __used, |
439 | union perf_event *event, | ||
438 | struct perf_sample *sample, | 440 | struct perf_sample *sample, |
439 | struct perf_evsel *evsel, | 441 | struct perf_evsel *evsel, |
440 | struct perf_session *session) | 442 | struct machine *machine) |
441 | { | 443 | { |
442 | struct thread *thread = perf_session__findnew(session, event->ip.pid); | 444 | struct addr_location al; |
445 | struct thread *thread = machine__findnew_thread(machine, event->ip.pid); | ||
443 | 446 | ||
444 | if (thread == NULL) { | 447 | if (thread == NULL) { |
445 | pr_debug("problem processing %d event, skipping it.\n", | 448 | pr_debug("problem processing %d event, skipping it.\n", |
@@ -458,16 +461,25 @@ static int process_sample_event(union perf_event *event, | |||
458 | return 0; | 461 | return 0; |
459 | } | 462 | } |
460 | 463 | ||
464 | if (perf_event__preprocess_sample(event, machine, &al, sample, 0) < 0) { | ||
465 | pr_err("problem processing %d event, skipping it.\n", | ||
466 | event->header.type); | ||
467 | return -1; | ||
468 | } | ||
469 | |||
470 | if (al.filtered) | ||
471 | return 0; | ||
472 | |||
461 | if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) | 473 | if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) |
462 | return 0; | 474 | return 0; |
463 | 475 | ||
464 | scripting_ops->process_event(event, sample, evsel, session, thread); | 476 | scripting_ops->process_event(event, sample, evsel, machine, thread); |
465 | 477 | ||
466 | session->hists.stats.total_period += sample->period; | 478 | evsel->hists.stats.total_period += sample->period; |
467 | return 0; | 479 | return 0; |
468 | } | 480 | } |
469 | 481 | ||
470 | static struct perf_event_ops event_ops = { | 482 | static struct perf_tool perf_script = { |
471 | .sample = process_sample_event, | 483 | .sample = process_sample_event, |
472 | .mmap = perf_event__process_mmap, | 484 | .mmap = perf_event__process_mmap, |
473 | .comm = perf_event__process_comm, | 485 | .comm = perf_event__process_comm, |
@@ -494,7 +506,7 @@ static int __cmd_script(struct perf_session *session) | |||
494 | 506 | ||
495 | signal(SIGINT, sig_handler); | 507 | signal(SIGINT, sig_handler); |
496 | 508 | ||
497 | ret = perf_session__process_events(session, &event_ops); | 509 | ret = perf_session__process_events(session, &perf_script); |
498 | 510 | ||
499 | if (debug_mode) | 511 | if (debug_mode) |
500 | pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered); | 512 | pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered); |
@@ -1083,7 +1095,9 @@ static const struct option options[] = { | |||
1083 | OPT_CALLBACK('f', "fields", NULL, "str", | 1095 | OPT_CALLBACK('f', "fields", NULL, "str", |
1084 | "comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr", | 1096 | "comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr", |
1085 | parse_output_fields), | 1097 | parse_output_fields), |
1086 | OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"), | 1098 | OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"), |
1099 | OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", | ||
1100 | "only display events for these comms"), | ||
1087 | OPT_BOOLEAN('I', "show-info", &show_full_info, | 1101 | OPT_BOOLEAN('I', "show-info", &show_full_info, |
1088 | "display extended information from perf.data file"), | 1102 | "display extended information from perf.data file"), |
1089 | OPT_END() | 1103 | OPT_END() |
@@ -1261,7 +1275,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __used) | |||
1261 | if (!script_name) | 1275 | if (!script_name) |
1262 | setup_pager(); | 1276 | setup_pager(); |
1263 | 1277 | ||
1264 | session = perf_session__new(input_name, O_RDONLY, 0, false, &event_ops); | 1278 | session = perf_session__new(input_name, O_RDONLY, 0, false, &perf_script); |
1265 | if (session == NULL) | 1279 | if (session == NULL) |
1266 | return -ENOMEM; | 1280 | return -ENOMEM; |
1267 | 1281 | ||