aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/Documentation/perf-script.txt2
-rw-r--r--tools/perf/builtin-script.c12
2 files changed, 12 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 5a0160d359a1..21494806c0ab 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -115,7 +115,7 @@ OPTIONS
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,trace 121 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 6b4925f65bf0..0659dff4a21d 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -44,6 +44,7 @@ enum perf_output_field {
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 {
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,
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,
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)
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...]",