Lines Matching +full:min +full:- +full:sample +full:- +full:time

1 // SPDX-License-Identifier: GPL-2.0-only
3 * builtin-timechart.c - make an svg timechart of system activity
30 #include <subcmd/parse-options.h>
31 #include "util/parse-events.h"
45 #define PWR_EVENT_EXIT -1
186 u64 time; member
201 struct per_pid *cursor = tchart->all_data; in find_create_pid()
204 if (cursor->pid == pid) in find_create_pid()
206 cursor = cursor->next; in find_create_pid()
210 cursor->pid = pid; in find_create_pid()
211 cursor->next = tchart->all_data; in find_create_pid()
212 tchart->all_data = cursor; in find_create_pid()
221 c = p->all; in pid_set_comm()
223 if (c->comm && strcmp(c->comm, comm) == 0) { in pid_set_comm()
224 p->current = c; in pid_set_comm()
227 if (!c->comm) { in pid_set_comm()
228 c->comm = strdup(comm); in pid_set_comm()
229 p->current = c; in pid_set_comm()
232 c = c->next; in pid_set_comm()
236 c->comm = strdup(comm); in pid_set_comm()
237 p->current = c; in pid_set_comm()
238 c->next = p->all; in pid_set_comm()
239 p->all = c; in pid_set_comm()
247 p->ppid = ppid; in pid_fork()
248 if (pp->current && pp->current->comm && !p->current) in pid_fork()
249 pid_set_comm(tchart, pid, pp->current->comm); in pid_fork()
251 p->start_time = timestamp; in pid_fork()
252 if (p->current && !p->current->start_time) { in pid_fork()
253 p->current->start_time = timestamp; in pid_fork()
254 p->current->state_since = timestamp; in pid_fork()
262 p->end_time = timestamp; in pid_exit()
263 if (p->current) in pid_exit()
264 p->current->end_time = timestamp; in pid_exit()
273 struct cpu_sample *sample; in pid_put_sample() local
276 c = p->current; in pid_put_sample()
280 p->current = c; in pid_put_sample()
281 c->next = p->all; in pid_put_sample()
282 p->all = c; in pid_put_sample()
285 sample = zalloc(sizeof(*sample)); in pid_put_sample()
286 assert(sample != NULL); in pid_put_sample()
287 sample->start_time = start; in pid_put_sample()
288 sample->end_time = end; in pid_put_sample()
289 sample->type = type; in pid_put_sample()
290 sample->next = c->samples; in pid_put_sample()
291 sample->cpu = cpu; in pid_put_sample()
292 sample->backtrace = backtrace; in pid_put_sample()
293 c->samples = sample; in pid_put_sample()
295 if (sample->type == TYPE_RUNNING && end > start && start > 0) { in pid_put_sample()
296 c->total_time += (end-start); in pid_put_sample()
297 p->total_time += (end-start); in pid_put_sample()
300 if (c->start_time == 0 || c->start_time > start) in pid_put_sample()
301 c->start_time = start; in pid_put_sample()
302 if (p->start_time == 0 || p->start_time > start) in pid_put_sample()
303 p->start_time = start; in pid_put_sample()
315 struct perf_sample *sample __maybe_unused, in process_comm_event()
319 pid_set_comm(tchart, event->comm.tid, event->comm.comm); in process_comm_event()
325 struct perf_sample *sample __maybe_unused, in process_fork_event()
329 pid_fork(tchart, event->fork.pid, event->fork.ppid, event->fork.time); in process_fork_event()
335 struct perf_sample *sample __maybe_unused, in process_exit_event()
339 pid_exit(tchart, event->fork.pid, event->fork.time); in process_exit_event()
360 pwr->state = cpus_cstate_state[cpu]; in c_state_end()
361 pwr->start_time = cpus_cstate_start_times[cpu]; in c_state_end()
362 pwr->end_time = timestamp; in c_state_end()
363 pwr->cpu = cpu; in c_state_end()
364 pwr->type = CSTATE; in c_state_end()
365 pwr->next = tchart->power_events; in c_state_end()
367 tchart->power_events = pwr; in c_state_end()
381 pwr->state = cpus_pstate_state[cpu]; in p_state_change()
382 pwr->start_time = cpus_pstate_start_times[cpu]; in p_state_change()
383 pwr->end_time = timestamp; in p_state_change()
384 pwr->cpu = cpu; in p_state_change()
385 pwr->type = PSTATE; in p_state_change()
386 pwr->next = tchart->power_events; in p_state_change()
388 if (!pwr->start_time) in p_state_change()
389 pwr->start_time = tchart->first_time; in p_state_change()
391 tchart->power_events = pwr; in p_state_change()
396 if ((u64)new_freq > tchart->max_freq) in p_state_change()
397 tchart->max_freq = new_freq; in p_state_change()
399 if (new_freq < tchart->min_freq || tchart->min_freq == 0) in p_state_change()
400 tchart->min_freq = new_freq; in p_state_change()
402 if (new_freq == tchart->max_freq - 1000) in p_state_change()
403 tchart->turbo_frequency = tchart->max_freq; in p_state_change()
415 we->time = timestamp; in sched_wakeup()
416 we->waker = waker; in sched_wakeup()
417 we->backtrace = backtrace; in sched_wakeup()
420 we->waker = -1; in sched_wakeup()
422 we->wakee = wakee; in sched_wakeup()
423 we->next = tchart->wake_events; in sched_wakeup()
424 tchart->wake_events = we; in sched_wakeup()
425 p = find_create_pid(tchart, we->wakee); in sched_wakeup()
427 if (p && p->current && p->current->state == TYPE_NONE) { in sched_wakeup()
428 p->current->state_since = timestamp; in sched_wakeup()
429 p->current->state = TYPE_WAITING; in sched_wakeup()
431 if (p && p->current && p->current->state == TYPE_BLOCKED) { in sched_wakeup()
432 pid_put_sample(tchart, p->pid, p->current->state, cpu, in sched_wakeup()
433 p->current->state_since, timestamp, NULL); in sched_wakeup()
434 p->current->state_since = timestamp; in sched_wakeup()
435 p->current->state = TYPE_WAITING; in sched_wakeup()
449 if (prev_p->current && prev_p->current->state != TYPE_NONE) in sched_switch()
451 prev_p->current->state_since, timestamp, in sched_switch()
453 if (p && p->current) { in sched_switch()
454 if (p->current->state != TYPE_NONE) in sched_switch()
455 pid_put_sample(tchart, next_pid, p->current->state, cpu, in sched_switch()
456 p->current->state_since, timestamp, in sched_switch()
459 p->current->state_since = timestamp; in sched_switch()
460 p->current->state = TYPE_RUNNING; in sched_switch()
463 if (prev_p->current) { in sched_switch()
464 prev_p->current->state = TYPE_NONE; in sched_switch()
465 prev_p->current->state_since = timestamp; in sched_switch()
467 prev_p->current->state = TYPE_BLOCKED; in sched_switch()
469 prev_p->current->state = TYPE_WAITING; in sched_switch()
474 struct perf_sample *sample, in cat_backtrace() argument
483 struct ip_callchain *chain = sample->callchain; in cat_backtrace()
494 if (machine__resolve(machine, &al, sample) < 0) { in cat_backtrace()
496 event->header.type); in cat_backtrace()
500 for (i = 0; i < chain->nr; i++) { in cat_backtrace()
504 ip = chain->ips[i]; in cat_backtrace()
506 ip = chain->ips[chain->nr - i - 1]; in cat_backtrace()
535 fprintf(f, "..... %016" PRIx64 " %s\n", ip, tal.sym->name); in cat_backtrace()
549 struct perf_sample *sample,
554 struct perf_sample *sample, in process_sample_event() argument
560 if (evsel->core.attr.sample_type & PERF_SAMPLE_TIME) { in process_sample_event()
561 if (!tchart->first_time || tchart->first_time > sample->time) in process_sample_event()
562 tchart->first_time = sample->time; in process_sample_event()
563 if (tchart->last_time < sample->time) in process_sample_event()
564 tchart->last_time = sample->time; in process_sample_event()
567 if (evsel->handler != NULL) { in process_sample_event()
568 tracepoint_handler f = evsel->handler; in process_sample_event()
569 return f(tchart, evsel, sample, in process_sample_event()
570 cat_backtrace(event, sample, machine)); in process_sample_event()
579 struct perf_sample *sample, in process_sample_cpu_idle() argument
582 u32 state = evsel__intval(evsel, sample, "state"); in process_sample_cpu_idle()
583 u32 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_cpu_idle()
586 c_state_end(tchart, cpu_id, sample->time); in process_sample_cpu_idle()
588 c_state_start(cpu_id, sample->time, state); in process_sample_cpu_idle()
595 struct perf_sample *sample, in process_sample_cpu_frequency() argument
598 u32 state = evsel__intval(evsel, sample, "state"); in process_sample_cpu_frequency()
599 u32 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_cpu_frequency()
601 p_state_change(tchart, cpu_id, sample->time, state); in process_sample_cpu_frequency()
608 struct perf_sample *sample, in process_sample_sched_wakeup() argument
611 u8 flags = evsel__intval(evsel, sample, "common_flags"); in process_sample_sched_wakeup()
612 int waker = evsel__intval(evsel, sample, "common_pid"); in process_sample_sched_wakeup()
613 int wakee = evsel__intval(evsel, sample, "pid"); in process_sample_sched_wakeup()
615 sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, backtrace); in process_sample_sched_wakeup()
622 struct perf_sample *sample, in process_sample_sched_switch() argument
625 int prev_pid = evsel__intval(evsel, sample, "prev_pid"); in process_sample_sched_switch()
626 int next_pid = evsel__intval(evsel, sample, "next_pid"); in process_sample_sched_switch()
627 u64 prev_state = evsel__intval(evsel, sample, "prev_state"); in process_sample_sched_switch()
629 sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid, in process_sample_sched_switch()
638 struct perf_sample *sample, in process_sample_power_start() argument
641 u64 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_power_start()
642 u64 value = evsel__intval(evsel, sample, "value"); in process_sample_power_start()
644 c_state_start(cpu_id, sample->time, value); in process_sample_power_start()
651 struct perf_sample *sample, in process_sample_power_end() argument
654 c_state_end(tchart, sample->cpu, sample->time); in process_sample_power_end()
661 struct perf_sample *sample, in process_sample_power_frequency() argument
664 u64 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_power_frequency()
665 u64 value = evsel__intval(evsel, sample, "value"); in process_sample_power_frequency()
667 p_state_change(tchart, cpu_id, sample->time, value); in process_sample_power_frequency()
673 * After the last sample we need to wrap up the current C/P state
681 for (cpu = 0; cpu <= tchart->numcpus; cpu++) { in end_sample_processing()
688 pwr->state = cpus_cstate_state[cpu]; in end_sample_processing()
689 pwr->start_time = cpus_cstate_start_times[cpu]; in end_sample_processing()
690 pwr->end_time = tchart->last_time; in end_sample_processing()
691 pwr->cpu = cpu; in end_sample_processing()
692 pwr->type = CSTATE; in end_sample_processing()
693 pwr->next = tchart->power_events; in end_sample_processing()
695 tchart->power_events = pwr; in end_sample_processing()
703 pwr->state = cpus_pstate_state[cpu]; in end_sample_processing()
704 pwr->start_time = cpus_pstate_start_times[cpu]; in end_sample_processing()
705 pwr->end_time = tchart->last_time; in end_sample_processing()
706 pwr->cpu = cpu; in end_sample_processing()
707 pwr->type = PSTATE; in end_sample_processing()
708 pwr->next = tchart->power_events; in end_sample_processing()
710 if (!pwr->start_time) in end_sample_processing()
711 pwr->start_time = tchart->first_time; in end_sample_processing()
712 if (!pwr->state) in end_sample_processing()
713 pwr->state = tchart->min_freq; in end_sample_processing()
714 tchart->power_events = pwr; in end_sample_processing()
722 struct per_pidcomm *c = p->current; in pid_begin_io_sample()
723 struct io_sample *sample; in pid_begin_io_sample() local
729 return -ENOMEM; in pid_begin_io_sample()
730 p->current = c; in pid_begin_io_sample()
731 c->next = p->all; in pid_begin_io_sample()
732 p->all = c; in pid_begin_io_sample()
735 prev = c->io_samples; in pid_begin_io_sample()
737 if (prev && prev->start_time && !prev->end_time) { in pid_begin_io_sample()
743 c->io_samples = prev->next; in pid_begin_io_sample()
748 sample = zalloc(sizeof(*sample)); in pid_begin_io_sample()
749 if (!sample) in pid_begin_io_sample()
750 return -ENOMEM; in pid_begin_io_sample()
751 sample->start_time = start; in pid_begin_io_sample()
752 sample->type = type; in pid_begin_io_sample()
753 sample->fd = fd; in pid_begin_io_sample()
754 sample->next = c->io_samples; in pid_begin_io_sample()
755 c->io_samples = sample; in pid_begin_io_sample()
757 if (c->start_time == 0 || c->start_time > start) in pid_begin_io_sample()
758 c->start_time = start; in pid_begin_io_sample()
767 struct per_pidcomm *c = p->current; in pid_end_io_sample()
768 struct io_sample *sample, *prev; in pid_end_io_sample() local
772 return -1; in pid_end_io_sample()
775 sample = c->io_samples; in pid_end_io_sample()
777 if (!sample) /* skip partially captured events */ in pid_end_io_sample()
780 if (sample->end_time) { in pid_end_io_sample()
786 if (sample->type != type) { in pid_end_io_sample()
791 sample->end_time = end; in pid_end_io_sample()
792 prev = sample->next; in pid_end_io_sample()
796 if (sample->end_time - sample->start_time < tchart->min_time) in pid_end_io_sample()
797 sample->end_time = sample->start_time + tchart->min_time; in pid_end_io_sample()
798 if (prev && sample->start_time < prev->end_time) { in pid_end_io_sample()
799 if (prev->err) /* try to make errors more visible */ in pid_end_io_sample()
800 sample->start_time = prev->end_time; in pid_end_io_sample()
802 prev->end_time = sample->start_time; in pid_end_io_sample()
806 sample->err = ret; in pid_end_io_sample()
810 if ((u64)ret > c->max_bytes) in pid_end_io_sample()
811 c->max_bytes = ret; in pid_end_io_sample()
813 c->total_bytes += ret; in pid_end_io_sample()
814 p->total_bytes += ret; in pid_end_io_sample()
815 sample->bytes = ret; in pid_end_io_sample()
818 /* merge two requests to make svg smaller and render-friendly */ in pid_end_io_sample()
820 prev->type == sample->type && in pid_end_io_sample()
821 prev->err == sample->err && in pid_end_io_sample()
822 prev->fd == sample->fd && in pid_end_io_sample()
823 prev->end_time + tchart->merge_dist >= sample->start_time) { in pid_end_io_sample()
825 sample->bytes += prev->bytes; in pid_end_io_sample()
826 sample->merges += prev->merges + 1; in pid_end_io_sample()
828 sample->start_time = prev->start_time; in pid_end_io_sample()
829 sample->next = prev->next; in pid_end_io_sample()
832 if (!sample->err && sample->bytes > c->max_bytes) in pid_end_io_sample()
833 c->max_bytes = sample->bytes; in pid_end_io_sample()
836 tchart->io_events++; in pid_end_io_sample()
844 struct perf_sample *sample) in process_enter_read() argument
846 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_read()
847 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ, in process_enter_read()
848 sample->time, fd); in process_enter_read()
854 struct perf_sample *sample) in process_exit_read() argument
856 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_read()
857 return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ, in process_exit_read()
858 sample->time, ret); in process_exit_read()
864 struct perf_sample *sample) in process_enter_write() argument
866 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_write()
867 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE, in process_enter_write()
868 sample->time, fd); in process_enter_write()
874 struct perf_sample *sample) in process_exit_write() argument
876 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_write()
877 return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE, in process_exit_write()
878 sample->time, ret); in process_exit_write()
884 struct perf_sample *sample) in process_enter_sync() argument
886 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_sync()
887 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC, in process_enter_sync()
888 sample->time, fd); in process_enter_sync()
894 struct perf_sample *sample) in process_exit_sync() argument
896 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_sync()
897 return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC, in process_exit_sync()
898 sample->time, ret); in process_exit_sync()
904 struct perf_sample *sample) in process_enter_tx() argument
906 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_tx()
907 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX, in process_enter_tx()
908 sample->time, fd); in process_enter_tx()
914 struct perf_sample *sample) in process_exit_tx() argument
916 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_tx()
917 return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX, in process_exit_tx()
918 sample->time, ret); in process_exit_tx()
924 struct perf_sample *sample) in process_enter_rx() argument
926 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_rx()
927 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX, in process_enter_rx()
928 sample->time, fd); in process_enter_rx()
934 struct perf_sample *sample) in process_exit_rx() argument
936 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_rx()
937 return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX, in process_exit_rx()
938 sample->time, ret); in process_exit_rx()
944 struct perf_sample *sample) in process_enter_poll() argument
946 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_poll()
947 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL, in process_enter_poll()
948 sample->time, fd); in process_enter_poll()
954 struct perf_sample *sample) in process_exit_poll() argument
956 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_poll()
957 return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL, in process_exit_poll()
958 sample->time, ret); in process_exit_poll()
971 while (tchart->all_data) { in sort_pids()
972 p = tchart->all_data; in sort_pids()
973 tchart->all_data = p->next; in sort_pids()
974 p->next = NULL; in sort_pids()
978 p->next = NULL; in sort_pids()
984 if (cursor->ppid > p->ppid || in sort_pids()
985 (cursor->ppid == p->ppid && cursor->pid > p->pid)) { in sort_pids()
988 p->next = prev->next; in sort_pids()
989 prev->next = p; in sort_pids()
993 p->next = new_list; in sort_pids()
1001 cursor = cursor->next; in sort_pids()
1003 prev->next = p; in sort_pids()
1006 tchart->all_data = new_list; in sort_pids()
1013 pwr = tchart->power_events; in draw_c_p_states()
1019 if (pwr->type == CSTATE) in draw_c_p_states()
1020 svg_cstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state); in draw_c_p_states()
1021 pwr = pwr->next; in draw_c_p_states()
1024 pwr = tchart->power_events; in draw_c_p_states()
1026 if (pwr->type == PSTATE) { in draw_c_p_states()
1027 if (!pwr->state) in draw_c_p_states()
1028 pwr->state = tchart->min_freq; in draw_c_p_states()
1029 svg_pstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state); in draw_c_p_states()
1031 pwr = pwr->next; in draw_c_p_states()
1041 we = tchart->wake_events; in draw_wakeups()
1047 p = tchart->all_data; in draw_wakeups()
1049 if (p->pid == we->waker || p->pid == we->wakee) { in draw_wakeups()
1050 c = p->all; in draw_wakeups()
1052 if (c->Y && c->start_time <= we->time && c->end_time >= we->time) { in draw_wakeups()
1053 if (p->pid == we->waker && !from) { in draw_wakeups()
1054 from = c->Y; in draw_wakeups()
1055 task_from = strdup(c->comm); in draw_wakeups()
1057 if (p->pid == we->wakee && !to) { in draw_wakeups()
1058 to = c->Y; in draw_wakeups()
1059 task_to = strdup(c->comm); in draw_wakeups()
1062 c = c->next; in draw_wakeups()
1064 c = p->all; in draw_wakeups()
1066 if (p->pid == we->waker && !from) { in draw_wakeups()
1067 from = c->Y; in draw_wakeups()
1068 task_from = strdup(c->comm); in draw_wakeups()
1070 if (p->pid == we->wakee && !to) { in draw_wakeups()
1071 to = c->Y; in draw_wakeups()
1072 task_to = strdup(c->comm); in draw_wakeups()
1074 c = c->next; in draw_wakeups()
1077 p = p->next; in draw_wakeups()
1082 sprintf(task_from, "[%i]", we->waker); in draw_wakeups()
1086 sprintf(task_to, "[%i]", we->wakee); in draw_wakeups()
1089 if (we->waker == -1) in draw_wakeups()
1090 svg_interrupt(we->time, to, we->backtrace); in draw_wakeups()
1091 else if (from && to && abs(from - to) == 1) in draw_wakeups()
1092 svg_wakeline(we->time, from, to, we->backtrace); in draw_wakeups()
1094 svg_partial_wakeline(we->time, from, task_from, to, in draw_wakeups()
1095 task_to, we->backtrace); in draw_wakeups()
1096 we = we->next; in draw_wakeups()
1107 struct cpu_sample *sample; in draw_cpu_usage() local
1108 p = tchart->all_data; in draw_cpu_usage()
1110 c = p->all; in draw_cpu_usage()
1112 sample = c->samples; in draw_cpu_usage()
1113 while (sample) { in draw_cpu_usage()
1114 if (sample->type == TYPE_RUNNING) { in draw_cpu_usage()
1115 svg_process(sample->cpu, in draw_cpu_usage()
1116 sample->start_time, in draw_cpu_usage()
1117 sample->end_time, in draw_cpu_usage()
1118 p->pid, in draw_cpu_usage()
1119 c->comm, in draw_cpu_usage()
1120 sample->backtrace); in draw_cpu_usage()
1123 sample = sample->next; in draw_cpu_usage()
1125 c = c->next; in draw_cpu_usage()
1127 p = p->next; in draw_cpu_usage()
1138 struct io_sample *sample; in draw_io_bars() local
1141 p = tchart->all_data; in draw_io_bars()
1143 c = p->all; in draw_io_bars()
1145 if (!c->display) { in draw_io_bars()
1146 c->Y = 0; in draw_io_bars()
1147 c = c->next; in draw_io_bars()
1151 svg_box(Y, c->start_time, c->end_time, "process3"); in draw_io_bars()
1152 sample = c->io_samples; in draw_io_bars()
1153 for (sample = c->io_samples; sample; sample = sample->next) { in draw_io_bars()
1154 double h = (double)sample->bytes / c->max_bytes; in draw_io_bars()
1156 if (tchart->skip_eagain && in draw_io_bars()
1157 sample->err == -EAGAIN) in draw_io_bars()
1160 if (sample->err) in draw_io_bars()
1163 if (sample->type == IOTYPE_SYNC) in draw_io_bars()
1165 sample->start_time, in draw_io_bars()
1166 sample->end_time, in draw_io_bars()
1168 sample->err ? "error" : "sync", in draw_io_bars()
1169 sample->fd, in draw_io_bars()
1170 sample->err, in draw_io_bars()
1171 sample->merges); in draw_io_bars()
1172 else if (sample->type == IOTYPE_POLL) in draw_io_bars()
1174 sample->start_time, in draw_io_bars()
1175 sample->end_time, in draw_io_bars()
1177 sample->err ? "error" : "poll", in draw_io_bars()
1178 sample->fd, in draw_io_bars()
1179 sample->err, in draw_io_bars()
1180 sample->merges); in draw_io_bars()
1181 else if (sample->type == IOTYPE_READ) in draw_io_bars()
1183 sample->start_time, in draw_io_bars()
1184 sample->end_time, in draw_io_bars()
1186 sample->err ? "error" : "disk", in draw_io_bars()
1187 sample->fd, in draw_io_bars()
1188 sample->err, in draw_io_bars()
1189 sample->merges); in draw_io_bars()
1190 else if (sample->type == IOTYPE_WRITE) in draw_io_bars()
1192 sample->start_time, in draw_io_bars()
1193 sample->end_time, in draw_io_bars()
1195 sample->err ? "error" : "disk", in draw_io_bars()
1196 sample->fd, in draw_io_bars()
1197 sample->err, in draw_io_bars()
1198 sample->merges); in draw_io_bars()
1199 else if (sample->type == IOTYPE_RX) in draw_io_bars()
1201 sample->start_time, in draw_io_bars()
1202 sample->end_time, in draw_io_bars()
1204 sample->err ? "error" : "net", in draw_io_bars()
1205 sample->fd, in draw_io_bars()
1206 sample->err, in draw_io_bars()
1207 sample->merges); in draw_io_bars()
1208 else if (sample->type == IOTYPE_TX) in draw_io_bars()
1210 sample->start_time, in draw_io_bars()
1211 sample->end_time, in draw_io_bars()
1213 sample->err ? "error" : "net", in draw_io_bars()
1214 sample->fd, in draw_io_bars()
1215 sample->err, in draw_io_bars()
1216 sample->merges); in draw_io_bars()
1220 bytes = c->total_bytes; in draw_io_bars()
1235 sprintf(comm, "%s:%i (%3.1f %sbytes)", c->comm ?: "", p->pid, bytes, suf); in draw_io_bars()
1236 svg_text(Y, c->start_time, comm); in draw_io_bars()
1238 c->Y = Y; in draw_io_bars()
1240 c = c->next; in draw_io_bars()
1242 p = p->next; in draw_io_bars()
1250 struct cpu_sample *sample; in draw_process_bars() local
1253 Y = 2 * tchart->numcpus + 2; in draw_process_bars()
1255 p = tchart->all_data; in draw_process_bars()
1257 c = p->all; in draw_process_bars()
1259 if (!c->display) { in draw_process_bars()
1260 c->Y = 0; in draw_process_bars()
1261 c = c->next; in draw_process_bars()
1265 svg_box(Y, c->start_time, c->end_time, "process"); in draw_process_bars()
1266 sample = c->samples; in draw_process_bars()
1267 while (sample) { in draw_process_bars()
1268 if (sample->type == TYPE_RUNNING) in draw_process_bars()
1269 svg_running(Y, sample->cpu, in draw_process_bars()
1270 sample->start_time, in draw_process_bars()
1271 sample->end_time, in draw_process_bars()
1272 sample->backtrace); in draw_process_bars()
1273 if (sample->type == TYPE_BLOCKED) in draw_process_bars()
1274 svg_blocked(Y, sample->cpu, in draw_process_bars()
1275 sample->start_time, in draw_process_bars()
1276 sample->end_time, in draw_process_bars()
1277 sample->backtrace); in draw_process_bars()
1278 if (sample->type == TYPE_WAITING) in draw_process_bars()
1279 svg_waiting(Y, sample->cpu, in draw_process_bars()
1280 sample->start_time, in draw_process_bars()
1281 sample->end_time, in draw_process_bars()
1282 sample->backtrace); in draw_process_bars()
1283 sample = sample->next; in draw_process_bars()
1286 if (c->comm) { in draw_process_bars()
1288 if (c->total_time > 5000000000) /* 5 seconds */ in draw_process_bars()
1289 sprintf(comm, "%s:%i (%2.2fs)", c->comm, p->pid, c->total_time / (double)NSEC_PER_SEC); in draw_process_bars()
1291 sprintf(comm, "%s:%i (%3.1fms)", c->comm, p->pid, c->total_time / (double)NSEC_PER_MSEC); in draw_process_bars()
1293 svg_text(Y, c->start_time, comm); in draw_process_bars()
1295 c->Y = Y; in draw_process_bars()
1297 c = c->next; in draw_process_bars()
1299 p = p->next; in draw_process_bars()
1311 filt->name = strdup(string); in add_process_filter()
1312 filt->pid = pid; in add_process_filter()
1313 filt->next = process_filter; in add_process_filter()
1326 if (filt->pid && p->pid == filt->pid) in passes_filter()
1328 if (strcmp(filt->name, c->comm) == 0) in passes_filter()
1330 filt = filt->next; in passes_filter()
1341 p = tchart->all_data; in determine_display_tasks_filtered()
1343 p->display = 0; in determine_display_tasks_filtered()
1344 if (p->start_time == 1) in determine_display_tasks_filtered()
1345 p->start_time = tchart->first_time; in determine_display_tasks_filtered()
1348 if (p->end_time == 0) in determine_display_tasks_filtered()
1349 p->end_time = tchart->last_time; in determine_display_tasks_filtered()
1351 c = p->all; in determine_display_tasks_filtered()
1354 c->display = 0; in determine_display_tasks_filtered()
1356 if (c->start_time == 1) in determine_display_tasks_filtered()
1357 c->start_time = tchart->first_time; in determine_display_tasks_filtered()
1360 c->display = 1; in determine_display_tasks_filtered()
1361 p->display = 1; in determine_display_tasks_filtered()
1365 if (c->end_time == 0) in determine_display_tasks_filtered()
1366 c->end_time = tchart->last_time; in determine_display_tasks_filtered()
1368 c = c->next; in determine_display_tasks_filtered()
1370 p = p->next; in determine_display_tasks_filtered()
1381 p = tchart->all_data; in determine_display_tasks()
1383 p->display = 0; in determine_display_tasks()
1384 if (p->start_time == 1) in determine_display_tasks()
1385 p->start_time = tchart->first_time; in determine_display_tasks()
1388 if (p->end_time == 0) in determine_display_tasks()
1389 p->end_time = tchart->last_time; in determine_display_tasks()
1390 if (p->total_time >= threshold) in determine_display_tasks()
1391 p->display = 1; in determine_display_tasks()
1393 c = p->all; in determine_display_tasks()
1396 c->display = 0; in determine_display_tasks()
1398 if (c->start_time == 1) in determine_display_tasks()
1399 c->start_time = tchart->first_time; in determine_display_tasks()
1401 if (c->total_time >= threshold) { in determine_display_tasks()
1402 c->display = 1; in determine_display_tasks()
1406 if (c->end_time == 0) in determine_display_tasks()
1407 c->end_time = tchart->last_time; in determine_display_tasks()
1409 c = c->next; in determine_display_tasks()
1411 p = p->next; in determine_display_tasks()
1422 p = timechart->all_data; in determine_display_io_tasks()
1425 if (p->end_time == 0) in determine_display_io_tasks()
1426 p->end_time = timechart->last_time; in determine_display_io_tasks()
1428 c = p->all; in determine_display_io_tasks()
1431 c->display = 0; in determine_display_io_tasks()
1433 if (c->total_bytes >= threshold) { in determine_display_io_tasks()
1434 c->display = 1; in determine_display_io_tasks()
1438 if (c->end_time == 0) in determine_display_io_tasks()
1439 c->end_time = timechart->last_time; in determine_display_io_tasks()
1441 c = c->next; in determine_display_io_tasks()
1443 p = p->next; in determine_display_io_tasks()
1455 int thresh = tchart->io_events ? BYTES_THRESH : TIME_THRESH; in write_svg_file()
1457 if (tchart->power_only) in write_svg_file()
1458 tchart->proc_num = 0; in write_svg_file()
1465 else if (tchart->io_events) in write_svg_file()
1470 } while (!process_filter && thresh && count < tchart->proc_num); in write_svg_file()
1472 if (!tchart->proc_num) in write_svg_file()
1475 if (tchart->io_events) { in write_svg_file()
1476 open_svg(filename, 0, count, tchart->first_time, tchart->last_time); in write_svg_file()
1483 open_svg(filename, tchart->numcpus, count, tchart->first_time, tchart->last_time); in write_svg_file()
1489 for (i = 0; i < tchart->numcpus; i++) in write_svg_file()
1490 svg_cpu_box(i, tchart->max_freq, tchart->turbo_frequency); in write_svg_file()
1493 if (tchart->proc_num) in write_svg_file()
1495 if (!tchart->tasks_only) in write_svg_file()
1497 if (tchart->proc_num) in write_svg_file()
1514 tchart->numcpus = ph->env.nr_cpus_avail; in process_header()
1518 if (!tchart->topology) in process_header()
1521 if (svg_build_topology_map(&ph->env)) in process_header()
1598 .force = tchart->force, in __cmd_timechart()
1602 &tchart->tool); in __cmd_timechart()
1603 int ret = -EINVAL; in __cmd_timechart()
1608 symbol__init(&session->header.env); in __cmd_timechart()
1610 (void)perf_header__process_sections(&session->header, in __cmd_timechart()
1611 perf_data__fd(session->data), in __cmd_timechart()
1635 (tchart->last_time - tchart->first_time) / (double)NSEC_PER_SEC, output_name); in __cmd_timechart()
1649 "record", "-a", "-R", "-c", "1", in timechart__io_record()
1724 return -ENOMEM; in timechart__io_record()
1728 return -ENOMEM; in timechart__io_record()
1737 rec_argc -= 4; in timechart__io_record()
1741 *p++ = "-e"; in timechart__io_record()
1743 *p++ = "--filter"; in timechart__io_record()
1748 rec_argc -= 4; in timechart__io_record()
1752 *p++ = "-e"; in timechart__io_record()
1754 *p++ = "--filter"; in timechart__io_record()
1759 rec_argc -= 4; in timechart__io_record()
1763 *p++ = "-e"; in timechart__io_record()
1765 *p++ = "--filter"; in timechart__io_record()
1784 "record", "-a", "-R", "-c", "1", in timechart__record()
1789 "-g", in timechart__record()
1794 "-e", "power:cpu_frequency", in timechart__record()
1795 "-e", "power:cpu_idle", in timechart__record()
1801 "-e", "power:power_start", in timechart__record()
1802 "-e", "power:power_end", in timechart__record()
1803 "-e", "power:power_frequency", in timechart__record()
1809 "-e", "sched:sched_wakeup", in timechart__record()
1810 "-e", "sched:sched_switch", in timechart__record()
1824 if (tchart->power_only) in timechart__record()
1827 if (tchart->tasks_only) { in timechart__record()
1832 if (!tchart->with_backtrace) in timechart__record()
1842 return -ENOMEM; in timechart__record()
1882 return -1; in parse_highlight()
1896 u64 *value = opt->value; in parse_time()
1909 return -1; in parse_time()
1923 .sample = process_sample_event, in cmd_timechart()
1932 OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"), in cmd_timechart()
1933 OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only, "output processes data only"), in cmd_timechart()
1949 OPT_INTEGER('n', "proc-num", &tchart.proc_num, in cmd_timechart()
1950 "min. number of tasks to print"), in cmd_timechart()
1953 OPT_BOOLEAN(0, "io-skip-eagain", &tchart.skip_eagain, in cmd_timechart()
1955 OPT_CALLBACK(0, "io-min-time", &tchart.min_time, "time", in cmd_timechart()
1956 "all IO faster than min-time will visually appear longer", in cmd_timechart()
1958 OPT_CALLBACK(0, "io-merge-dist", &tchart.merge_dist, "time", in cmd_timechart()
1959 "merge events that are merge-dist us apart", in cmd_timechart()
1970 OPT_BOOLEAN('I', "io-only", &tchart.io_only, in cmd_timechart()
1983 pr_err("-P and -T options cannot be used at the same time.\n"); in cmd_timechart()
1984 return -1; in cmd_timechart()
1993 pr_err("-P and -T options cannot be used at the same time.\n"); in cmd_timechart()
1994 return -1; in cmd_timechart()