Lines Matching refs:tchart
199 static struct per_pid *find_create_pid(struct timechart *tchart, int pid)
201 struct per_pid *cursor = tchart->all_data;
211 cursor->next = tchart->all_data;
212 tchart->all_data = cursor;
216 static void pid_set_comm(struct timechart *tchart, int pid, char *comm)
220 p = find_create_pid(tchart, pid);
242 static void pid_fork(struct timechart *tchart, int pid, int ppid, u64 timestamp)
245 p = find_create_pid(tchart, pid);
246 pp = find_create_pid(tchart, ppid);
249 pid_set_comm(tchart, pid, pp->current->comm);
258 static void pid_exit(struct timechart *tchart, int pid, u64 timestamp)
261 p = find_create_pid(tchart, pid);
267 static void pid_put_sample(struct timechart *tchart, int pid, int type,
275 p = find_create_pid(tchart, pid);
318 struct timechart *tchart = container_of(tool, struct timechart, tool);
319 pid_set_comm(tchart, event->comm.tid, event->comm.comm);
328 struct timechart *tchart = container_of(tool, struct timechart, tool);
329 pid_fork(tchart, event->fork.pid, event->fork.ppid, event->fork.time);
338 struct timechart *tchart = container_of(tool, struct timechart, tool);
339 pid_exit(tchart, event->fork.pid, event->fork.time);
353 static void c_state_end(struct timechart *tchart, int cpu, u64 timestamp)
365 pwr->next = tchart->power_events;
367 tchart->power_events = pwr;
370 static void p_state_change(struct timechart *tchart, int cpu, u64 timestamp, u64 new_freq)
386 pwr->next = tchart->power_events;
389 pwr->start_time = tchart->first_time;
391 tchart->power_events = pwr;
396 if ((u64)new_freq > tchart->max_freq)
397 tchart->max_freq = new_freq;
399 if (new_freq < tchart->min_freq || tchart->min_freq == 0)
400 tchart->min_freq = new_freq;
402 if (new_freq == tchart->max_freq - 1000)
403 tchart->turbo_frequency = tchart->max_freq;
406 static void sched_wakeup(struct timechart *tchart, int cpu, u64 timestamp,
423 we->next = tchart->wake_events;
424 tchart->wake_events = we;
425 p = find_create_pid(tchart, we->wakee);
432 pid_put_sample(tchart, p->pid, p->current->state, cpu,
439 static void sched_switch(struct timechart *tchart, int cpu, u64 timestamp,
445 prev_p = find_create_pid(tchart, prev_pid);
447 p = find_create_pid(tchart, next_pid);
450 pid_put_sample(tchart, prev_pid, TYPE_RUNNING, cpu,
455 pid_put_sample(tchart, next_pid, p->current->state, cpu,
547 typedef int (*tracepoint_handler)(struct timechart *tchart,
558 struct timechart *tchart = container_of(tool, struct timechart, tool);
561 if (!tchart->first_time || tchart->first_time > sample->time)
562 tchart->first_time = sample->time;
563 if (tchart->last_time < sample->time)
564 tchart->last_time = sample->time;
569 return f(tchart, evsel, sample,
577 process_sample_cpu_idle(struct timechart *tchart __maybe_unused,
586 c_state_end(tchart, cpu_id, sample->time);
593 process_sample_cpu_frequency(struct timechart *tchart,
601 p_state_change(tchart, cpu_id, sample->time, state);
606 process_sample_sched_wakeup(struct timechart *tchart,
615 sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, backtrace);
620 process_sample_sched_switch(struct timechart *tchart,
629 sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid,
636 process_sample_power_start(struct timechart *tchart __maybe_unused,
649 process_sample_power_end(struct timechart *tchart,
654 c_state_end(tchart, sample->cpu, sample->time);
659 process_sample_power_frequency(struct timechart *tchart,
667 p_state_change(tchart, cpu_id, sample->time, value);
676 static void end_sample_processing(struct timechart *tchart)
681 for (cpu = 0; cpu <= tchart->numcpus; cpu++) {
690 pwr->end_time = tchart->last_time;
693 pwr->next = tchart->power_events;
695 tchart->power_events = pwr;
705 pwr->end_time = tchart->last_time;
708 pwr->next = tchart->power_events;
711 pwr->start_time = tchart->first_time;
713 pwr->state = tchart->min_freq;
714 tchart->power_events = pwr;
718 static int pid_begin_io_sample(struct timechart *tchart, int pid, int type,
721 struct per_pid *p = find_create_pid(tchart, pid);
763 static int pid_end_io_sample(struct timechart *tchart, int pid, int type,
766 struct per_pid *p = find_create_pid(tchart, pid);
796 if (sample->end_time - sample->start_time < tchart->min_time)
797 sample->end_time = sample->start_time + tchart->min_time;
823 prev->end_time + tchart->merge_dist >= sample->start_time) {
836 tchart->io_events++;
842 process_enter_read(struct timechart *tchart,
847 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ,
852 process_exit_read(struct timechart *tchart,
857 return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ,
862 process_enter_write(struct timechart *tchart,
867 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE,
872 process_exit_write(struct timechart *tchart,
877 return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE,
882 process_enter_sync(struct timechart *tchart,
887 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC,
892 process_exit_sync(struct timechart *tchart,
897 return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC,
902 process_enter_tx(struct timechart *tchart,
907 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX,
912 process_exit_tx(struct timechart *tchart,
917 return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX,
922 process_enter_rx(struct timechart *tchart,
927 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX,
932 process_exit_rx(struct timechart *tchart,
937 return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX,
942 process_enter_poll(struct timechart *tchart,
947 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL,
952 process_exit_poll(struct timechart *tchart,
957 return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL,
964 static void sort_pids(struct timechart *tchart)
971 while (tchart->all_data) {
972 p = tchart->all_data;
973 tchart->all_data = p->next;
1006 tchart->all_data = new_list;
1010 static void draw_c_p_states(struct timechart *tchart)
1013 pwr = tchart->power_events;
1024 pwr = tchart->power_events;
1028 pwr->state = tchart->min_freq;
1035 static void draw_wakeups(struct timechart *tchart)
1041 we = tchart->wake_events;
1047 p = tchart->all_data;
1103 static void draw_cpu_usage(struct timechart *tchart)
1108 p = tchart->all_data;
1131 static void draw_io_bars(struct timechart *tchart)
1141 p = tchart->all_data;
1156 if (tchart->skip_eagain &&
1246 static void draw_process_bars(struct timechart *tchart)
1253 Y = 2 * tchart->numcpus + 2;
1255 p = tchart->all_data;
1335 static int determine_display_tasks_filtered(struct timechart *tchart)
1341 p = tchart->all_data;
1345 p->start_time = tchart->first_time;
1349 p->end_time = tchart->last_time;
1357 c->start_time = tchart->first_time;
1366 c->end_time = tchart->last_time;
1375 static int determine_display_tasks(struct timechart *tchart, u64 threshold)
1381 p = tchart->all_data;
1385 p->start_time = tchart->first_time;
1389 p->end_time = tchart->last_time;
1399 c->start_time = tchart->first_time;
1407 c->end_time = tchart->last_time;
1451 static void write_svg_file(struct timechart *tchart, const char *filename)
1455 int thresh = tchart->io_events ? BYTES_THRESH : TIME_THRESH;
1457 if (tchart->power_only)
1458 tchart->proc_num = 0;
1464 count = determine_display_tasks_filtered(tchart);
1465 else if (tchart->io_events)
1466 count = determine_display_io_tasks(tchart, thresh);
1468 count = determine_display_tasks(tchart, thresh);
1470 } while (!process_filter && thresh && count < tchart->proc_num);
1472 if (!tchart->proc_num)
1475 if (tchart->io_events) {
1476 open_svg(filename, 0, count, tchart->first_time, tchart->last_time);
1481 draw_io_bars(tchart);
1483 open_svg(filename, tchart->numcpus, count, tchart->first_time, tchart->last_time);
1489 for (i = 0; i < tchart->numcpus; i++)
1490 svg_cpu_box(i, tchart->max_freq, tchart->turbo_frequency);
1492 draw_cpu_usage(tchart);
1493 if (tchart->proc_num)
1494 draw_process_bars(tchart);
1495 if (!tchart->tasks_only)
1496 draw_c_p_states(tchart);
1497 if (tchart->proc_num)
1498 draw_wakeups(tchart);
1510 struct timechart *tchart = data;
1514 tchart->numcpus = ph->env.nr_cpus_avail;
1518 if (!tchart->topology)
1532 static int __cmd_timechart(struct timechart *tchart, const char *output_name)
1598 .force = tchart->force,
1602 &tchart->tool);
1612 tchart,
1628 end_sample_processing(tchart);
1630 sort_pids(tchart);
1632 write_svg_file(tchart, output_name);
1635 (tchart->last_time - tchart->first_time) / (double)NSEC_PER_SEC, output_name);
1776 static int timechart__record(struct timechart *tchart, int argc, const char **argv)
1824 if (tchart->power_only)
1827 if (tchart->tasks_only) {
1832 if (!tchart->with_backtrace)
1918 struct timechart tchart = {
1932 OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
1933 OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only, "output processes data only"),
1949 OPT_INTEGER('n', "proc-num", &tchart.proc_num,
1951 OPT_BOOLEAN('t', "topology", &tchart.topology,
1953 OPT_BOOLEAN(0, "io-skip-eagain", &tchart.skip_eagain,
1955 OPT_CALLBACK(0, "io-min-time", &tchart.min_time, "time",
1958 OPT_CALLBACK(0, "io-merge-dist", &tchart.merge_dist, "time",
1961 OPT_BOOLEAN('f', "force", &tchart.force, "don't complain, do it"),
1970 OPT_BOOLEAN('I', "io-only", &tchart.io_only,
1972 OPT_BOOLEAN('g', "callchain", &tchart.with_backtrace, "record callchain"),
1982 if (tchart.power_only && tchart.tasks_only) {
1992 if (tchart.power_only && tchart.tasks_only) {
1997 if (tchart.io_only)
2000 return timechart__record(&tchart, argc, argv);
2006 return __cmd_timechart(&tchart, output_name);