aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 19:09:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 19:09:53 -0400
commitef35ad26f8ff44d2c93e29952cdb336bda729d9d (patch)
treee2921072b9f4d820b18d6e5bc489b64ef2068668 /tools/perf/builtin-script.c
parent8efb90cf1e80129fad197b916714e1d01ee183d2 (diff)
parentf9b9f812235d53f774a083e88a5a23b517a69752 (diff)
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf changes from Ingo Molnar: "Kernel side changes: - Consolidate the PMU interrupt-disabled code amongst architectures (Vince Weaver) - misc fixes Tooling changes (new features, user visible changes): - Add support for pagefault tracing in 'trace', please see multiple examples in the changeset messages (Stanislav Fomichev). - Add pagefault statistics in 'trace' (Stanislav Fomichev) - Add header for columns in 'top' and 'report' TUI browsers (Jiri Olsa) - Add pagefault statistics in 'trace' (Stanislav Fomichev) - Add IO mode into timechart command (Stanislav Fomichev) - Fallback to syscalls:* when raw_syscalls:* is not available in the perl and python perf scripts. (Daniel Bristot de Oliveira) - Add --repeat global option to 'perf bench' to be used in benchmarks such as the existing 'futex' one, that was modified to use it instead of a local option. (Davidlohr Bueso) - Fix fd -> pathname resolution in 'trace', be it using /proc or a vfs_getname probe point. (Arnaldo Carvalho de Melo) - Add suggestion of how to set perf_event_paranoid sysctl, to help non-root users trying tools like 'trace' to get a working environment. (Arnaldo Carvalho de Melo) - Updates from trace-cmd for traceevent plugin_kvm plus args cleanup (Steven Rostedt, Jan Kiszka) - Support S/390 in 'perf kvm stat' (Alexander Yarygin) Tooling infrastructure changes: - Allow reserving a row for header purposes in the hists browser (Arnaldo Carvalho de Melo) - Various fixes and prep work related to supporting Intel PT (Adrian Hunter) - Introduce multiple debug variables control (Jiri Olsa) - Add callchain and additional sample information for python scripts (Joseph Schuchart) - More prep work to support Intel PT: (Adrian Hunter) - Polishing 'script' BTS output - 'inject' can specify --kallsym - VDSO is per machine, not a global var - Expose data addr lookup functions previously private to 'script' - Large mmap fixes in events processing - Include standard stringify macros in power pc code (Sukadev Bhattiprolu) Tooling cleanups: - Convert open coded equivalents to asprintf() (Andy Shevchenko) - Remove needless reassignments in 'trace' (Arnaldo Carvalho de Melo) - Cache the is_exit syscall test in 'trace) (Arnaldo Carvalho de Melo) - No need to reimplement err() in 'perf bench sched-messaging', drop barf(). (Davidlohr Bueso). - Remove ev_name argument from perf_evsel__hists_browse, can be obtained from the other parameters. (Jiri Olsa) Tooling fixes: - Fix memory leak in the 'sched-messaging' perf bench test. (Davidlohr Bueso) - The -o and -n 'perf bench mem' options are mutually exclusive, emit error when both are specified. (Davidlohr Bueso) - Fix scrollbar refresh row index in the ui browser, problem exposed now that headers will be added and will be allowed to be switched on/off. (Jiri Olsa) - Handle the num array type in python properly (Sebastian Andrzej Siewior) - Fix wrong condition for allocation failure (Jiri Olsa) - Adjust callchain based on DWARF debug info on powerpc (Sukadev Bhattiprolu) - Fix a risk for doing free on uninitialized pointer in traceevent lib (Rickard Strandqvist) - Update attr test with PERF_FLAG_FD_CLOEXEC flag (Jiri Olsa) - Enable close-on-exec flag on perf file descriptor (Yann Droneaud) - Fix build on gcc 4.4.7 (Arnaldo Carvalho de Melo) - Event ordering fixes (Jiri Olsa)" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (123 commits) Revert "perf tools: Fix jump label always changing during tracing" perf tools: Fix perf usage string leftover perf: Check permission only for parent tracepoint event perf record: Store PERF_RECORD_FINISHED_ROUND only for nonempty rounds perf record: Always force PERF_RECORD_FINISHED_ROUND event perf inject: Add --kallsyms parameter perf tools: Expose 'addr' functions so they can be reused perf session: Fix accounting of ordered samples queue perf powerpc: Include util/util.h and remove stringify macros perf tools: Fix build on gcc 4.4.7 perf tools: Add thread parameter to vdso__dso_findnew() perf tools: Add dso__type() perf tools: Separate the VDSO map name from the VDSO dso name perf tools: Add vdso__new() perf machine: Fix the lifetime of the VDSO temporary file perf tools: Group VDSO global variables into a structure perf session: Add ability to skip 4GiB or more perf session: Add ability to 'skip' a non-piped event stream perf tools: Pass machine to vdso__dso_findnew() perf tools: Add dso__data_size() ...
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c60
1 files changed, 19 insertions, 41 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9e9c91f5b7fa..f57035b89c15 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -358,27 +358,6 @@ static void print_sample_start(struct perf_sample *sample,
358 } 358 }
359} 359}
360 360
361static bool is_bts_event(struct perf_event_attr *attr)
362{
363 return ((attr->type == PERF_TYPE_HARDWARE) &&
364 (attr->config & PERF_COUNT_HW_BRANCH_INSTRUCTIONS) &&
365 (attr->sample_period == 1));
366}
367
368static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
369{
370 if ((attr->type == PERF_TYPE_SOFTWARE) &&
371 ((attr->config == PERF_COUNT_SW_PAGE_FAULTS) ||
372 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MIN) ||
373 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)))
374 return true;
375
376 if (is_bts_event(attr))
377 return true;
378
379 return false;
380}
381
382static void print_sample_addr(union perf_event *event, 361static void print_sample_addr(union perf_event *event,
383 struct perf_sample *sample, 362 struct perf_sample *sample,
384 struct machine *machine, 363 struct machine *machine,
@@ -386,24 +365,13 @@ static void print_sample_addr(union perf_event *event,
386 struct perf_event_attr *attr) 365 struct perf_event_attr *attr)
387{ 366{
388 struct addr_location al; 367 struct addr_location al;
389 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
390 368
391 printf("%16" PRIx64, sample->addr); 369 printf("%16" PRIx64, sample->addr);
392 370
393 if (!sample_addr_correlates_sym(attr)) 371 if (!sample_addr_correlates_sym(attr))
394 return; 372 return;
395 373
396 thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, 374 perf_event__preprocess_sample_addr(event, sample, machine, thread, &al);
397 sample->addr, &al);
398 if (!al.map)
399 thread__find_addr_map(thread, machine, cpumode, MAP__VARIABLE,
400 sample->addr, &al);
401
402 al.cpu = sample->cpu;
403 al.sym = NULL;
404
405 if (al.map)
406 al.sym = map__find_symbol(al.map, al.addr, NULL);
407 375
408 if (PRINT_FIELD(SYM)) { 376 if (PRINT_FIELD(SYM)) {
409 printf(" "); 377 printf(" ");
@@ -427,25 +395,35 @@ static void print_sample_bts(union perf_event *event,
427 struct addr_location *al) 395 struct addr_location *al)
428{ 396{
429 struct perf_event_attr *attr = &evsel->attr; 397 struct perf_event_attr *attr = &evsel->attr;
398 bool print_srcline_last = false;
430 399
431 /* print branch_from information */ 400 /* print branch_from information */
432 if (PRINT_FIELD(IP)) { 401 if (PRINT_FIELD(IP)) {
433 if (!symbol_conf.use_callchain) 402 unsigned int print_opts = output[attr->type].print_ip_opts;
434 printf(" "); 403
435 else 404 if (symbol_conf.use_callchain && sample->callchain) {
436 printf("\n"); 405 printf("\n");
437 perf_evsel__print_ip(evsel, sample, al, 406 } else {
438 output[attr->type].print_ip_opts, 407 printf(" ");
408 if (print_opts & PRINT_IP_OPT_SRCLINE) {
409 print_srcline_last = true;
410 print_opts &= ~PRINT_IP_OPT_SRCLINE;
411 }
412 }
413 perf_evsel__print_ip(evsel, sample, al, print_opts,
439 PERF_MAX_STACK_DEPTH); 414 PERF_MAX_STACK_DEPTH);
440 } 415 }
441 416
442 printf(" => ");
443
444 /* print branch_to information */ 417 /* print branch_to information */
445 if (PRINT_FIELD(ADDR) || 418 if (PRINT_FIELD(ADDR) ||
446 ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) && 419 ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
447 !output[attr->type].user_set)) 420 !output[attr->type].user_set)) {
421 printf(" => ");
448 print_sample_addr(event, sample, al->machine, thread, attr); 422 print_sample_addr(event, sample, al->machine, thread, attr);
423 }
424
425 if (print_srcline_last)
426 map__fprintf_srcline(al->map, al->addr, "\n ", stdout);
449 427
450 printf("\n"); 428 printf("\n");
451} 429}