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);
309 #ifdef SUPPORT_OLD_POWER_EVENTS
310 static int use_old_power_events;
313 static void c_state_start(int cpu, u64 timestamp, int state)
315 cpus_cstate_start_times[cpu] = timestamp;
316 cpus_cstate_state[cpu] = state;
319 static void c_state_end(int cpu, u64 timestamp)
321 struct power_event *pwr = zalloc(sizeof(*pwr));
326 pwr->state = cpus_cstate_state[cpu];
327 pwr->start_time = cpus_cstate_start_times[cpu];
328 pwr->end_time = timestamp;
331 pwr->next = power_events;
336 static void p_state_change(int cpu, u64 timestamp, u64 new_freq)
338 struct power_event *pwr;
340 if (new_freq > 8000000) /* detect invalid data */
343 pwr = zalloc(sizeof(*pwr));
347 pwr->state = cpus_pstate_state[cpu];
348 pwr->start_time = cpus_pstate_start_times[cpu];
349 pwr->end_time = timestamp;
352 pwr->next = power_events;
354 if (!pwr->start_time)
355 pwr->start_time = first_time;
359 cpus_pstate_state[cpu] = new_freq;
360 cpus_pstate_start_times[cpu] = timestamp;
362 if ((u64)new_freq > max_freq)
365 if (new_freq < min_freq || min_freq == 0)
368 if (new_freq == max_freq - 1000)
369 turbo_frequency = max_freq;
372 static void sched_wakeup(int cpu, u64 timestamp, int waker, int wakee,
373 u8 flags, const char *backtrace)
376 struct wake_event *we = zalloc(sizeof(*we));
381 we->time = timestamp;
383 we->backtrace = backtrace;
385 if ((flags & TRACE_FLAG_HARDIRQ) || (flags & TRACE_FLAG_SOFTIRQ))
389 we->next = wake_events;
391 p = find_create_pid(we->wakee);
393 if (p && p->current && p->current->state == TYPE_NONE) {
394 p->current->state_since = timestamp;
395 p->current->state = TYPE_WAITING;
397 if (p && p->current && p->current->state == TYPE_BLOCKED) {
398 pid_put_sample(p->pid, p->current->state, cpu,
399 p->current->state_since, timestamp, NULL);
400 p->current->state_since = timestamp;
401 p->current->state = TYPE_WAITING;
405 static void sched_switch(int cpu, u64 timestamp, int prev_pid, int next_pid,
406 u64 prev_state, const char *backtrace)
408 struct per_pid *p = NULL, *prev_p;
410 prev_p = find_create_pid(prev_pid);
412 p = find_create_pid(next_pid);
414 if (prev_p->current && prev_p->current->state != TYPE_NONE)
415 pid_put_sample(prev_pid, TYPE_RUNNING, cpu,
416 prev_p->current->state_since, timestamp,
418 if (p && p->current) {
419 if (p->current->state != TYPE_NONE)
420 pid_put_sample(next_pid, p->current->state, cpu,
421 p->current->state_since, timestamp,
424 p->current->state_since = timestamp;
425 p->current->state = TYPE_RUNNING;
428 if (prev_p->current) {
429 prev_p->current->state = TYPE_NONE;
430 prev_p->current->state_since = timestamp;
432 prev_p->current->state = TYPE_BLOCKED;
434 prev_p->current->state = TYPE_WAITING;
438 static const char *cat_backtrace(union perf_event *event,
439 struct perf_sample *sample,
440 struct machine *machine)
442 struct addr_location al;
446 u8 cpumode = PERF_RECORD_MISC_USER;
447 struct addr_location tal;
448 struct ip_callchain *chain = sample->callchain;
449 FILE *f = open_memstream(&p, &p_len);
452 perror("open_memstream error");
459 if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
460 fprintf(stderr, "problem processing %d event, skipping it.\n",
465 for (i = 0; i < chain->nr; i++) {
468 if (callchain_param.order == ORDER_CALLEE)
471 ip = chain->ips[chain->nr - i - 1];
473 if (ip >= PERF_CONTEXT_MAX) {
475 case PERF_CONTEXT_HV:
476 cpumode = PERF_RECORD_MISC_HYPERVISOR;
478 case PERF_CONTEXT_KERNEL:
479 cpumode = PERF_RECORD_MISC_KERNEL;
481 case PERF_CONTEXT_USER:
482 cpumode = PERF_RECORD_MISC_USER;
485 pr_debug("invalid callchain context: "
486 "%"PRId64"\n", (s64) ip);
489 * It seems the callchain is corrupted.
499 tal.filtered = false;
500 thread__find_addr_location(al.thread, machine, cpumode,
501 MAP__FUNCTION, ip, &tal);
504 fprintf(f, "..... %016" PRIx64 " %s\n", ip,
507 fprintf(f, "..... %016" PRIx64 "\n", ip);
516 typedef int (*tracepoint_handler)(struct perf_evsel *evsel,
517 struct perf_sample *sample,
518 const char *backtrace);
520 static int process_sample_event(struct perf_tool *tool __maybe_unused,
521 union perf_event *event __maybe_unused,
522 struct perf_sample *sample,
523 struct perf_evsel *evsel,
524 struct machine *machine __maybe_unused)
526 if (evsel->attr.sample_type & PERF_SAMPLE_TIME) {
527 if (!first_time || first_time > sample->time)
528 first_time = sample->time;
529 if (last_time < sample->time)
530 last_time = sample->time;
533 if (sample->cpu > numcpus)
534 numcpus = sample->cpu;
536 if (evsel->handler != NULL) {
537 tracepoint_handler f = evsel->handler;
538 return f(evsel, sample, cat_backtrace(event, sample, machine));
545 process_sample_cpu_idle(struct perf_evsel *evsel,
546 struct perf_sample *sample,
547 const char *backtrace __maybe_unused)
549 u32 state = perf_evsel__intval(evsel, sample, "state");
550 u32 cpu_id = perf_evsel__intval(evsel, sample, "cpu_id");
552 if (state == (u32)PWR_EVENT_EXIT)
553 c_state_end(cpu_id, sample->time);
555 c_state_start(cpu_id, sample->time, state);
560 process_sample_cpu_frequency(struct perf_evsel *evsel,
561 struct perf_sample *sample,
562 const char *backtrace __maybe_unused)
564 u32 state = perf_evsel__intval(evsel, sample, "state");
565 u32 cpu_id = perf_evsel__intval(evsel, sample, "cpu_id");
567 p_state_change(cpu_id, sample->time, state);
572 process_sample_sched_wakeup(struct perf_evsel *evsel,
573 struct perf_sample *sample,
574 const char *backtrace)
576 u8 flags = perf_evsel__intval(evsel, sample, "common_flags");
577 int waker = perf_evsel__intval(evsel, sample, "common_pid");
578 int wakee = perf_evsel__intval(evsel, sample, "pid");
580 sched_wakeup(sample->cpu, sample->time, waker, wakee, flags, backtrace);
585 process_sample_sched_switch(struct perf_evsel *evsel,
586 struct perf_sample *sample,
587 const char *backtrace)
589 int prev_pid = perf_evsel__intval(evsel, sample, "prev_pid");
590 int next_pid = perf_evsel__intval(evsel, sample, "next_pid");
591 u64 prev_state = perf_evsel__intval(evsel, sample, "prev_state");
593 sched_switch(sample->cpu, sample->time, prev_pid, next_pid, prev_state,
598 #ifdef SUPPORT_OLD_POWER_EVENTS
600 process_sample_power_start(struct perf_evsel *evsel,
601 struct perf_sample *sample,
602 const char *backtrace __maybe_unused)
604 u64 cpu_id = perf_evsel__intval(evsel, sample, "cpu_id");
605 u64 value = perf_evsel__intval(evsel, sample, "value");
607 c_state_start(cpu_id, sample->time, value);
612 process_sample_power_end(struct perf_evsel *evsel __maybe_unused,
613 struct perf_sample *sample,
614 const char *backtrace __maybe_unused)
616 c_state_end(sample->cpu, sample->time);
621 process_sample_power_frequency(struct perf_evsel *evsel,
622 struct perf_sample *sample,
623 const char *backtrace __maybe_unused)
625 u64 cpu_id = perf_evsel__intval(evsel, sample, "cpu_id");
626 u64 value = perf_evsel__intval(evsel, sample, "value");
628 p_state_change(cpu_id, sample->time, value);
631 #endif /* SUPPORT_OLD_POWER_EVENTS */
634 * After the last sample we need to wrap up the current C/P state
635 * and close out each CPU for these.
637 static void end_sample_processing(void)
640 struct power_event *pwr;
642 for (cpu = 0; cpu <= numcpus; cpu++) {
645 pwr = zalloc(sizeof(*pwr));
649 pwr->state = cpus_cstate_state[cpu];
650 pwr->start_time = cpus_cstate_start_times[cpu];
651 pwr->end_time = last_time;
654 pwr->next = power_events;
660 pwr = zalloc(sizeof(*pwr));
664 pwr->state = cpus_pstate_state[cpu];
665 pwr->start_time = cpus_pstate_start_times[cpu];
666 pwr->end_time = last_time;
669 pwr->next = power_events;
671 if (!pwr->start_time)
672 pwr->start_time = first_time;
674 pwr->state = min_freq;
680 * Sort the pid datastructure
682 static void sort_pids(void)
684 struct per_pid *new_list, *p, *cursor, *prev;
685 /* sort by ppid first, then by pid, lowest to highest */
694 if (new_list == NULL) {
702 if (cursor->ppid > p->ppid ||
703 (cursor->ppid == p->ppid && cursor->pid > p->pid)) {
704 /* must insert before */
706 p->next = prev->next;
719 cursor = cursor->next;
728 static void draw_c_p_states(void)
730 struct power_event *pwr;
734 * two pass drawing so that the P state bars are on top of the C state blocks
737 if (pwr->type == CSTATE)
738 svg_cstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state);
744 if (pwr->type == PSTATE) {
746 pwr->state = min_freq;
747 svg_pstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state);
753 static void draw_wakeups(void)
755 struct wake_event *we;
757 struct per_pidcomm *c;
761 int from = 0, to = 0;
762 char *task_from = NULL, *task_to = NULL;
764 /* locate the column of the waker and wakee */
767 if (p->pid == we->waker || p->pid == we->wakee) {
770 if (c->Y && c->start_time <= we->time && c->end_time >= we->time) {
771 if (p->pid == we->waker && !from) {
773 task_from = strdup(c->comm);
775 if (p->pid == we->wakee && !to) {
777 task_to = strdup(c->comm);
784 if (p->pid == we->waker && !from) {
786 task_from = strdup(c->comm);
788 if (p->pid == we->wakee && !to) {
790 task_to = strdup(c->comm);
799 task_from = malloc(40);
800 sprintf(task_from, "[%i]", we->waker);
803 task_to = malloc(40);
804 sprintf(task_to, "[%i]", we->wakee);
808 svg_interrupt(we->time, to, we->backtrace);
809 else if (from && to && abs(from - to) == 1)
810 svg_wakeline(we->time, from, to, we->backtrace);
812 svg_partial_wakeline(we->time, from, task_from, to,
813 task_to, we->backtrace);
821 static void draw_cpu_usage(void)
824 struct per_pidcomm *c;
825 struct cpu_sample *sample;
832 if (sample->type == TYPE_RUNNING)
833 svg_process(sample->cpu, sample->start_time, sample->end_time, "sample", c->comm);
835 sample = sample->next;
843 static void draw_process_bars(void)
846 struct per_pidcomm *c;
847 struct cpu_sample *sample;
862 svg_box(Y, c->start_time, c->end_time, "process");
865 if (sample->type == TYPE_RUNNING)
866 svg_running(Y, sample->cpu,
870 if (sample->type == TYPE_BLOCKED)
871 svg_blocked(Y, sample->cpu,
875 if (sample->type == TYPE_WAITING)
876 svg_waiting(Y, sample->cpu,
880 sample = sample->next;
885 if (c->total_time > 5000000000) /* 5 seconds */
886 sprintf(comm, "%s:%i (%2.2fs)", c->comm, p->pid, c->total_time / 1000000000.0);
888 sprintf(comm, "%s:%i (%3.1fms)", c->comm, p->pid, c->total_time / 1000000.0);
890 svg_text(Y, c->start_time, comm);
900 static void add_process_filter(const char *string)
902 int pid = strtoull(string, NULL, 10);
903 struct process_filter *filt = malloc(sizeof(*filt));
908 filt->name = strdup(string);
910 filt->next = process_filter;
912 process_filter = filt;
915 static int passes_filter(struct per_pid *p, struct per_pidcomm *c)
917 struct process_filter *filt;
921 filt = process_filter;
923 if (filt->pid && p->pid == filt->pid)
925 if (strcmp(filt->name, c->comm) == 0)
932 static int determine_display_tasks_filtered(void)
935 struct per_pidcomm *c;
941 if (p->start_time == 1)
942 p->start_time = first_time;
944 /* no exit marker, task kept running to the end */
945 if (p->end_time == 0)
946 p->end_time = last_time;
953 if (c->start_time == 1)
954 c->start_time = first_time;
956 if (passes_filter(p, c)) {
962 if (c->end_time == 0)
963 c->end_time = last_time;
972 static int determine_display_tasks(u64 threshold)
975 struct per_pidcomm *c;
979 return determine_display_tasks_filtered();
984 if (p->start_time == 1)
985 p->start_time = first_time;
987 /* no exit marker, task kept running to the end */
988 if (p->end_time == 0)
989 p->end_time = last_time;
990 if (p->total_time >= threshold)
998 if (c->start_time == 1)
999 c->start_time = first_time;
1001 if (c->total_time >= threshold) {
1006 if (c->end_time == 0)
1007 c->end_time = last_time;
1018 #define TIME_THRESH 10000000
1020 static void write_svg_file(const char *filename)
1024 int thresh = TIME_THRESH;
1031 /* We'd like to show at least proc_num tasks;
1032 * be less picky if we have fewer */
1034 count = determine_display_tasks(thresh);
1036 } while (!process_filter && thresh && count < proc_num);
1038 open_svg(filename, numcpus, count, first_time, last_time);
1043 for (i = 0; i < numcpus; i++)
1044 svg_cpu_box(i, max_freq, turbo_frequency);
1048 draw_process_bars();
1057 static int __cmd_timechart(const char *output_name)
1059 struct perf_tool perf_timechart = {
1060 .comm = process_comm_event,
1061 .fork = process_fork_event,
1062 .exit = process_exit_event,
1063 .sample = process_sample_event,
1064 .ordered_samples = true,
1066 const struct perf_evsel_str_handler power_tracepoints[] = {
1067 { "power:cpu_idle", process_sample_cpu_idle },
1068 { "power:cpu_frequency", process_sample_cpu_frequency },
1069 { "sched:sched_wakeup", process_sample_sched_wakeup },
1070 { "sched:sched_switch", process_sample_sched_switch },
1071 #ifdef SUPPORT_OLD_POWER_EVENTS
1072 { "power:power_start", process_sample_power_start },
1073 { "power:power_end", process_sample_power_end },
1074 { "power:power_frequency", process_sample_power_frequency },
1077 struct perf_data_file file = {
1079 .mode = PERF_DATA_MODE_READ,
1082 struct perf_session *session = perf_session__new(&file, false,
1086 if (session == NULL)
1089 if (!perf_session__has_traces(session, "timechart record"))
1092 if (perf_session__set_tracepoints_handlers(session,
1093 power_tracepoints)) {
1094 pr_err("Initializing session tracepoint handlers failed\n");
1098 ret = perf_session__process_events(session, &perf_timechart);
1102 end_sample_processing();
1106 write_svg_file(output_name);
1108 pr_info("Written %2.1f seconds of trace to %s.\n",
1109 (last_time - first_time) / 1000000000.0, output_name);
1111 perf_session__delete(session);
1115 static int __cmd_record(int argc, const char **argv)
1117 unsigned int rec_argc, i, j;
1118 const char **rec_argv;
1120 unsigned int record_elems;
1122 const char * const common_args[] = {
1123 "record", "-a", "-R", "-c", "1",
1125 unsigned int common_args_nr = ARRAY_SIZE(common_args);
1127 const char * const backtrace_args[] = {
1130 unsigned int backtrace_args_no = ARRAY_SIZE(backtrace_args);
1132 const char * const power_args[] = {
1133 "-e", "power:cpu_frequency",
1134 "-e", "power:cpu_idle",
1136 unsigned int power_args_nr = ARRAY_SIZE(power_args);
1138 const char * const old_power_args[] = {
1139 #ifdef SUPPORT_OLD_POWER_EVENTS
1140 "-e", "power:power_start",
1141 "-e", "power:power_end",
1142 "-e", "power:power_frequency",
1145 unsigned int old_power_args_nr = ARRAY_SIZE(old_power_args);
1147 const char * const tasks_args[] = {
1148 "-e", "sched:sched_wakeup",
1149 "-e", "sched:sched_switch",
1151 unsigned int tasks_args_nr = ARRAY_SIZE(tasks_args);
1153 #ifdef SUPPORT_OLD_POWER_EVENTS
1154 if (!is_valid_tracepoint("power:cpu_idle") &&
1155 is_valid_tracepoint("power:power_start")) {
1156 use_old_power_events = 1;
1159 old_power_args_nr = 0;
1168 old_power_args_nr = 0;
1171 if (!with_backtrace)
1172 backtrace_args_no = 0;
1174 record_elems = common_args_nr + tasks_args_nr +
1175 power_args_nr + old_power_args_nr + backtrace_args_no;
1177 rec_argc = record_elems + argc;
1178 rec_argv = calloc(rec_argc + 1, sizeof(char *));
1180 if (rec_argv == NULL)
1184 for (i = 0; i < common_args_nr; i++)
1185 *p++ = strdup(common_args[i]);
1187 for (i = 0; i < backtrace_args_no; i++)
1188 *p++ = strdup(backtrace_args[i]);
1190 for (i = 0; i < tasks_args_nr; i++)
1191 *p++ = strdup(tasks_args[i]);
1193 for (i = 0; i < power_args_nr; i++)
1194 *p++ = strdup(power_args[i]);
1196 for (i = 0; i < old_power_args_nr; i++)
1197 *p++ = strdup(old_power_args[i]);
1199 for (j = 1; j < (unsigned int)argc; j++)
1202 return cmd_record(rec_argc, rec_argv, NULL);
1206 parse_process(const struct option *opt __maybe_unused, const char *arg,
1207 int __maybe_unused unset)
1210 add_process_filter(arg);
1214 int cmd_timechart(int argc, const char **argv,
1215 const char *prefix __maybe_unused)
1217 const char *output_name = "output.svg";
1218 const struct option timechart_options[] = {
1219 OPT_STRING('i', "input", &input_name, "file", "input file name"),
1220 OPT_STRING('o', "output", &output_name, "file", "output file name"),
1221 OPT_INTEGER('w', "width", &svg_page_width, "page width"),
1222 OPT_BOOLEAN('P', "power-only", &power_only, "output power data only"),
1223 OPT_BOOLEAN('T', "tasks-only", &tasks_only,
1224 "output processes data only"),
1225 OPT_CALLBACK('p', "process", NULL, "process",
1226 "process selector. Pass a pid or process name.",
1228 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
1229 "Look for files with symbols relative to this directory"),
1230 OPT_INTEGER('n', "proc-num", &proc_num,
1231 "min. number of tasks to print"),
1234 const char * const timechart_usage[] = {
1235 "perf timechart [<options>] {record}",
1239 const struct option record_options[] = {
1240 OPT_BOOLEAN('P', "power-only", &power_only, "output power data only"),
1241 OPT_BOOLEAN('T', "tasks-only", &tasks_only,
1242 "output processes data only"),
1243 OPT_BOOLEAN('g', "callchain", &with_backtrace, "record callchain"),
1246 const char * const record_usage[] = {
1247 "perf timechart record [<options>]",
1250 argc = parse_options(argc, argv, timechart_options, timechart_usage,
1251 PARSE_OPT_STOP_AT_NON_OPTION);
1253 if (power_only && tasks_only) {
1254 pr_err("-P and -T options cannot be used at the same time.\n");
1260 if (argc && !strncmp(argv[0], "rec", 3)) {
1261 argc = parse_options(argc, argv, record_options, record_usage,
1262 PARSE_OPT_STOP_AT_NON_OPTION);
1264 if (power_only && tasks_only) {
1265 pr_err("-P and -T options cannot be used at the same time.\n");
1269 return __cmd_record(argc, argv);
1271 usage_with_options(timechart_usage, timechart_options);
1275 return __cmd_timechart(output_name);