Lines Matching refs:tchart

201 static struct per_pid *find_create_pid(struct timechart *tchart, int pid)  in find_create_pid()  argument
203 struct per_pid *cursor = tchart->all_data; in find_create_pid()
213 cursor->next = tchart->all_data; in find_create_pid()
214 tchart->all_data = cursor; in find_create_pid()
231 static void pid_set_comm(struct timechart *tchart, int pid, char *comm) in pid_set_comm() argument
235 p = find_create_pid(tchart, pid); in pid_set_comm()
254 static void pid_fork(struct timechart *tchart, int pid, int ppid, u64 timestamp) in pid_fork() argument
257 p = find_create_pid(tchart, pid); in pid_fork()
258 pp = find_create_pid(tchart, ppid); in pid_fork()
261 pid_set_comm(tchart, pid, pp->current->comm); in pid_fork()
270 static void pid_exit(struct timechart *tchart, int pid, u64 timestamp) in pid_exit() argument
273 p = find_create_pid(tchart, pid); in pid_exit()
279 static void pid_put_sample(struct timechart *tchart, int pid, int type, in pid_put_sample() argument
287 p = find_create_pid(tchart, pid); in pid_put_sample()
327 struct timechart *tchart = container_of(tool, struct timechart, tool); in process_comm_event() local
328 pid_set_comm(tchart, event->comm.tid, event->comm.comm); in process_comm_event()
337 struct timechart *tchart = container_of(tool, struct timechart, tool); in process_fork_event() local
338 pid_fork(tchart, event->fork.pid, event->fork.ppid, event->fork.time); in process_fork_event()
347 struct timechart *tchart = container_of(tool, struct timechart, tool); in process_exit_event() local
348 pid_exit(tchart, event->fork.pid, event->fork.time); in process_exit_event()
362 static void c_state_end(struct timechart *tchart, int cpu, u64 timestamp) in c_state_end() argument
374 pwr->next = tchart->power_events; in c_state_end()
376 tchart->power_events = pwr; in c_state_end()
379 static struct power_event *p_state_end(struct timechart *tchart, int cpu, in p_state_end() argument
392 pwr->next = tchart->power_events; in p_state_end()
394 pwr->start_time = tchart->first_time; in p_state_end()
396 tchart->power_events = pwr; in p_state_end()
400 static void p_state_change(struct timechart *tchart, int cpu, u64 timestamp, u64 new_freq) in p_state_change() argument
407 pwr = p_state_end(tchart, cpu, timestamp); in p_state_change()
414 if ((u64)new_freq > tchart->max_freq) in p_state_change()
415 tchart->max_freq = new_freq; in p_state_change()
417 if (new_freq < tchart->min_freq || tchart->min_freq == 0) in p_state_change()
418 tchart->min_freq = new_freq; in p_state_change()
420 if (new_freq == tchart->max_freq - 1000) in p_state_change()
421 tchart->turbo_frequency = tchart->max_freq; in p_state_change()
424 static void sched_wakeup(struct timechart *tchart, int cpu, u64 timestamp, in sched_wakeup() argument
441 we->next = tchart->wake_events; in sched_wakeup()
442 tchart->wake_events = we; in sched_wakeup()
443 p = find_create_pid(tchart, we->wakee); in sched_wakeup()
450 pid_put_sample(tchart, p->pid, p->current->state, cpu, in sched_wakeup()
457 static void sched_switch(struct timechart *tchart, int cpu, u64 timestamp, in sched_switch() argument
463 prev_p = find_create_pid(tchart, prev_pid); in sched_switch()
465 p = find_create_pid(tchart, next_pid); in sched_switch()
468 pid_put_sample(tchart, prev_pid, TYPE_RUNNING, cpu, in sched_switch()
473 pid_put_sample(tchart, next_pid, p->current->state, cpu, in sched_switch()
565 typedef int (*tracepoint_handler)(struct timechart *tchart,
576 struct timechart *tchart = container_of(tool, struct timechart, tool); in process_sample_event() local
579 if (!tchart->first_time || tchart->first_time > sample->time) in process_sample_event()
580 tchart->first_time = sample->time; in process_sample_event()
581 if (tchart->last_time < sample->time) in process_sample_event()
582 tchart->last_time = sample->time; in process_sample_event()
587 return f(tchart, evsel, sample, in process_sample_event()
595 process_sample_cpu_idle(struct timechart *tchart __maybe_unused, in process_sample_cpu_idle()
604 c_state_end(tchart, cpu_id, sample->time); in process_sample_cpu_idle()
611 process_sample_cpu_frequency(struct timechart *tchart, in process_sample_cpu_frequency() argument
619 p_state_change(tchart, cpu_id, sample->time, state); in process_sample_cpu_frequency()
624 process_sample_sched_wakeup(struct timechart *tchart, in process_sample_sched_wakeup() argument
633 sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, backtrace); in process_sample_sched_wakeup()
638 process_sample_sched_switch(struct timechart *tchart, in process_sample_sched_switch() argument
647 sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid, in process_sample_sched_switch()
654 process_sample_power_start(struct timechart *tchart __maybe_unused, in process_sample_power_start()
667 process_sample_power_end(struct timechart *tchart, in process_sample_power_end() argument
672 c_state_end(tchart, sample->cpu, sample->time); in process_sample_power_end()
677 process_sample_power_frequency(struct timechart *tchart, in process_sample_power_frequency() argument
685 p_state_change(tchart, cpu_id, sample->time, value); in process_sample_power_frequency()
694 static void end_sample_processing(struct timechart *tchart) in end_sample_processing() argument
699 for (cpu = 0; cpu <= tchart->numcpus; cpu++) { in end_sample_processing()
708 pwr->end_time = tchart->last_time; in end_sample_processing()
711 pwr->next = tchart->power_events; in end_sample_processing()
713 tchart->power_events = pwr; in end_sample_processing()
717 pwr = p_state_end(tchart, cpu, tchart->last_time); in end_sample_processing()
722 pwr->state = tchart->min_freq; in end_sample_processing()
726 static int pid_begin_io_sample(struct timechart *tchart, int pid, int type, in pid_begin_io_sample() argument
729 struct per_pid *p = find_create_pid(tchart, pid); in pid_begin_io_sample()
768 static int pid_end_io_sample(struct timechart *tchart, int pid, int type, in pid_end_io_sample() argument
771 struct per_pid *p = find_create_pid(tchart, pid); in pid_end_io_sample()
801 if (sample->end_time - sample->start_time < tchart->min_time) in pid_end_io_sample()
802 sample->end_time = sample->start_time + tchart->min_time; in pid_end_io_sample()
828 prev->end_time + tchart->merge_dist >= sample->start_time) { in pid_end_io_sample()
841 tchart->io_events++; in pid_end_io_sample()
847 process_enter_read(struct timechart *tchart, in process_enter_read() argument
852 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ, in process_enter_read()
857 process_exit_read(struct timechart *tchart, in process_exit_read() argument
862 return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ, in process_exit_read()
867 process_enter_write(struct timechart *tchart, in process_enter_write() argument
872 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE, in process_enter_write()
877 process_exit_write(struct timechart *tchart, in process_exit_write() argument
882 return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE, in process_exit_write()
887 process_enter_sync(struct timechart *tchart, in process_enter_sync() argument
892 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC, in process_enter_sync()
897 process_exit_sync(struct timechart *tchart, in process_exit_sync() argument
902 return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC, in process_exit_sync()
907 process_enter_tx(struct timechart *tchart, in process_enter_tx() argument
912 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX, in process_enter_tx()
917 process_exit_tx(struct timechart *tchart, in process_exit_tx() argument
922 return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX, in process_exit_tx()
927 process_enter_rx(struct timechart *tchart, in process_enter_rx() argument
932 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX, in process_enter_rx()
937 process_exit_rx(struct timechart *tchart, in process_exit_rx() argument
942 return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX, in process_exit_rx()
947 process_enter_poll(struct timechart *tchart, in process_enter_poll() argument
952 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL, in process_enter_poll()
957 process_exit_poll(struct timechart *tchart, in process_exit_poll() argument
962 return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL, in process_exit_poll()
969 static void sort_pids(struct timechart *tchart) in sort_pids() argument
976 while (tchart->all_data) { in sort_pids()
977 p = tchart->all_data; in sort_pids()
978 tchart->all_data = p->next; in sort_pids()
1011 tchart->all_data = new_list; in sort_pids()
1015 static void draw_c_p_states(struct timechart *tchart) in draw_c_p_states() argument
1018 pwr = tchart->power_events; in draw_c_p_states()
1029 pwr = tchart->power_events; in draw_c_p_states()
1033 pwr->state = tchart->min_freq; in draw_c_p_states()
1040 static void draw_wakeups(struct timechart *tchart) in draw_wakeups() argument
1046 we = tchart->wake_events; in draw_wakeups()
1052 p = tchart->all_data; in draw_wakeups()
1108 static void draw_cpu_usage(struct timechart *tchart) in draw_cpu_usage() argument
1113 p = tchart->all_data; in draw_cpu_usage()
1136 static void draw_io_bars(struct timechart *tchart) in draw_io_bars() argument
1146 p = tchart->all_data; in draw_io_bars()
1161 if (tchart->skip_eagain && in draw_io_bars()
1251 static void draw_process_bars(struct timechart *tchart) in draw_process_bars() argument
1258 Y = 2 * tchart->numcpus + 2; in draw_process_bars()
1260 p = tchart->all_data; in draw_process_bars()
1340 static int determine_display_tasks_filtered(struct timechart *tchart) in determine_display_tasks_filtered() argument
1346 p = tchart->all_data; in determine_display_tasks_filtered()
1350 p->start_time = tchart->first_time; in determine_display_tasks_filtered()
1354 p->end_time = tchart->last_time; in determine_display_tasks_filtered()
1362 c->start_time = tchart->first_time; in determine_display_tasks_filtered()
1371 c->end_time = tchart->last_time; in determine_display_tasks_filtered()
1380 static int determine_display_tasks(struct timechart *tchart, u64 threshold) in determine_display_tasks() argument
1386 p = tchart->all_data; in determine_display_tasks()
1390 p->start_time = tchart->first_time; in determine_display_tasks()
1394 p->end_time = tchart->last_time; in determine_display_tasks()
1404 c->start_time = tchart->first_time; in determine_display_tasks()
1412 c->end_time = tchart->last_time; in determine_display_tasks()
1456 static void write_svg_file(struct timechart *tchart, const char *filename) in write_svg_file() argument
1460 int thresh = tchart->io_events ? BYTES_THRESH : TIME_THRESH; in write_svg_file()
1462 if (tchart->power_only) in write_svg_file()
1463 tchart->proc_num = 0; in write_svg_file()
1469 count = determine_display_tasks_filtered(tchart); in write_svg_file()
1470 else if (tchart->io_events) in write_svg_file()
1471 count = determine_display_io_tasks(tchart, thresh); in write_svg_file()
1473 count = determine_display_tasks(tchart, thresh); in write_svg_file()
1475 } while (!process_filter && thresh && count < tchart->proc_num); in write_svg_file()
1477 if (!tchart->proc_num) in write_svg_file()
1480 if (tchart->io_events) { in write_svg_file()
1481 open_svg(filename, 0, count, tchart->first_time, tchart->last_time); in write_svg_file()
1486 draw_io_bars(tchart); in write_svg_file()
1488 open_svg(filename, tchart->numcpus, count, tchart->first_time, tchart->last_time); in write_svg_file()
1494 for (i = 0; i < tchart->numcpus; i++) in write_svg_file()
1495 svg_cpu_box(i, tchart->max_freq, tchart->turbo_frequency); in write_svg_file()
1497 draw_cpu_usage(tchart); in write_svg_file()
1498 if (tchart->proc_num) in write_svg_file()
1499 draw_process_bars(tchart); in write_svg_file()
1500 if (!tchart->tasks_only) in write_svg_file()
1501 draw_c_p_states(tchart); in write_svg_file()
1502 if (tchart->proc_num) in write_svg_file()
1503 draw_wakeups(tchart); in write_svg_file()
1515 struct timechart *tchart = data; in process_header() local
1519 tchart->numcpus = ph->env.nr_cpus_avail; in process_header()
1523 if (!tchart->topology) in process_header()
1537 static int __cmd_timechart(struct timechart *tchart, const char *output_name) in __cmd_timechart() argument
1603 .force = tchart->force, in __cmd_timechart()
1606 struct perf_session *session = perf_session__new(&data, &tchart->tool); in __cmd_timechart()
1616 tchart, in __cmd_timechart()
1632 end_sample_processing(tchart); in __cmd_timechart()
1634 sort_pids(tchart); in __cmd_timechart()
1636 write_svg_file(tchart, output_name); in __cmd_timechart()
1639 (tchart->last_time - tchart->first_time) / (double)NSEC_PER_SEC, output_name); in __cmd_timechart()
1780 static int timechart__record(struct timechart *tchart, int argc, const char **argv) in timechart__record() argument
1828 if (tchart->power_only) in timechart__record()
1831 if (tchart->tasks_only) { in timechart__record()
1836 if (!tchart->with_backtrace) in timechart__record()
1922 struct timechart tchart = { in cmd_timechart() local
1936 OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"), in cmd_timechart()
1937 OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only, "output processes data only"), in cmd_timechart()
1953 OPT_INTEGER('n', "proc-num", &tchart.proc_num, in cmd_timechart()
1955 OPT_BOOLEAN('t', "topology", &tchart.topology, in cmd_timechart()
1957 OPT_BOOLEAN(0, "io-skip-eagain", &tchart.skip_eagain, in cmd_timechart()
1959 OPT_CALLBACK(0, "io-min-time", &tchart.min_time, "time", in cmd_timechart()
1962 OPT_CALLBACK(0, "io-merge-dist", &tchart.merge_dist, "time", in cmd_timechart()
1965 OPT_BOOLEAN('f', "force", &tchart.force, "don't complain, do it"), in cmd_timechart()
1974 OPT_BOOLEAN('I', "io-only", &tchart.io_only, in cmd_timechart()
1976 OPT_BOOLEAN('g', "callchain", &tchart.with_backtrace, "record callchain"), in cmd_timechart()
1986 if (tchart.power_only && tchart.tasks_only) { in cmd_timechart()
1996 if (tchart.power_only && tchart.tasks_only) { in cmd_timechart()
2001 if (tchart.io_only) in cmd_timechart()
2004 return timechart__record(&tchart, argc, argv); in cmd_timechart()
2010 return __cmd_timechart(&tchart, output_name); in cmd_timechart()