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

1 // SPDX-License-Identifier: GPL-2.0-only
3 * builtin-timechart.c - make an svg timechart of system activity
29 #include <subcmd/parse-options.h>
30 #include "util/parse-events.h"
41 #include <traceevent/event-parse.h>
48 #define PWR_EVENT_EXIT -1
189 u64 time; member
204 struct per_pid *cursor = tchart->all_data; in find_create_pid()
207 if (cursor->pid == pid) in find_create_pid()
209 cursor = cursor->next; in find_create_pid()
213 cursor->pid = pid; in find_create_pid()
214 cursor->next = tchart->all_data; in find_create_pid()
215 tchart->all_data = cursor; in find_create_pid()
226 p->current = c; in create_pidcomm()
227 c->next = p->all; in create_pidcomm()
228 p->all = c; in create_pidcomm()
237 c = p->all; in pid_set_comm()
239 if (c->comm && strcmp(c->comm, comm) == 0) { in pid_set_comm()
240 p->current = c; in pid_set_comm()
243 if (!c->comm) { in pid_set_comm()
244 c->comm = strdup(comm); in pid_set_comm()
245 p->current = c; in pid_set_comm()
248 c = c->next; in pid_set_comm()
252 c->comm = strdup(comm); in pid_set_comm()
260 p->ppid = ppid; in pid_fork()
261 if (pp->current && pp->current->comm && !p->current) in pid_fork()
262 pid_set_comm(tchart, pid, pp->current->comm); in pid_fork()
264 p->start_time = timestamp; in pid_fork()
265 if (p->current && !p->current->start_time) { in pid_fork()
266 p->current->start_time = timestamp; in pid_fork()
267 p->current->state_since = timestamp; in pid_fork()
275 p->end_time = timestamp; in pid_exit()
276 if (p->current) in pid_exit()
277 p->current->end_time = timestamp; in pid_exit()
286 struct cpu_sample *sample; in pid_put_sample() local
289 c = p->current; in pid_put_sample()
295 sample = zalloc(sizeof(*sample)); in pid_put_sample()
296 assert(sample != NULL); in pid_put_sample()
297 sample->start_time = start; in pid_put_sample()
298 sample->end_time = end; in pid_put_sample()
299 sample->type = type; in pid_put_sample()
300 sample->next = c->samples; in pid_put_sample()
301 sample->cpu = cpu; in pid_put_sample()
302 sample->backtrace = backtrace; in pid_put_sample()
303 c->samples = sample; in pid_put_sample()
305 if (sample->type == TYPE_RUNNING && end > start && start > 0) { in pid_put_sample()
306 c->total_time += (end-start); in pid_put_sample()
307 p->total_time += (end-start); in pid_put_sample()
310 if (c->start_time == 0 || c->start_time > start) in pid_put_sample()
311 c->start_time = start; in pid_put_sample()
312 if (p->start_time == 0 || p->start_time > start) in pid_put_sample()
313 p->start_time = start; in pid_put_sample()
325 struct perf_sample *sample __maybe_unused, in process_comm_event()
329 pid_set_comm(tchart, event->comm.tid, event->comm.comm); in process_comm_event()
335 struct perf_sample *sample __maybe_unused, in process_fork_event()
339 pid_fork(tchart, event->fork.pid, event->fork.ppid, event->fork.time); in process_fork_event()
345 struct perf_sample *sample __maybe_unused, in process_exit_event()
349 pid_exit(tchart, event->fork.pid, event->fork.time); in process_exit_event()
370 pwr->state = cpus_cstate_state[cpu]; in c_state_end()
371 pwr->start_time = cpus_cstate_start_times[cpu]; in c_state_end()
372 pwr->end_time = timestamp; in c_state_end()
373 pwr->cpu = cpu; in c_state_end()
374 pwr->type = CSTATE; in c_state_end()
375 pwr->next = tchart->power_events; in c_state_end()
377 tchart->power_events = pwr; in c_state_end()
388 pwr->state = cpus_pstate_state[cpu]; in p_state_end()
389 pwr->start_time = cpus_pstate_start_times[cpu]; in p_state_end()
390 pwr->end_time = timestamp; in p_state_end()
391 pwr->cpu = cpu; in p_state_end()
392 pwr->type = PSTATE; in p_state_end()
393 pwr->next = tchart->power_events; in p_state_end()
394 if (!pwr->start_time) in p_state_end()
395 pwr->start_time = tchart->first_time; in p_state_end()
397 tchart->power_events = pwr; in p_state_end()
415 if ((u64)new_freq > tchart->max_freq) in p_state_change()
416 tchart->max_freq = new_freq; in p_state_change()
418 if (new_freq < tchart->min_freq || tchart->min_freq == 0) in p_state_change()
419 tchart->min_freq = new_freq; in p_state_change()
421 if (new_freq == tchart->max_freq - 1000) in p_state_change()
422 tchart->turbo_frequency = tchart->max_freq; in p_state_change()
434 we->time = timestamp; in sched_wakeup()
435 we->waker = waker; in sched_wakeup()
436 we->backtrace = backtrace; in sched_wakeup()
439 we->waker = -1; in sched_wakeup()
441 we->wakee = wakee; in sched_wakeup()
442 we->next = tchart->wake_events; in sched_wakeup()
443 tchart->wake_events = we; in sched_wakeup()
444 p = find_create_pid(tchart, we->wakee); in sched_wakeup()
446 if (p && p->current && p->current->state == TYPE_NONE) { in sched_wakeup()
447 p->current->state_since = timestamp; in sched_wakeup()
448 p->current->state = TYPE_WAITING; in sched_wakeup()
450 if (p && p->current && p->current->state == TYPE_BLOCKED) { in sched_wakeup()
451 pid_put_sample(tchart, p->pid, p->current->state, cpu, in sched_wakeup()
452 p->current->state_since, timestamp, NULL); in sched_wakeup()
453 p->current->state_since = timestamp; in sched_wakeup()
454 p->current->state = TYPE_WAITING; in sched_wakeup()
468 if (prev_p->current && prev_p->current->state != TYPE_NONE) in sched_switch()
470 prev_p->current->state_since, timestamp, in sched_switch()
472 if (p && p->current) { in sched_switch()
473 if (p->current->state != TYPE_NONE) in sched_switch()
474 pid_put_sample(tchart, next_pid, p->current->state, cpu, in sched_switch()
475 p->current->state_since, timestamp, in sched_switch()
478 p->current->state_since = timestamp; in sched_switch()
479 p->current->state = TYPE_RUNNING; in sched_switch()
482 if (prev_p->current) { in sched_switch()
483 prev_p->current->state = TYPE_NONE; in sched_switch()
484 prev_p->current->state_since = timestamp; in sched_switch()
486 prev_p->current->state = TYPE_BLOCKED; in sched_switch()
488 prev_p->current->state = TYPE_WAITING; in sched_switch()
493 struct perf_sample *sample, in cat_backtrace() argument
501 struct ip_callchain *chain = sample->callchain; in cat_backtrace()
513 if (machine__resolve(machine, &al, sample) < 0) { in cat_backtrace()
515 event->header.type); in cat_backtrace()
519 for (i = 0; i < chain->nr; i++) { in cat_backtrace()
524 ip = chain->ips[i]; in cat_backtrace()
526 ip = chain->ips[chain->nr - i - 1]; in cat_backtrace()
556 fprintf(f, "..... %016" PRIx64 " %s\n", ip, tal.sym->name); in cat_backtrace()
571 struct perf_sample *sample,
576 struct perf_sample *sample, in process_sample_event() argument
582 if (evsel->core.attr.sample_type & PERF_SAMPLE_TIME) { in process_sample_event()
583 if (!tchart->first_time || tchart->first_time > sample->time) in process_sample_event()
584 tchart->first_time = sample->time; in process_sample_event()
585 if (tchart->last_time < sample->time) in process_sample_event()
586 tchart->last_time = sample->time; in process_sample_event()
589 if (evsel->handler != NULL) { in process_sample_event()
590 tracepoint_handler f = evsel->handler; in process_sample_event()
591 return f(tchart, evsel, sample, in process_sample_event()
592 cat_backtrace(event, sample, machine)); in process_sample_event()
601 struct perf_sample *sample, in process_sample_cpu_idle() argument
604 u32 state = evsel__intval(evsel, sample, "state"); in process_sample_cpu_idle()
605 u32 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_cpu_idle()
608 c_state_end(tchart, cpu_id, sample->time); in process_sample_cpu_idle()
610 c_state_start(cpu_id, sample->time, state); in process_sample_cpu_idle()
617 struct perf_sample *sample, in process_sample_cpu_frequency() argument
620 u32 state = evsel__intval(evsel, sample, "state"); in process_sample_cpu_frequency()
621 u32 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_cpu_frequency()
623 p_state_change(tchart, cpu_id, sample->time, state); in process_sample_cpu_frequency()
630 struct perf_sample *sample, in process_sample_sched_wakeup() argument
633 u8 flags = evsel__intval(evsel, sample, "common_flags"); in process_sample_sched_wakeup()
634 int waker = evsel__intval(evsel, sample, "common_pid"); in process_sample_sched_wakeup()
635 int wakee = evsel__intval(evsel, sample, "pid"); in process_sample_sched_wakeup()
637 sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, backtrace); in process_sample_sched_wakeup()
644 struct perf_sample *sample, in process_sample_sched_switch() argument
647 int prev_pid = evsel__intval(evsel, sample, "prev_pid"); in process_sample_sched_switch()
648 int next_pid = evsel__intval(evsel, sample, "next_pid"); in process_sample_sched_switch()
649 u64 prev_state = evsel__intval(evsel, sample, "prev_state"); in process_sample_sched_switch()
651 sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid, in process_sample_sched_switch()
660 struct perf_sample *sample, in process_sample_power_start() argument
663 u64 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_power_start()
664 u64 value = evsel__intval(evsel, sample, "value"); in process_sample_power_start()
666 c_state_start(cpu_id, sample->time, value); in process_sample_power_start()
673 struct perf_sample *sample, in process_sample_power_end() argument
676 c_state_end(tchart, sample->cpu, sample->time); in process_sample_power_end()
683 struct perf_sample *sample, in process_sample_power_frequency() argument
686 u64 cpu_id = evsel__intval(evsel, sample, "cpu_id"); in process_sample_power_frequency()
687 u64 value = evsel__intval(evsel, sample, "value"); in process_sample_power_frequency()
689 p_state_change(tchart, cpu_id, sample->time, value); in process_sample_power_frequency()
695 * After the last sample we need to wrap up the current C/P state
703 for (cpu = 0; cpu <= tchart->numcpus; cpu++) { in end_sample_processing()
710 pwr->state = cpus_cstate_state[cpu]; in end_sample_processing()
711 pwr->start_time = cpus_cstate_start_times[cpu]; in end_sample_processing()
712 pwr->end_time = tchart->last_time; in end_sample_processing()
713 pwr->cpu = cpu; in end_sample_processing()
714 pwr->type = CSTATE; in end_sample_processing()
715 pwr->next = tchart->power_events; in end_sample_processing()
717 tchart->power_events = pwr; in end_sample_processing()
721 pwr = p_state_end(tchart, cpu, tchart->last_time); in end_sample_processing()
725 if (!pwr->state) in end_sample_processing()
726 pwr->state = tchart->min_freq; in end_sample_processing()
734 struct per_pidcomm *c = p->current; in pid_begin_io_sample()
735 struct io_sample *sample; in pid_begin_io_sample() local
741 return -ENOMEM; in pid_begin_io_sample()
744 prev = c->io_samples; in pid_begin_io_sample()
746 if (prev && prev->start_time && !prev->end_time) { in pid_begin_io_sample()
752 c->io_samples = prev->next; in pid_begin_io_sample()
757 sample = zalloc(sizeof(*sample)); in pid_begin_io_sample()
758 if (!sample) in pid_begin_io_sample()
759 return -ENOMEM; in pid_begin_io_sample()
760 sample->start_time = start; in pid_begin_io_sample()
761 sample->type = type; in pid_begin_io_sample()
762 sample->fd = fd; in pid_begin_io_sample()
763 sample->next = c->io_samples; in pid_begin_io_sample()
764 c->io_samples = sample; in pid_begin_io_sample()
766 if (c->start_time == 0 || c->start_time > start) in pid_begin_io_sample()
767 c->start_time = start; in pid_begin_io_sample()
776 struct per_pidcomm *c = p->current; in pid_end_io_sample()
777 struct io_sample *sample, *prev; in pid_end_io_sample() local
781 return -1; in pid_end_io_sample()
784 sample = c->io_samples; in pid_end_io_sample()
786 if (!sample) /* skip partially captured events */ in pid_end_io_sample()
789 if (sample->end_time) { in pid_end_io_sample()
795 if (sample->type != type) { in pid_end_io_sample()
800 sample->end_time = end; in pid_end_io_sample()
801 prev = sample->next; in pid_end_io_sample()
805 if (sample->end_time - sample->start_time < tchart->min_time) in pid_end_io_sample()
806 sample->end_time = sample->start_time + tchart->min_time; in pid_end_io_sample()
807 if (prev && sample->start_time < prev->end_time) { in pid_end_io_sample()
808 if (prev->err) /* try to make errors more visible */ in pid_end_io_sample()
809 sample->start_time = prev->end_time; in pid_end_io_sample()
811 prev->end_time = sample->start_time; in pid_end_io_sample()
815 sample->err = ret; in pid_end_io_sample()
819 if ((u64)ret > c->max_bytes) in pid_end_io_sample()
820 c->max_bytes = ret; in pid_end_io_sample()
822 c->total_bytes += ret; in pid_end_io_sample()
823 p->total_bytes += ret; in pid_end_io_sample()
824 sample->bytes = ret; in pid_end_io_sample()
827 /* merge two requests to make svg smaller and render-friendly */ in pid_end_io_sample()
829 prev->type == sample->type && in pid_end_io_sample()
830 prev->err == sample->err && in pid_end_io_sample()
831 prev->fd == sample->fd && in pid_end_io_sample()
832 prev->end_time + tchart->merge_dist >= sample->start_time) { in pid_end_io_sample()
834 sample->bytes += prev->bytes; in pid_end_io_sample()
835 sample->merges += prev->merges + 1; in pid_end_io_sample()
837 sample->start_time = prev->start_time; in pid_end_io_sample()
838 sample->next = prev->next; in pid_end_io_sample()
841 if (!sample->err && sample->bytes > c->max_bytes) in pid_end_io_sample()
842 c->max_bytes = sample->bytes; in pid_end_io_sample()
845 tchart->io_events++; in pid_end_io_sample()
853 struct perf_sample *sample) in process_enter_read() argument
855 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_read()
856 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ, in process_enter_read()
857 sample->time, fd); in process_enter_read()
863 struct perf_sample *sample) in process_exit_read() argument
865 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_read()
866 return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ, in process_exit_read()
867 sample->time, ret); in process_exit_read()
873 struct perf_sample *sample) in process_enter_write() argument
875 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_write()
876 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE, in process_enter_write()
877 sample->time, fd); in process_enter_write()
883 struct perf_sample *sample) in process_exit_write() argument
885 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_write()
886 return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE, in process_exit_write()
887 sample->time, ret); in process_exit_write()
893 struct perf_sample *sample) in process_enter_sync() argument
895 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_sync()
896 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC, in process_enter_sync()
897 sample->time, fd); in process_enter_sync()
903 struct perf_sample *sample) in process_exit_sync() argument
905 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_sync()
906 return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC, in process_exit_sync()
907 sample->time, ret); in process_exit_sync()
913 struct perf_sample *sample) in process_enter_tx() argument
915 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_tx()
916 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX, in process_enter_tx()
917 sample->time, fd); in process_enter_tx()
923 struct perf_sample *sample) in process_exit_tx() argument
925 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_tx()
926 return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX, in process_exit_tx()
927 sample->time, ret); in process_exit_tx()
933 struct perf_sample *sample) in process_enter_rx() argument
935 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_rx()
936 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX, in process_enter_rx()
937 sample->time, fd); in process_enter_rx()
943 struct perf_sample *sample) in process_exit_rx() argument
945 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_rx()
946 return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX, in process_exit_rx()
947 sample->time, ret); in process_exit_rx()
953 struct perf_sample *sample) in process_enter_poll() argument
955 long fd = evsel__intval(evsel, sample, "fd"); in process_enter_poll()
956 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL, in process_enter_poll()
957 sample->time, fd); in process_enter_poll()
963 struct perf_sample *sample) in process_exit_poll() argument
965 long ret = evsel__intval(evsel, sample, "ret"); in process_exit_poll()
966 return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL, in process_exit_poll()
967 sample->time, ret); in process_exit_poll()
980 while (tchart->all_data) { in sort_pids()
981 p = tchart->all_data; in sort_pids()
982 tchart->all_data = p->next; in sort_pids()
983 p->next = NULL; in sort_pids()
987 p->next = NULL; in sort_pids()
993 if (cursor->ppid > p->ppid || in sort_pids()
994 (cursor->ppid == p->ppid && cursor->pid > p->pid)) { in sort_pids()
997 p->next = prev->next; in sort_pids()
998 prev->next = p; in sort_pids()
1002 p->next = new_list; in sort_pids()
1010 cursor = cursor->next; in sort_pids()
1012 prev->next = p; in sort_pids()
1015 tchart->all_data = new_list; in sort_pids()
1022 pwr = tchart->power_events; in draw_c_p_states()
1028 if (pwr->type == CSTATE) in draw_c_p_states()
1029 svg_cstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state); in draw_c_p_states()
1030 pwr = pwr->next; in draw_c_p_states()
1033 pwr = tchart->power_events; in draw_c_p_states()
1035 if (pwr->type == PSTATE) { in draw_c_p_states()
1036 if (!pwr->state) in draw_c_p_states()
1037 pwr->state = tchart->min_freq; in draw_c_p_states()
1038 svg_pstate(pwr->cpu, pwr->start_time, pwr->end_time, pwr->state); in draw_c_p_states()
1040 pwr = pwr->next; in draw_c_p_states()
1050 we = tchart->wake_events; in draw_wakeups()
1056 p = tchart->all_data; in draw_wakeups()
1058 if (p->pid == we->waker || p->pid == we->wakee) { in draw_wakeups()
1059 c = p->all; in draw_wakeups()
1061 if (c->Y && c->start_time <= we->time && c->end_time >= we->time) { in draw_wakeups()
1062 if (p->pid == we->waker && !from) { in draw_wakeups()
1063 from = c->Y; in draw_wakeups()
1064 task_from = strdup(c->comm); in draw_wakeups()
1066 if (p->pid == we->wakee && !to) { in draw_wakeups()
1067 to = c->Y; in draw_wakeups()
1068 task_to = strdup(c->comm); in draw_wakeups()
1071 c = c->next; in draw_wakeups()
1073 c = p->all; in draw_wakeups()
1075 if (p->pid == we->waker && !from) { in draw_wakeups()
1076 from = c->Y; in draw_wakeups()
1077 task_from = strdup(c->comm); in draw_wakeups()
1079 if (p->pid == we->wakee && !to) { in draw_wakeups()
1080 to = c->Y; in draw_wakeups()
1081 task_to = strdup(c->comm); in draw_wakeups()
1083 c = c->next; in draw_wakeups()
1086 p = p->next; in draw_wakeups()
1091 sprintf(task_from, "[%i]", we->waker); in draw_wakeups()
1095 sprintf(task_to, "[%i]", we->wakee); in draw_wakeups()
1098 if (we->waker == -1) in draw_wakeups()
1099 svg_interrupt(we->time, to, we->backtrace); in draw_wakeups()
1100 else if (from && to && abs(from - to) == 1) in draw_wakeups()
1101 svg_wakeline(we->time, from, to, we->backtrace); in draw_wakeups()
1103 svg_partial_wakeline(we->time, from, task_from, to, in draw_wakeups()
1104 task_to, we->backtrace); in draw_wakeups()
1105 we = we->next; in draw_wakeups()
1116 struct cpu_sample *sample; in draw_cpu_usage() local
1117 p = tchart->all_data; in draw_cpu_usage()
1119 c = p->all; in draw_cpu_usage()
1121 sample = c->samples; in draw_cpu_usage()
1122 while (sample) { in draw_cpu_usage()
1123 if (sample->type == TYPE_RUNNING) { in draw_cpu_usage()
1124 svg_process(sample->cpu, in draw_cpu_usage()
1125 sample->start_time, in draw_cpu_usage()
1126 sample->end_time, in draw_cpu_usage()
1127 p->pid, in draw_cpu_usage()
1128 c->comm, in draw_cpu_usage()
1129 sample->backtrace); in draw_cpu_usage()
1132 sample = sample->next; in draw_cpu_usage()
1134 c = c->next; in draw_cpu_usage()
1136 p = p->next; in draw_cpu_usage()
1147 struct io_sample *sample; in draw_io_bars() local
1150 p = tchart->all_data; in draw_io_bars()
1152 c = p->all; in draw_io_bars()
1154 if (!c->display) { in draw_io_bars()
1155 c->Y = 0; in draw_io_bars()
1156 c = c->next; in draw_io_bars()
1160 svg_box(Y, c->start_time, c->end_time, "process3"); in draw_io_bars()
1161 sample = c->io_samples; in draw_io_bars()
1162 for (sample = c->io_samples; sample; sample = sample->next) { in draw_io_bars()
1163 double h = (double)sample->bytes / c->max_bytes; in draw_io_bars()
1165 if (tchart->skip_eagain && in draw_io_bars()
1166 sample->err == -EAGAIN) in draw_io_bars()
1169 if (sample->err) in draw_io_bars()
1172 if (sample->type == IOTYPE_SYNC) in draw_io_bars()
1174 sample->start_time, in draw_io_bars()
1175 sample->end_time, in draw_io_bars()
1177 sample->err ? "error" : "sync", 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_POLL) in draw_io_bars()
1183 sample->start_time, in draw_io_bars()
1184 sample->end_time, in draw_io_bars()
1186 sample->err ? "error" : "poll", 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_READ) 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_WRITE) in draw_io_bars()
1201 sample->start_time, in draw_io_bars()
1202 sample->end_time, in draw_io_bars()
1204 sample->err ? "error" : "disk", 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_RX) 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()
1217 else if (sample->type == IOTYPE_TX) in draw_io_bars()
1219 sample->start_time, in draw_io_bars()
1220 sample->end_time, in draw_io_bars()
1222 sample->err ? "error" : "net", in draw_io_bars()
1223 sample->fd, in draw_io_bars()
1224 sample->err, in draw_io_bars()
1225 sample->merges); in draw_io_bars()
1229 bytes = c->total_bytes; in draw_io_bars()
1244 sprintf(comm, "%s:%i (%3.1f %sbytes)", c->comm ?: "", p->pid, bytes, suf); in draw_io_bars()
1245 svg_text(Y, c->start_time, comm); in draw_io_bars()
1247 c->Y = Y; in draw_io_bars()
1249 c = c->next; in draw_io_bars()
1251 p = p->next; in draw_io_bars()
1259 struct cpu_sample *sample; in draw_process_bars() local
1262 Y = 2 * tchart->numcpus + 2; in draw_process_bars()
1264 p = tchart->all_data; in draw_process_bars()
1266 c = p->all; in draw_process_bars()
1268 if (!c->display) { in draw_process_bars()
1269 c->Y = 0; in draw_process_bars()
1270 c = c->next; in draw_process_bars()
1274 svg_box(Y, c->start_time, c->end_time, "process"); in draw_process_bars()
1275 sample = c->samples; in draw_process_bars()
1276 while (sample) { in draw_process_bars()
1277 if (sample->type == TYPE_RUNNING) in draw_process_bars()
1278 svg_running(Y, sample->cpu, in draw_process_bars()
1279 sample->start_time, in draw_process_bars()
1280 sample->end_time, in draw_process_bars()
1281 sample->backtrace); in draw_process_bars()
1282 if (sample->type == TYPE_BLOCKED) in draw_process_bars()
1283 svg_blocked(Y, sample->cpu, in draw_process_bars()
1284 sample->start_time, in draw_process_bars()
1285 sample->end_time, in draw_process_bars()
1286 sample->backtrace); in draw_process_bars()
1287 if (sample->type == TYPE_WAITING) in draw_process_bars()
1288 svg_waiting(Y, sample->cpu, in draw_process_bars()
1289 sample->start_time, in draw_process_bars()
1290 sample->end_time, in draw_process_bars()
1291 sample->backtrace); in draw_process_bars()
1292 sample = sample->next; in draw_process_bars()
1295 if (c->comm) { in draw_process_bars()
1297 if (c->total_time > 5000000000) /* 5 seconds */ in draw_process_bars()
1298 sprintf(comm, "%s:%i (%2.2fs)", c->comm, p->pid, c->total_time / (double)NSEC_PER_SEC); in draw_process_bars()
1300 sprintf(comm, "%s:%i (%3.1fms)", c->comm, p->pid, c->total_time / (double)NSEC_PER_MSEC); in draw_process_bars()
1302 svg_text(Y, c->start_time, comm); in draw_process_bars()
1304 c->Y = Y; in draw_process_bars()
1306 c = c->next; in draw_process_bars()
1308 p = p->next; in draw_process_bars()
1320 filt->name = strdup(string); in add_process_filter()
1321 filt->pid = pid; in add_process_filter()
1322 filt->next = process_filter; in add_process_filter()
1335 if (filt->pid && p->pid == filt->pid) in passes_filter()
1337 if (strcmp(filt->name, c->comm) == 0) in passes_filter()
1339 filt = filt->next; in passes_filter()
1350 p = tchart->all_data; in determine_display_tasks_filtered()
1352 p->display = 0; in determine_display_tasks_filtered()
1353 if (p->start_time == 1) in determine_display_tasks_filtered()
1354 p->start_time = tchart->first_time; in determine_display_tasks_filtered()
1357 if (p->end_time == 0) in determine_display_tasks_filtered()
1358 p->end_time = tchart->last_time; in determine_display_tasks_filtered()
1360 c = p->all; in determine_display_tasks_filtered()
1363 c->display = 0; in determine_display_tasks_filtered()
1365 if (c->start_time == 1) in determine_display_tasks_filtered()
1366 c->start_time = tchart->first_time; in determine_display_tasks_filtered()
1369 c->display = 1; in determine_display_tasks_filtered()
1370 p->display = 1; in determine_display_tasks_filtered()
1374 if (c->end_time == 0) in determine_display_tasks_filtered()
1375 c->end_time = tchart->last_time; in determine_display_tasks_filtered()
1377 c = c->next; in determine_display_tasks_filtered()
1379 p = p->next; in determine_display_tasks_filtered()
1390 p = tchart->all_data; in determine_display_tasks()
1392 p->display = 0; in determine_display_tasks()
1393 if (p->start_time == 1) in determine_display_tasks()
1394 p->start_time = tchart->first_time; in determine_display_tasks()
1397 if (p->end_time == 0) in determine_display_tasks()
1398 p->end_time = tchart->last_time; in determine_display_tasks()
1399 if (p->total_time >= threshold) in determine_display_tasks()
1400 p->display = 1; in determine_display_tasks()
1402 c = p->all; in determine_display_tasks()
1405 c->display = 0; in determine_display_tasks()
1407 if (c->start_time == 1) in determine_display_tasks()
1408 c->start_time = tchart->first_time; in determine_display_tasks()
1410 if (c->total_time >= threshold) { in determine_display_tasks()
1411 c->display = 1; in determine_display_tasks()
1415 if (c->end_time == 0) in determine_display_tasks()
1416 c->end_time = tchart->last_time; in determine_display_tasks()
1418 c = c->next; in determine_display_tasks()
1420 p = p->next; in determine_display_tasks()
1431 p = timechart->all_data; in determine_display_io_tasks()
1434 if (p->end_time == 0) in determine_display_io_tasks()
1435 p->end_time = timechart->last_time; in determine_display_io_tasks()
1437 c = p->all; in determine_display_io_tasks()
1440 c->display = 0; in determine_display_io_tasks()
1442 if (c->total_bytes >= threshold) { in determine_display_io_tasks()
1443 c->display = 1; in determine_display_io_tasks()
1447 if (c->end_time == 0) in determine_display_io_tasks()
1448 c->end_time = timechart->last_time; in determine_display_io_tasks()
1450 c = c->next; in determine_display_io_tasks()
1452 p = p->next; in determine_display_io_tasks()
1464 int thresh = tchart->io_events ? BYTES_THRESH : TIME_THRESH; in write_svg_file()
1466 if (tchart->power_only) in write_svg_file()
1467 tchart->proc_num = 0; in write_svg_file()
1474 else if (tchart->io_events) in write_svg_file()
1479 } while (!process_filter && thresh && count < tchart->proc_num); in write_svg_file()
1481 if (!tchart->proc_num) in write_svg_file()
1484 if (tchart->io_events) { in write_svg_file()
1485 open_svg(filename, 0, count, tchart->first_time, tchart->last_time); in write_svg_file()
1492 open_svg(filename, tchart->numcpus, count, tchart->first_time, tchart->last_time); in write_svg_file()
1498 for (i = 0; i < tchart->numcpus; i++) in write_svg_file()
1499 svg_cpu_box(i, tchart->max_freq, tchart->turbo_frequency); in write_svg_file()
1502 if (tchart->proc_num) in write_svg_file()
1504 if (!tchart->tasks_only) in write_svg_file()
1506 if (tchart->proc_num) in write_svg_file()
1523 tchart->numcpus = ph->env.nr_cpus_avail; in process_header()
1527 if (!tchart->topology) in process_header()
1530 if (svg_build_topology_map(&ph->env)) in process_header()
1607 .force = tchart->force, in __cmd_timechart()
1610 int ret = -EINVAL; in __cmd_timechart()
1612 perf_tool__init(&tchart->tool, /*ordered_events=*/true); in __cmd_timechart()
1613 tchart->tool.comm = process_comm_event; in __cmd_timechart()
1614 tchart->tool.fork = process_fork_event; in __cmd_timechart()
1615 tchart->tool.exit = process_exit_event; in __cmd_timechart()
1616 tchart->tool.sample = process_sample_event; in __cmd_timechart()
1618 session = perf_session__new(&data, &tchart->tool); in __cmd_timechart()
1622 symbol__init(&session->header.env); in __cmd_timechart()
1624 (void)perf_header__process_sections(&session->header, in __cmd_timechart()
1625 perf_data__fd(session->data), in __cmd_timechart()
1649 (tchart->last_time - tchart->first_time) / (double)NSEC_PER_SEC, output_name); in __cmd_timechart()
1663 "record", "-a", "-R", "-c", "1", in timechart__io_record()
1738 return -ENOMEM; in timechart__io_record()
1742 return -ENOMEM; in timechart__io_record()
1751 rec_argc -= 4; in timechart__io_record()
1755 *p++ = "-e"; in timechart__io_record()
1757 *p++ = "--filter"; in timechart__io_record()
1762 rec_argc -= 4; in timechart__io_record()
1766 *p++ = "-e"; in timechart__io_record()
1768 *p++ = "--filter"; in timechart__io_record()
1773 rec_argc -= 4; in timechart__io_record()
1777 *p++ = "-e"; in timechart__io_record()
1779 *p++ = "--filter"; in timechart__io_record()
1798 "record", "-a", "-R", "-c", "1", in timechart__record()
1803 "-g", in timechart__record()
1808 "-e", "power:cpu_frequency", in timechart__record()
1809 "-e", "power:cpu_idle", in timechart__record()
1815 "-e", "power:power_start", in timechart__record()
1816 "-e", "power:power_end", in timechart__record()
1817 "-e", "power:power_frequency", in timechart__record()
1823 "-e", "sched:sched_wakeup", in timechart__record()
1824 "-e", "sched:sched_switch", in timechart__record()
1838 if (tchart->power_only) in timechart__record()
1841 if (tchart->tasks_only) { in timechart__record()
1846 if (!tchart->with_backtrace) in timechart__record()
1856 return -ENOMEM; in timechart__record()
1896 return -1; in parse_highlight()
1910 u64 *value = opt->value; in parse_time()
1923 return -1; in parse_time()
1939 OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"), in cmd_timechart()
1940 OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only, "output processes data only"), in cmd_timechart()
1956 OPT_INTEGER('n', "proc-num", &tchart.proc_num, in cmd_timechart()
1960 OPT_BOOLEAN(0, "io-skip-eagain", &tchart.skip_eagain, in cmd_timechart()
1962 OPT_CALLBACK(0, "io-min-time", &tchart.min_time, "time", in cmd_timechart()
1963 "all IO faster than min-time will visually appear longer", in cmd_timechart()
1965 OPT_CALLBACK(0, "io-merge-dist", &tchart.merge_dist, "time", in cmd_timechart()
1966 "merge events that are merge-dist us apart", in cmd_timechart()
1977 OPT_BOOLEAN('I', "io-only", &tchart.io_only, in cmd_timechart()
1990 return -ENOMEM; in cmd_timechart()
1993 ret = -ENOMEM; in cmd_timechart()
1998 ret = -ENOMEM; in cmd_timechart()
2003 ret = -ENOMEM; in cmd_timechart()
2011 pr_err("-P and -T options cannot be used at the same time.\n"); in cmd_timechart()
2012 ret = -1; in cmd_timechart()
2022 pr_err("-P and -T options cannot be used at the same time.\n"); in cmd_timechart()
2023 ret = -1; in cmd_timechart()