History

perf script: Add period data column

Adding period data column to be displayed in perf script. It's possible to get period values using -f option, like: $ perf script -f comm,tid,time,period,ip,sym,dso :26019 26019 52414.329088: 3707 ffffffff8105443a native_write_msr_safe ([kernel.kallsyms]) :26019 26019 52414.329088: 44 ffffffff8105443a native_write_msr_safe ([kernel.kallsyms]) :26019 26019 52414.329093: 1987 ffffffff8105443a native_write_msr_safe ([kernel.kallsyms]) :26019 26019 52414.329093: 6 ffffffff8105443a native_write_msr_safe ([kernel.kallsyms]) ls 26019 52414.329442: 537558 3407c0639c _dl_map_object_from_fd (/usr/lib64/ld-2.17.so) ls 26019 52414.329442: 2099 3407c0639c _dl_map_object_from_fd (/usr/lib64/ld-2.17.so) ls 26019 52414.330181: 1242100 34080917bb get_next_seq (/usr/lib64/libc-2.17.so) ls 26019 52414.330181: 3774 34080917bb get_next_seq (/usr/lib64/libc-2.17.so) ls 26019 52414.331427: 1083662 ffffffff810c7dc2 update_curr ([kernel.kallsyms]) ls 26019 52414.331427: 360 ffffffff810c7dc2 update_curr ([kernel.kallsyms])

Jiri Olsa committed 12 years ago

Commit 535aeaa1 parent f14d5702 files · +12 −2Browse files

Unified · Split

2 files
  1. tools/perf/Documentation/perf-script.txt +1 −1
  2. tools/perf/builtin-script.c +11 −1
tools/perf/Documentation/perf-script.txt+1−1
@@ -115,7 +115,7 @@ OPTIONS · 114 unmodified lines
115-f::115-f::
116--fields::116--fields::
117 Comma separated list of fields to print. Options are:117 Comma separated list of fields to print. Options are:
118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline.118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period.
119 Field list can be prepended with the type, trace, sw or hw,119 Field list can be prepended with the type, trace, sw or hw,
120 to indicate to which event type the field list applies.120 to indicate to which event type the field list applies.
121 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace121 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
tools/perf/builtin-script.c+11−1
@@ -44,6 +44,7 @@ enum perf_output_field { · 43 unmodified lines
44 PERF_OUTPUT_ADDR = 1U << 10,44 PERF_OUTPUT_ADDR = 1U << 10,
45 PERF_OUTPUT_SYMOFFSET = 1U << 11,45 PERF_OUTPUT_SYMOFFSET = 1U << 11,
46 PERF_OUTPUT_SRCLINE = 1U << 12,46 PERF_OUTPUT_SRCLINE = 1U << 12,
47 PERF_OUTPUT_PERIOD = 1U << 13,
47};48};
48 49
49struct output_option {50struct output_option {
@@ -63,6 +64,7 @@ struct output_option { · 13 unmodified lines
63 {.str = "addr", .field = PERF_OUTPUT_ADDR},64 {.str = "addr", .field = PERF_OUTPUT_ADDR},
64 {.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},65 {.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
65 {.str = "srcline", .field = PERF_OUTPUT_SRCLINE},66 {.str = "srcline", .field = PERF_OUTPUT_SRCLINE},
67 {.str = "period", .field = PERF_OUTPUT_PERIOD},
66};68};
67 69
68/* default set to maintain compatibility with current format */70/* default set to maintain compatibility with current format */
@@ -229,6 +231,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, · 160 unmodified lines
229 PERF_OUTPUT_CPU))231 PERF_OUTPUT_CPU))
230 return -EINVAL;232 return -EINVAL;
231 233
234 if (PRINT_FIELD(PERIOD) &&
235 perf_evsel__check_stype(evsel, PERF_SAMPLE_PERIOD, "PERIOD",
236 PERF_OUTPUT_PERIOD))
237 return -EINVAL;
238
232 return 0;239 return 0;
233}240}
234 241
@@ -448,6 +455,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample, · 213 unmodified lines
448 455
449 print_sample_start(sample, thread, evsel);456 print_sample_start(sample, thread, evsel);
450 457
458 if (PRINT_FIELD(PERIOD))
459 printf("%10" PRIu64 " ", sample->period);
460
451 if (PRINT_FIELD(EVNAME)) {461 if (PRINT_FIELD(EVNAME)) {
452 const char *evname = perf_evsel__name(evsel);462 const char *evname = perf_evsel__name(evsel);
453 printf("%s: ", evname ? evname : "[unknown]");463 printf("%s: ", evname ? evname : "[unknown]");
@@ -1543,7 +1553,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) · 1089 unmodified lines
1543 "comma separated output fields prepend with 'type:'. "1553 "comma separated output fields prepend with 'type:'. "
1544 "Valid types: hw,sw,trace,raw. "1554 "Valid types: hw,sw,trace,raw. "
1545 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"1555 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
1546 "addr,symoff", parse_output_fields),1556 "addr,symoff,period", parse_output_fields),
1547 OPT_BOOLEAN('a', "all-cpus", &system_wide,1557 OPT_BOOLEAN('a', "all-cpus", &system_wide,
1548 "system-wide collection from all CPUs"),1558 "system-wide collection from all CPUs"),
1549 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",1559 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t