diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2016-11-29 12:15:43 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-12-01 11:02:45 -0500 |
commit | a91f4c473fa1655a2a5f1ceba46f76a95eef35bb (patch) | |
tree | b4600475102d836393f1aab2938de908f450805f /tools/perf/builtin-script.c | |
parent | c284d669a20d408b70ce0dc9b2d995971f5fe0c7 (diff) |
perf script: Add option to specify time window of interest
Add option to allow user to control analysis window. e.g., collect data
for some amount of time and analyze a segment of interest within that
window.
Committer notes:
Testing it:
# perf evlist -v
cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
#
# perf script --hide-call-graph | head -15
swapper 0 [0] 9693.370039: 1 cycles:ppp: ffffffffb90072ad x86_pmu_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370044: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370046: 7 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370048: 126 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370049: 2701 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370051: 58823 cycles:ppp: ffffffffb90cd2e0 idle_cpu (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370059: 1 cycles:ppp: ffffffffb91a713a ctx_resched (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370062: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370064: 13 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370065: 250 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370067: 5269 cycles:ppp: ffffffffb902fe79 sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370069: 114602 cycles:ppp: ffffffffb90c1c5a atomic_notifier_call_chain (.../4.8.8-300.fc25.x86_64/vmlinux)
perf 5124 [2] 9693.370076: 1 cycles:ppp: ffffffffb91a76c1 __perf_event_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
perf 5124 [2] 9693.370091: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
perf 5124 [2] 9693.370095: 3 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
#
# perf script --hide-call-graph --time ,9693.370048
swapper 0 [0] 9693.370039: 1 cycles:ppp: ffffffffb90072ad x86_pmu_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370044: 1 cycles:ppp: ffffffffb900ca1b intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [0] 9693.370046: 7 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
# perf script --hide-call-graph --time 9693.370064,9693.370076
swapper 0 [1] 9693.370064: 13 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370065: 250 cycles:ppp: ffffffffb902fd93 native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370067: 5269 cycles:ppp: ffffffffb902fe79 sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper 0 [1] 9693.370069: 114602 cycles:ppp: ffffffffb90c1c5a atomic_notifier_call_chain (.../4.8.8-300.fc25.x86_64/vmlinux)
#
Signed-off-by: David Ahern <dsahern@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1480439746-42695-4-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 066b4bf73780..2f3ff69fc4e7 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "util/thread_map.h" | 22 | #include "util/thread_map.h" |
23 | #include "util/stat.h" | 23 | #include "util/stat.h" |
24 | #include "util/thread-stack.h" | 24 | #include "util/thread-stack.h" |
25 | #include "util/time-utils.h" | ||
25 | #include <linux/bitmap.h> | 26 | #include <linux/bitmap.h> |
26 | #include <linux/stringify.h> | 27 | #include <linux/stringify.h> |
27 | #include <linux/time64.h> | 28 | #include <linux/time64.h> |
@@ -833,6 +834,8 @@ struct perf_script { | |||
833 | struct cpu_map *cpus; | 834 | struct cpu_map *cpus; |
834 | struct thread_map *threads; | 835 | struct thread_map *threads; |
835 | int name_width; | 836 | int name_width; |
837 | const char *time_str; | ||
838 | struct perf_time_interval ptime; | ||
836 | }; | 839 | }; |
837 | 840 | ||
838 | static int perf_evlist__max_name_len(struct perf_evlist *evlist) | 841 | static int perf_evlist__max_name_len(struct perf_evlist *evlist) |
@@ -1014,6 +1017,9 @@ static int process_sample_event(struct perf_tool *tool, | |||
1014 | struct perf_script *scr = container_of(tool, struct perf_script, tool); | 1017 | struct perf_script *scr = container_of(tool, struct perf_script, tool); |
1015 | struct addr_location al; | 1018 | struct addr_location al; |
1016 | 1019 | ||
1020 | if (perf_time__skip_sample(&scr->ptime, sample->time)) | ||
1021 | return 0; | ||
1022 | |||
1017 | if (debug_mode) { | 1023 | if (debug_mode) { |
1018 | if (sample->time < last_timestamp) { | 1024 | if (sample->time < last_timestamp) { |
1019 | pr_err("Samples misordered, previous: %" PRIu64 | 1025 | pr_err("Samples misordered, previous: %" PRIu64 |
@@ -2186,7 +2192,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2186 | "Enable symbol demangling"), | 2192 | "Enable symbol demangling"), |
2187 | OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, | 2193 | OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, |
2188 | "Enable kernel symbol demangling"), | 2194 | "Enable kernel symbol demangling"), |
2189 | 2195 | OPT_STRING(0, "time", &script.time_str, "str", | |
2196 | "Time span of interest (start,stop)"), | ||
2190 | OPT_END() | 2197 | OPT_END() |
2191 | }; | 2198 | }; |
2192 | const char * const script_subcommands[] = { "record", "report", NULL }; | 2199 | const char * const script_subcommands[] = { "record", "report", NULL }; |
@@ -2465,6 +2472,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2465 | if (err < 0) | 2472 | if (err < 0) |
2466 | goto out_delete; | 2473 | goto out_delete; |
2467 | 2474 | ||
2475 | /* needs to be parsed after looking up reference time */ | ||
2476 | if (perf_time__parse_str(&script.ptime, script.time_str) != 0) { | ||
2477 | pr_err("Invalid time string\n"); | ||
2478 | return -EINVAL; | ||
2479 | } | ||
2480 | |||
2468 | err = __cmd_script(&script); | 2481 | err = __cmd_script(&script); |
2469 | 2482 | ||
2470 | flush_scripting(); | 2483 | flush_scripting(); |