2 * builtin-timechart.c - make an svg timechart of system activity
4 * (C) Copyright 2009 Intel Corporation
7 * Arjan van de Ven <arjan@linux.intel.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; version 2
15 #include <traceevent/event-parse.h>
19 #include "util/util.h"
21 #include "util/color.h"
22 #include <linux/list.h>
23 #include "util/cache.h"
24 #include "util/evlist.h"
25 #include "util/evsel.h"
26 #include <linux/rbtree.h>
27 #include "util/symbol.h"
28 #include "util/callchain.h"
29 #include "util/strlist.h"
32 #include "util/header.h"
33 #include "util/parse-options.h"
34 #include "util/parse-events.h"
35 #include "util/event.h"
36 #include "util/session.h"
37 #include "util/svghelper.h"
38 #include "util/tool.h"
39 #include "util/data.h"
41 #define SUPPORT_OLD_POWER_EVENTS 1
42 #define PWR_EVENT_EXIT -1
44 static int proc_num = 15;
46 static unsigned int numcpus;
47 static u64 min_freq; /* Lowest CPU frequency seen */
48 static u64 max_freq; /* Highest CPU frequency seen */
49 static u64 turbo_frequency;
51 static u64 first_time, last_time;
53 static bool power_only;
54 static bool tasks_only;
55 static bool with_backtrace;
65 struct sample_wrapper;
68 * Datastructure layout:
69 * We keep an list of "pid"s, matching the kernels notion of a task struct.
70 * Each "pid" entry, has a list of "comm"s.
71 * this is because we want to track different programs different, while
72 * exec will reuse the original pid (by design).
73 * Each comm has a list of samples that will be used to draw
88 struct per_pidcomm *all;
89 struct per_pidcomm *current;
94 struct per_pidcomm *next;
108 struct cpu_sample *samples;
111 struct sample_wrapper {
112 struct sample_wrapper *next;
115 unsigned char data[0];
119 #define TYPE_RUNNING 1
120 #define TYPE_WAITING 2
121 #define TYPE_BLOCKED 3
124 struct cpu_sample *next;
130 const char *backtrace;
133 static struct per_pid *all_data;
139 struct power_event *next;
148 struct wake_event *next;
152 const char *backtrace;
155 static struct power_event *power_events;
156 static struct wake_event *wake_events;
158 struct process_filter;
159 struct process_filter {
162 struct process_filter *next;
165 static struct process_filter *process_filter;
168 static struct per_pid *find_create_pid(int pid)
170 struct per_pid *cursor = all_data;
173 if (cursor->pid == pid)
175 cursor = cursor->next;
177 cursor = zalloc(sizeof(*cursor));
178 assert(cursor != NULL);
180 cursor->next = all_data;
185 static void pid_set_comm(int pid, char *comm)
188 struct per_pidcomm *c;
189 p = find_create_pid(pid);
192 if (c->comm && strcmp(c->comm, comm) == 0) {
197 c->comm = strdup(comm);
203 c = zalloc(sizeof(*c));
205 c->comm = strdup(comm);
211 static void pid_fork(int pid, int ppid, u64 timestamp)
213 struct per_pid *p, *pp;
214 p = find_create_pid(pid);
215 pp = find_create_pid(ppid);
217 if (pp->current && pp->current->comm && !p->current)
218 pid_set_comm(pid, pp->current->comm);
220 p->start_time = timestamp;
222 p->current->start_time = timestamp;
223 p->current->state_since = timestamp;
227 static void pid_exit(int pid, u64 timestamp)
230 p = find_create_pid(pid);
231 p->end_time = timestamp;
233 p->current->end_time = timestamp;
237 pid_put_sample(int pid, int type, unsigned int cpu, u64 start, u64 end,
238 const char *backtrace)
241 struct per_pidcomm *c;
242 struct cpu_sample *sample;
244 p = find_create_pid(pid);
247 c = zalloc(sizeof(*c));
254 sample = zalloc(sizeof(*sample));
255 assert(sample != NULL);
256 sample->start_time = start;
257 sample->end_time = end;
259 sample->next = c->samples;
261 sample->backtrace = backtrace;
264 if (sample->type == TYPE_RUNNING && end > start && start > 0) {
265 c->total_time += (end-start);
266 p->total_time += (end-start);
269 if (c->start_time == 0 || c->start_time > start)
270 c->start_time = start;
271 if (p->start_time == 0 || p->start_time > start)
272 p->start_time = start;
275 #define MAX_CPUS 4096
277 static u64 cpus_cstate_start_times[MAX_CPUS];
278 static int cpus_cstate_state[MAX_CPUS];
279 static u64 cpus_pstate_start_times[MAX_CPUS];
280 static u64 cpus_pstate_state[MAX_CPUS];
282 static int process_comm_event(struct perf_tool *tool __maybe_unused,
283 union perf_event *event,
284 struct perf_sample *sample __maybe_unused,
285 struct machine *machine __maybe_unused)
287 pid_set_comm(event->comm.tid, event->comm.comm);
291 static int process_fork_event(struct perf_tool *tool __maybe_unused,
292 union perf_event *event,
293 struct perf_sample *sample __maybe_unused,
294 struct machine *machine __maybe_unused)
296 pid_fork(event->fork.pid, event->fork.ppid, event->fork.time);
300 static int process_exit_event(struct perf_tool *tool __maybe_unused,
301 union perf_event *event,
302 struct perf_sample *sample __maybe_unused,
303 struct machine *machine __maybe_unused)
305 pid_exit(event->fork.pid, event->fork.time);
312 unsigned char preempt_count;
317 #ifdef SUPPORT_OLD_POWER_EVENTS
318 static int use_old_power_events;
319 struct power_entry_old {
320 struct trace_entry te;
327 struct power_processor_entry {
328 struct trace_entry te;
333 #define TASK_COMM_LEN 16
334 struct wakeup_entry {
335 struct trace_entry te;
336 char comm[TASK_COMM_LEN];
342 struct sched_switch {
343 struct trace_entry te;
344 char prev_comm[TASK_COMM_LEN];
347 long prev_state; /* Arjan weeps. */
348 char next_comm[TASK_COMM_LEN];
353 static void c_state_start(int cpu, u64 timestamp, int state)
355 cpus_cstate_start_times[cpu] = timestamp;
356 cpus_cstate_state[cpu] = state;
359 static void c_state_end(int cpu, u64 timestamp)
361 struct power_event *pwr = zalloc(sizeof(*pwr));
366 pwr->state = cpus_cstate_state[cpu];
367 pwr->start_time = cpus_cstate_start_times[cpu];
368 pwr->end_time = timestamp;
371 pwr->next = power_events;
376 static void p_state_change(int cpu, u64 timestamp, u64 new_freq)
378 struct power_event *pwr;
380 if (new_freq > 8000000) /* detect invalid data */
383 pwr = zalloc(sizeof(*pwr));
387 pwr->state = cpus_pstate_state[cpu];
388 pwr->start_time = cpus_pstate_start_times[cpu];
389 pwr->end_time = timestamp;
392 pwr->next = power_events;
394 if (!pwr->start_time)
395 pwr->start_time = first_time;
399 cpus_pstate_state[cpu] = new_freq;
400 cpus_pstate_start_times[cpu] = timestamp;
402 if ((u64)new_freq > max_freq)
405 if (new_freq < min_freq || min_freq == 0)
408 if (new_freq == max_freq - 1000)
409 turbo_frequency = max_freq;
413 sched_wakeup(int cpu, u64 timestamp, int pid, struct trace_entry *te,
414 const char *backtrace)
417 struct wakeup_entry *wake = (void *)te;
418 struct wake_event *we = zalloc(sizeof(*we));
423 we->time = timestamp;
425 we->backtrace = backtrace;
427 if ((te->flags & TRACE_FLAG_HARDIRQ) || (te->flags & TRACE_FLAG_SOFTIRQ))
430 we->wakee = wake->pid;
431 we->next = wake_events;
433 p = find_create_pid(we->wakee);
435 if (p && p->current && p->current->state == TYPE_NONE) {
436 p->current->state_since = timestamp;
437 p->current->state = TYPE_WAITING;
439 if (p && p->current && p->current->state == TYPE_BLOCKED) {
440 pid_put_sample(p->pid, p->current->state, cpu,
441 p->current->state_since, timestamp, NULL);
442 p->current->state_since = timestamp;
443 p->current->state = TYPE_WAITING;
447 static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te,
448 const char *backtrace)
450 struct per_pid *p = NULL, *prev_p;
451 struct sched_switch *sw = (void *)te;
454 prev_p = find_create_pid(sw->prev_pid);
456 p = find_create_pid(sw->next_pid);
458 if (prev_p->current && prev_p->current->state != TYPE_NONE)
459 pid_put_sample(sw->prev_pid, TYPE_RUNNING, cpu,
460 prev_p->current->state_since, timestamp,
462 if (p && p->current) {
463 if (p->current->state != TYPE_NONE)
464 pid_put_sample(sw->next_pid, p->current->state, cpu,
465 p->current->state_since, timestamp,
468 p->current->state_since = timestamp;
469 p->current->state = TYPE_RUNNING;
472 if (prev_p->current) {
473 prev_p->current->state = TYPE_NONE;
474 prev_p->current->state_since = timestamp;
475 if (sw->prev_state & 2)
476 prev_p->current->state = TYPE_BLOCKED;
477 if (sw->prev_state == 0)
478 prev_p->current->state = TYPE_WAITING;
482 static const char *cat_backtrace(union perf_event *event,
483 struct perf_sample *sample,
484 struct machine *machine)
486 struct addr_location al;
490 u8 cpumode = PERF_RECORD_MISC_USER;
491 struct addr_location tal;
492 struct ip_callchain *chain = sample->callchain;
493 FILE *f = open_memstream(&p, &p_len);
496 perror("open_memstream error");
503 if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
504 fprintf(stderr, "problem processing %d event, skipping it.\n",
509 for (i = 0; i < chain->nr; i++) {
512 if (callchain_param.order == ORDER_CALLEE)
515 ip = chain->ips[chain->nr - i - 1];
517 if (ip >= PERF_CONTEXT_MAX) {
519 case PERF_CONTEXT_HV:
520 cpumode = PERF_RECORD_MISC_HYPERVISOR;
522 case PERF_CONTEXT_KERNEL:
523 cpumode = PERF_RECORD_MISC_KERNEL;
525 case PERF_CONTEXT_USER:
526 cpumode = PERF_RECORD_MISC_USER;
529 pr_debug("invalid callchain context: "
530 "%"PRId64"\n", (s64) ip);
533 * It seems the callchain is corrupted.
543 tal.filtered = false;
544 thread__find_addr_location(al.thread, machine, cpumode,
545 MAP__FUNCTION, ip, &tal);
548 fprintf(f, "..... %016" PRIx64 " %s\n", ip,
551 fprintf(f, "..... %016" PRIx64 "\n", ip);
560 typedef int (*tracepoint_handler)(struct perf_evsel *evsel,
561 struct perf_sample *sample,
562 const char *backtrace);
564 static int process_sample_event(struct perf_tool *tool __maybe_unused,
565 union perf_event *event __maybe_unused,
566 struct perf_sample *sample,
567 struct perf_evsel *evsel,
568 struct machine *machine __maybe_unused)
570 if (evsel->attr.sample_type & PERF_SAMPLE_TIME) {
571 if (!first_time || first_time > sample->time)
572 first_time = sample->time;
573 if (last_time < sample->time)
574 last_time = sample->time;
577 if (sample->cpu > numcpus)
578 numcpus = sample->cpu;
580 if (evsel->handler != NULL) {
581 tracepoint_handler f = evsel->handler;
582 return f(evsel, sample, cat_backtrace(event, sample, machine));
589 process_sample_cpu_idle(struct perf_evsel *evsel __maybe_unused,
590 struct perf_sample *sample,
591 const char *backtrace __maybe_unused)
593 struct power_processor_entry *ppe = sample->raw_data;
595 if (ppe->state == (u32) PWR_EVENT_EXIT)
596 c_state_end(ppe->cpu_id, sample->time);
598 c_state_start(ppe->cpu_id, sample->time, ppe->state);
603 process_sample_cpu_frequency(struct perf_evsel *evsel __maybe_unused,
604 struct perf_sample *sample,
605 const char *backtrace __maybe_unused)
607 struct power_processor_entry *ppe = sample->raw_data;
609 p_state_change(ppe->cpu_id, sample->time, ppe->state);
614 process_sample_sched_wakeup(struct perf_evsel *evsel __maybe_unused,
615 struct perf_sample *sample,
616 const char *backtrace)
618 struct trace_entry *te = sample->raw_data;
620 sched_wakeup(sample->cpu, sample->time, sample->pid, te, backtrace);
625 process_sample_sched_switch(struct perf_evsel *evsel __maybe_unused,
626 struct perf_sample *sample,
627 const char *backtrace)
629 struct trace_entry *te = sample->raw_data;
631 sched_switch(sample->cpu, sample->time, te, backtrace);
635 #ifdef SUPPORT_OLD_POWER_EVENTS
637 process_sample_power_start(struct perf_evsel *evsel __maybe_unused,
638 struct perf_sample *sample,
639 const char *backtrace __maybe_unused)
641 struct power_entry_old *peo = sample->raw_data;
643 c_state_start(peo->cpu_id, sample->time, peo->value);
648 process_sample_power_end(struct perf_evsel *evsel __maybe_unused,
649 struct perf_sample *sample,
650 const char *backtrace __maybe_unused)
652 c_state_end(sample->cpu, sample->time);
657 process_sample_power_frequency(struct perf_evsel *evsel __maybe_unused,
658 struct perf_sample *sample,
659 const char *backtrace __maybe_unused)
661 struct power_entry_old *peo = sample->raw_data;
663 p_state_change(peo->cpu_id, sample->time, peo->value);
666 #endif /* SUPPORT_OLD_POWER_EVENTS */
669 * After the last sample we need to wrap up the current C/P state
670 * and close out each CPU for these.
672 static void end_sample_processing(void)
675 struct power_event *pwr;
677 for (cpu = 0; cpu <= numcpus; cpu++) {
680 pwr = zalloc(sizeof(*pwr));
684 pwr->state = cpus_cstate_state[cpu];
685 pwr->start_time = cpus_cstate_start_times[cpu];
686 pwr->end_time = last_time;
689 pwr->next = power_events;
695 pwr = zalloc(sizeof(*pwr));
699 pwr->state = cpus_pstate_state[cpu];
700 pwr->start_time = cpus_pstate_start_times[cpu];
701 pwr->end_time = last_time;
704 pwr->next = power_events;
706 if (!pwr->start_time)
707 pwr->start_time = first_time;
709 pwr->state = min_freq;
715 * Sort the pid datastructure
717 static void sort_pids(void)
719 struct per_pid *new_list, *p, *cursor, *prev;
720 /* sort by ppid first, then by pid, lowest to highest */
729 if (new_list == NULL) {
737 if (cursor->ppid > p->ppid ||
738 (cursor->ppid == p->ppid && cursor->pid > p->pid)) {
739 /* must insert before */
741 p->next = prev->next;
754 cursor = cursor->next;
763 static void draw_c_p_states(void)
765 struct power_event *pwr;
769 * two pass drawing so that the P state bars are on top of the C state blocks
772 if (pwr->type == CSTATE)
773 svg_cstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state);
779 if (pwr->type == PSTATE) {
781 pwr->state = min_freq;
782 svg_pstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state);
788 static void draw_wakeups(void)
790 struct wake_event *we;
792 struct per_pidcomm *c;
796 int from = 0, to = 0;
797 char *task_from = NULL, *task_to = NULL;
799 /* locate the column of the waker and wakee */
802 if (p->pid == we->waker || p->pid == we->wakee) {
805 if (c->Y && c->start_time <= we->time && c->end_time >= we->time) {
806 if (p->pid == we->waker && !from) {
808 task_from = strdup(c->comm);
810 if (p->pid == we->wakee && !to) {
812 task_to = strdup(c->comm);
819 if (p->pid == we->waker && !from) {
821 task_from = strdup(c->comm);
823 if (p->pid == we->wakee && !to) {
825 task_to = strdup(c->comm);
834 task_from = malloc(40);
835 sprintf(task_from, "[%i]", we->waker);
838 task_to = malloc(40);
839 sprintf(task_to, "[%i]", we->wakee);
843 svg_interrupt(we->time, to, we->backtrace);
844 else if (from && to && abs(from - to) == 1)
845 svg_wakeline(we->time, from, to, we->backtrace);
847 svg_partial_wakeline(we->time, from, task_from, to,
848 task_to, we->backtrace);
856 static void draw_cpu_usage(void)
859 struct per_pidcomm *c;
860 struct cpu_sample *sample;
867 if (sample->type == TYPE_RUNNING)
868 svg_process(sample->cpu, sample->start_time, sample->end_time, "sample", c->comm);
870 sample = sample->next;
878 static void draw_process_bars(void)
881 struct per_pidcomm *c;
882 struct cpu_sample *sample;
897 svg_box(Y, c->start_time, c->end_time, "process");
900 if (sample->type == TYPE_RUNNING)
901 svg_running(Y, sample->cpu,
905 if (sample->type == TYPE_BLOCKED)
906 svg_blocked(Y, sample->cpu,
910 if (sample->type == TYPE_WAITING)
911 svg_waiting(Y, sample->cpu,
915 sample = sample->next;
920 if (c->total_time > 5000000000) /* 5 seconds */
921 sprintf(comm, "%s:%i (%2.2fs)", c->comm, p->pid, c->total_time / 1000000000.0);
923 sprintf(comm, "%s:%i (%3.1fms)", c->comm, p->pid, c->total_time / 1000000.0);
925 svg_text(Y, c->start_time, comm);
935 static void add_process_filter(const char *string)
937 int pid = strtoull(string, NULL, 10);
938 struct process_filter *filt = malloc(sizeof(*filt));
943 filt->name = strdup(string);
945 filt->next = process_filter;
947 process_filter = filt;
950 static int passes_filter(struct per_pid *p, struct per_pidcomm *c)
952 struct process_filter *filt;
956 filt = process_filter;
958 if (filt->pid && p->pid == filt->pid)
960 if (strcmp(filt->name, c->comm) == 0)
967 static int determine_display_tasks_filtered(void)
970 struct per_pidcomm *c;
976 if (p->start_time == 1)
977 p->start_time = first_time;
979 /* no exit marker, task kept running to the end */
980 if (p->end_time == 0)
981 p->end_time = last_time;
988 if (c->start_time == 1)
989 c->start_time = first_time;
991 if (passes_filter(p, c)) {
997 if (c->end_time == 0)
998 c->end_time = last_time;
1007 static int determine_display_tasks(u64 threshold)
1010 struct per_pidcomm *c;
1014 return determine_display_tasks_filtered();
1019 if (p->start_time == 1)
1020 p->start_time = first_time;
1022 /* no exit marker, task kept running to the end */
1023 if (p->end_time == 0)
1024 p->end_time = last_time;
1025 if (p->total_time >= threshold)
1033 if (c->start_time == 1)
1034 c->start_time = first_time;
1036 if (c->total_time >= threshold) {
1041 if (c->end_time == 0)
1042 c->end_time = last_time;
1053 #define TIME_THRESH 10000000
1055 static void write_svg_file(const char *filename)
1059 int thresh = TIME_THRESH;
1066 /* We'd like to show at least proc_num tasks;
1067 * be less picky if we have fewer */
1069 count = determine_display_tasks(thresh);
1071 } while (!process_filter && thresh && count < proc_num);
1073 open_svg(filename, numcpus, count, first_time, last_time);
1078 for (i = 0; i < numcpus; i++)
1079 svg_cpu_box(i, max_freq, turbo_frequency);
1083 draw_process_bars();
1092 static int __cmd_timechart(const char *output_name)
1094 struct perf_tool perf_timechart = {
1095 .comm = process_comm_event,
1096 .fork = process_fork_event,
1097 .exit = process_exit_event,
1098 .sample = process_sample_event,
1099 .ordered_samples = true,
1101 const struct perf_evsel_str_handler power_tracepoints[] = {
1102 { "power:cpu_idle", process_sample_cpu_idle },
1103 { "power:cpu_frequency", process_sample_cpu_frequency },
1104 { "sched:sched_wakeup", process_sample_sched_wakeup },
1105 { "sched:sched_switch", process_sample_sched_switch },
1106 #ifdef SUPPORT_OLD_POWER_EVENTS
1107 { "power:power_start", process_sample_power_start },
1108 { "power:power_end", process_sample_power_end },
1109 { "power:power_frequency", process_sample_power_frequency },
1112 struct perf_data_file file = {
1114 .mode = PERF_DATA_MODE_READ,
1117 struct perf_session *session = perf_session__new(&file, false,
1121 if (session == NULL)
1124 if (!perf_session__has_traces(session, "timechart record"))
1127 if (perf_session__set_tracepoints_handlers(session,
1128 power_tracepoints)) {
1129 pr_err("Initializing session tracepoint handlers failed\n");
1133 ret = perf_session__process_events(session, &perf_timechart);
1137 end_sample_processing();
1141 write_svg_file(output_name);
1143 pr_info("Written %2.1f seconds of trace to %s.\n",
1144 (last_time - first_time) / 1000000000.0, output_name);
1146 perf_session__delete(session);
1150 static int __cmd_record(int argc, const char **argv)
1152 unsigned int rec_argc, i, j;
1153 const char **rec_argv;
1155 unsigned int record_elems;
1157 const char * const common_args[] = {
1158 "record", "-a", "-R", "-c", "1",
1160 unsigned int common_args_nr = ARRAY_SIZE(common_args);
1162 const char * const backtrace_args[] = {
1165 unsigned int backtrace_args_no = ARRAY_SIZE(backtrace_args);
1167 const char * const power_args[] = {
1168 "-e", "power:cpu_frequency",
1169 "-e", "power:cpu_idle",
1171 unsigned int power_args_nr = ARRAY_SIZE(power_args);
1173 const char * const old_power_args[] = {
1174 #ifdef SUPPORT_OLD_POWER_EVENTS
1175 "-e", "power:power_start",
1176 "-e", "power:power_end",
1177 "-e", "power:power_frequency",
1180 unsigned int old_power_args_nr = ARRAY_SIZE(old_power_args);
1182 const char * const tasks_args[] = {
1183 "-e", "sched:sched_wakeup",
1184 "-e", "sched:sched_switch",
1186 unsigned int tasks_args_nr = ARRAY_SIZE(tasks_args);
1188 #ifdef SUPPORT_OLD_POWER_EVENTS
1189 if (!is_valid_tracepoint("power:cpu_idle") &&
1190 is_valid_tracepoint("power:power_start")) {
1191 use_old_power_events = 1;
1194 old_power_args_nr = 0;
1203 old_power_args_nr = 0;
1206 if (!with_backtrace)
1207 backtrace_args_no = 0;
1209 record_elems = common_args_nr + tasks_args_nr +
1210 power_args_nr + old_power_args_nr + backtrace_args_no;
1212 rec_argc = record_elems + argc;
1213 rec_argv = calloc(rec_argc + 1, sizeof(char *));
1215 if (rec_argv == NULL)
1219 for (i = 0; i < common_args_nr; i++)
1220 *p++ = strdup(common_args[i]);
1222 for (i = 0; i < backtrace_args_no; i++)
1223 *p++ = strdup(backtrace_args[i]);
1225 for (i = 0; i < tasks_args_nr; i++)
1226 *p++ = strdup(tasks_args[i]);
1228 for (i = 0; i < power_args_nr; i++)
1229 *p++ = strdup(power_args[i]);
1231 for (i = 0; i < old_power_args_nr; i++)
1232 *p++ = strdup(old_power_args[i]);
1234 for (j = 1; j < (unsigned int)argc; j++)
1237 return cmd_record(rec_argc, rec_argv, NULL);
1241 parse_process(const struct option *opt __maybe_unused, const char *arg,
1242 int __maybe_unused unset)
1245 add_process_filter(arg);
1249 int cmd_timechart(int argc, const char **argv,
1250 const char *prefix __maybe_unused)
1252 const char *output_name = "output.svg";
1253 const struct option timechart_options[] = {
1254 OPT_STRING('i', "input", &input_name, "file", "input file name"),
1255 OPT_STRING('o', "output", &output_name, "file", "output file name"),
1256 OPT_INTEGER('w', "width", &svg_page_width, "page width"),
1257 OPT_BOOLEAN('P', "power-only", &power_only, "output power data only"),
1258 OPT_BOOLEAN('T', "tasks-only", &tasks_only,
1259 "output processes data only"),
1260 OPT_CALLBACK('p', "process", NULL, "process",
1261 "process selector. Pass a pid or process name.",
1263 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
1264 "Look for files with symbols relative to this directory"),
1265 OPT_INTEGER('n', "proc-num", &proc_num,
1266 "min. number of tasks to print"),
1269 const char * const timechart_usage[] = {
1270 "perf timechart [<options>] {record}",
1274 const struct option record_options[] = {
1275 OPT_BOOLEAN('P', "power-only", &power_only, "output power data only"),
1276 OPT_BOOLEAN('T', "tasks-only", &tasks_only,
1277 "output processes data only"),
1278 OPT_BOOLEAN('g', "callchain", &with_backtrace, "record callchain"),
1281 const char * const record_usage[] = {
1282 "perf timechart record [<options>]",
1285 argc = parse_options(argc, argv, timechart_options, timechart_usage,
1286 PARSE_OPT_STOP_AT_NON_OPTION);
1288 if (power_only && tasks_only) {
1289 pr_err("-P and -T options cannot be used at the same time.\n");
1295 if (argc && !strncmp(argv[0], "rec", 3)) {
1296 argc = parse_options(argc, argv, record_options, record_usage,
1297 PARSE_OPT_STOP_AT_NON_OPTION);
1299 if (power_only && tasks_only) {
1300 pr_err("-P and -T options cannot be used at the same time.\n");
1304 return __cmd_record(argc, argv);
1306 usage_with_options(timechart_usage, timechart_options);
1310 return __cmd_timechart(output_name);