diff options
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r-- | tools/perf/builtin-timechart.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index aa26f4d66d10..3b75b2e21ea5 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "util/color.h" | 19 | #include "util/color.h" |
20 | #include <linux/list.h> | 20 | #include <linux/list.h> |
21 | #include "util/cache.h" | 21 | #include "util/cache.h" |
22 | #include "util/evsel.h" | ||
22 | #include <linux/rbtree.h> | 23 | #include <linux/rbtree.h> |
23 | #include "util/symbol.h" | 24 | #include "util/symbol.h" |
24 | #include "util/callchain.h" | 25 | #include "util/callchain.h" |
@@ -31,13 +32,14 @@ | |||
31 | #include "util/event.h" | 32 | #include "util/event.h" |
32 | #include "util/session.h" | 33 | #include "util/session.h" |
33 | #include "util/svghelper.h" | 34 | #include "util/svghelper.h" |
35 | #include "util/tool.h" | ||
34 | 36 | ||
35 | #define SUPPORT_OLD_POWER_EVENTS 1 | 37 | #define SUPPORT_OLD_POWER_EVENTS 1 |
36 | #define PWR_EVENT_EXIT -1 | 38 | #define PWR_EVENT_EXIT -1 |
37 | 39 | ||
38 | 40 | ||
39 | static char const *input_name = "perf.data"; | 41 | static const char *input_name; |
40 | static char const *output_name = "output.svg"; | 42 | static const char *output_name = "output.svg"; |
41 | 43 | ||
42 | static unsigned int numcpus; | 44 | static unsigned int numcpus; |
43 | static u64 min_freq; /* Lowest CPU frequency seen */ | 45 | static u64 min_freq; /* Lowest CPU frequency seen */ |
@@ -273,25 +275,28 @@ static int cpus_cstate_state[MAX_CPUS]; | |||
273 | static u64 cpus_pstate_start_times[MAX_CPUS]; | 275 | static u64 cpus_pstate_start_times[MAX_CPUS]; |
274 | static u64 cpus_pstate_state[MAX_CPUS]; | 276 | static u64 cpus_pstate_state[MAX_CPUS]; |
275 | 277 | ||
276 | static int process_comm_event(union perf_event *event, | 278 | static int process_comm_event(struct perf_tool *tool __used, |
279 | union perf_event *event, | ||
277 | struct perf_sample *sample __used, | 280 | struct perf_sample *sample __used, |
278 | struct perf_session *session __used) | 281 | struct machine *machine __used) |
279 | { | 282 | { |
280 | pid_set_comm(event->comm.tid, event->comm.comm); | 283 | pid_set_comm(event->comm.tid, event->comm.comm); |
281 | return 0; | 284 | return 0; |
282 | } | 285 | } |
283 | 286 | ||
284 | static int process_fork_event(union perf_event *event, | 287 | static int process_fork_event(struct perf_tool *tool __used, |
288 | union perf_event *event, | ||
285 | struct perf_sample *sample __used, | 289 | struct perf_sample *sample __used, |
286 | struct perf_session *session __used) | 290 | struct machine *machine __used) |
287 | { | 291 | { |
288 | pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); | 292 | pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); |
289 | return 0; | 293 | return 0; |
290 | } | 294 | } |
291 | 295 | ||
292 | static int process_exit_event(union perf_event *event, | 296 | static int process_exit_event(struct perf_tool *tool __used, |
297 | union perf_event *event, | ||
293 | struct perf_sample *sample __used, | 298 | struct perf_sample *sample __used, |
294 | struct perf_session *session __used) | 299 | struct machine *machine __used) |
295 | { | 300 | { |
296 | pid_exit(event->fork.pid, event->fork.time); | 301 | pid_exit(event->fork.pid, event->fork.time); |
297 | return 0; | 302 | return 0; |
@@ -486,14 +491,15 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te) | |||
486 | } | 491 | } |
487 | 492 | ||
488 | 493 | ||
489 | static int process_sample_event(union perf_event *event __used, | 494 | static int process_sample_event(struct perf_tool *tool __used, |
495 | union perf_event *event __used, | ||
490 | struct perf_sample *sample, | 496 | struct perf_sample *sample, |
491 | struct perf_evsel *evsel __used, | 497 | struct perf_evsel *evsel, |
492 | struct perf_session *session) | 498 | struct machine *machine __used) |
493 | { | 499 | { |
494 | struct trace_entry *te; | 500 | struct trace_entry *te; |
495 | 501 | ||
496 | if (session->sample_type & PERF_SAMPLE_TIME) { | 502 | if (evsel->attr.sample_type & PERF_SAMPLE_TIME) { |
497 | if (!first_time || first_time > sample->time) | 503 | if (!first_time || first_time > sample->time) |
498 | first_time = sample->time; | 504 | first_time = sample->time; |
499 | if (last_time < sample->time) | 505 | if (last_time < sample->time) |
@@ -501,7 +507,7 @@ static int process_sample_event(union perf_event *event __used, | |||
501 | } | 507 | } |
502 | 508 | ||
503 | te = (void *)sample->raw_data; | 509 | te = (void *)sample->raw_data; |
504 | if (session->sample_type & PERF_SAMPLE_RAW && sample->raw_size > 0) { | 510 | if ((evsel->attr.sample_type & PERF_SAMPLE_RAW) && sample->raw_size > 0) { |
505 | char *event_str; | 511 | char *event_str; |
506 | #ifdef SUPPORT_OLD_POWER_EVENTS | 512 | #ifdef SUPPORT_OLD_POWER_EVENTS |
507 | struct power_entry_old *peo; | 513 | struct power_entry_old *peo; |
@@ -974,7 +980,7 @@ static void write_svg_file(const char *filename) | |||
974 | svg_close(); | 980 | svg_close(); |
975 | } | 981 | } |
976 | 982 | ||
977 | static struct perf_event_ops event_ops = { | 983 | static struct perf_tool perf_timechart = { |
978 | .comm = process_comm_event, | 984 | .comm = process_comm_event, |
979 | .fork = process_fork_event, | 985 | .fork = process_fork_event, |
980 | .exit = process_exit_event, | 986 | .exit = process_exit_event, |
@@ -985,7 +991,7 @@ static struct perf_event_ops event_ops = { | |||
985 | static int __cmd_timechart(void) | 991 | static int __cmd_timechart(void) |
986 | { | 992 | { |
987 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | 993 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, |
988 | 0, false, &event_ops); | 994 | 0, false, &perf_timechart); |
989 | int ret = -EINVAL; | 995 | int ret = -EINVAL; |
990 | 996 | ||
991 | if (session == NULL) | 997 | if (session == NULL) |
@@ -994,7 +1000,7 @@ static int __cmd_timechart(void) | |||
994 | if (!perf_session__has_traces(session, "timechart record")) | 1000 | if (!perf_session__has_traces(session, "timechart record")) |
995 | goto out_delete; | 1001 | goto out_delete; |
996 | 1002 | ||
997 | ret = perf_session__process_events(session, &event_ops); | 1003 | ret = perf_session__process_events(session, &perf_timechart); |
998 | if (ret) | 1004 | if (ret) |
999 | goto out_delete; | 1005 | goto out_delete; |
1000 | 1006 | ||