Lines Matching defs:tchart

202 static struct per_pid *find_create_pid(struct timechart *tchart, int pid)
204 struct per_pid *cursor = tchart->all_data;
214 cursor->next = tchart->all_data;
215 tchart->all_data = cursor;
232 static void pid_set_comm(struct timechart *tchart, int pid, char *comm)
236 p = find_create_pid(tchart, pid);
255 static void pid_fork(struct timechart *tchart, int pid, int ppid, u64 timestamp)
258 p = find_create_pid(tchart, pid);
259 pp = find_create_pid(tchart, ppid);
262 pid_set_comm(tchart, pid, pp->current->comm);
271 static void pid_exit(struct timechart *tchart, int pid, u64 timestamp)
274 p = find_create_pid(tchart, pid);
280 static void pid_put_sample(struct timechart *tchart, int pid, int type,
288 p = find_create_pid(tchart, pid);
328 struct timechart *tchart = container_of(tool, struct timechart, tool);
329 pid_set_comm(tchart, event->comm.tid, event->comm.comm);
338 struct timechart *tchart = container_of(tool, struct timechart, tool);
339 pid_fork(tchart, event->fork.pid, event->fork.ppid, event->fork.time);
348 struct timechart *tchart = container_of(tool, struct timechart, tool);
349 pid_exit(tchart, event->fork.pid, event->fork.time);
363 static void c_state_end(struct timechart *tchart, int cpu, u64 timestamp)
375 pwr->next = tchart->power_events;
377 tchart->power_events = pwr;
380 static struct power_event *p_state_end(struct timechart *tchart, int cpu,
393 pwr->next = tchart->power_events;
395 pwr->start_time = tchart->first_time;
397 tchart->power_events = pwr;
401 static void p_state_change(struct timechart *tchart, int cpu, u64 timestamp, u64 new_freq)
408 pwr = p_state_end(tchart, cpu, timestamp);
415 if ((u64)new_freq > tchart->max_freq)
416 tchart->max_freq = new_freq;
418 if (new_freq < tchart->min_freq || tchart->min_freq == 0)
419 tchart->min_freq = new_freq;
421 if (new_freq == tchart->max_freq - 1000)
422 tchart->turbo_frequency = tchart->max_freq;
425 static void sched_wakeup(struct timechart *tchart, int cpu, u64 timestamp,
442 we->next = tchart->wake_events;
443 tchart->wake_events = we;
444 p = find_create_pid(tchart, we->wakee);
451 pid_put_sample(tchart, p->pid, p->current->state, cpu,
458 static void sched_switch(struct timechart *tchart, int cpu, u64 timestamp,
464 prev_p = find_create_pid(tchart, prev_pid);
466 p = find_create_pid(tchart, next_pid);
469 pid_put_sample(tchart, prev_pid, TYPE_RUNNING, cpu,
474 pid_put_sample(tchart, next_pid, p->current->state, cpu,
569 typedef int (*tracepoint_handler)(struct timechart *tchart,
580 struct timechart *tchart = container_of(tool, struct timechart, tool);
583 if (!tchart->first_time || tchart->first_time > sample->time)
584 tchart->first_time = sample->time;
585 if (tchart->last_time < sample->time)
586 tchart->last_time = sample->time;
591 return f(tchart, evsel, sample,
599 process_sample_cpu_idle(struct timechart *tchart __maybe_unused,
608 c_state_end(tchart, cpu_id, sample->time);
615 process_sample_cpu_frequency(struct timechart *tchart,
623 p_state_change(tchart, cpu_id, sample->time, state);
628 process_sample_sched_wakeup(struct timechart *tchart,
637 sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, backtrace);
642 process_sample_sched_switch(struct timechart *tchart,
651 sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid,
658 process_sample_power_start(struct timechart *tchart __maybe_unused,
671 process_sample_power_end(struct timechart *tchart,
676 c_state_end(tchart, sample->cpu, sample->time);
681 process_sample_power_frequency(struct timechart *tchart,
689 p_state_change(tchart, cpu_id, sample->time, value);
698 static void end_sample_processing(struct timechart *tchart)
703 for (cpu = 0; cpu <= tchart->numcpus; cpu++) {
712 pwr->end_time = tchart->last_time;
715 pwr->next = tchart->power_events;
717 tchart->power_events = pwr;
721 pwr = p_state_end(tchart, cpu, tchart->last_time);
726 pwr->state = tchart->min_freq;
730 static int pid_begin_io_sample(struct timechart *tchart, int pid, int type,
733 struct per_pid *p = find_create_pid(tchart, pid);
772 static int pid_end_io_sample(struct timechart *tchart, int pid, int type,
775 struct per_pid *p = find_create_pid(tchart, pid);
805 if (sample->end_time - sample->start_time < tchart->min_time)
806 sample->end_time = sample->start_time + tchart->min_time;
832 prev->end_time + tchart->merge_dist >= sample->start_time) {
845 tchart->io_events++;
851 process_enter_read(struct timechart *tchart,
856 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ,
861 process_exit_read(struct timechart *tchart,
866 return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ,
871 process_enter_write(struct timechart *tchart,
876 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE,
881 process_exit_write(struct timechart *tchart,
886 return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE,
891 process_enter_sync(struct timechart *tchart,
896 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC,
901 process_exit_sync(struct timechart *tchart,
906 return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC,
911 process_enter_tx(struct timechart *tchart,
916 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX,
921 process_exit_tx(struct timechart *tchart,
926 return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX,
931 process_enter_rx(struct timechart *tchart,
936 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX,
941 process_exit_rx(struct timechart *tchart,
946 return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX,
951 process_enter_poll(struct timechart *tchart,
956 return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL,
961 process_exit_poll(struct timechart *tchart,
966 return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL,
973 static void sort_pids(struct timechart *tchart)
980 while (tchart->all_data) {
981 p = tchart->all_data;
982 tchart->all_data = p->next;
1015 tchart->all_data = new_list;
1019 static void draw_c_p_states(struct timechart *tchart)
1022 pwr = tchart->power_events;
1033 pwr = tchart->power_events;
1037 pwr->state = tchart->min_freq;
1044 static void draw_wakeups(struct timechart *tchart)
1050 we = tchart->wake_events;
1056 p = tchart->all_data;
1112 static void draw_cpu_usage(struct timechart *tchart)
1117 p = tchart->all_data;
1140 static void draw_io_bars(struct timechart *tchart)
1150 p = tchart->all_data;
1165 if (tchart->skip_eagain &&
1255 static void draw_process_bars(struct timechart *tchart)
1262 Y = 2 * tchart->numcpus + 2;
1264 p = tchart->all_data;
1344 static int determine_display_tasks_filtered(struct timechart *tchart)
1350 p = tchart->all_data;
1354 p->start_time = tchart->first_time;
1358 p->end_time = tchart->last_time;
1366 c->start_time = tchart->first_time;
1375 c->end_time = tchart->last_time;
1384 static int determine_display_tasks(struct timechart *tchart, u64 threshold)
1390 p = tchart->all_data;
1394 p->start_time = tchart->first_time;
1398 p->end_time = tchart->last_time;
1408 c->start_time = tchart->first_time;
1416 c->end_time = tchart->last_time;
1460 static void write_svg_file(struct timechart *tchart, const char *filename)
1464 int thresh = tchart->io_events ? BYTES_THRESH : TIME_THRESH;
1466 if (tchart->power_only)
1467 tchart->proc_num = 0;
1473 count = determine_display_tasks_filtered(tchart);
1474 else if (tchart->io_events)
1475 count = determine_display_io_tasks(tchart, thresh);
1477 count = determine_display_tasks(tchart, thresh);
1479 } while (!process_filter && thresh && count < tchart->proc_num);
1481 if (!tchart->proc_num)
1484 if (tchart->io_events) {
1485 open_svg(filename, 0, count, tchart->first_time, tchart->last_time);
1490 draw_io_bars(tchart);
1492 open_svg(filename, tchart->numcpus, count, tchart->first_time, tchart->last_time);
1498 for (i = 0; i < tchart->numcpus; i++)
1499 svg_cpu_box(i, tchart->max_freq, tchart->turbo_frequency);
1501 draw_cpu_usage(tchart);
1502 if (tchart->proc_num)
1503 draw_process_bars(tchart);
1504 if (!tchart->tasks_only)
1505 draw_c_p_states(tchart);
1506 if (tchart->proc_num)
1507 draw_wakeups(tchart);
1519 struct timechart *tchart = data;
1523 tchart->numcpus = ph->env.nr_cpus_avail;
1527 if (!tchart->topology)
1541 static int __cmd_timechart(struct timechart *tchart, const char *output_name)
1607 .force = tchart->force,
1610 struct perf_session *session = perf_session__new(&data, &tchart->tool);
1620 tchart,
1636 end_sample_processing(tchart);
1638 sort_pids(tchart);
1640 write_svg_file(tchart, output_name);
1643 (tchart->last_time - tchart->first_time) / (double)NSEC_PER_SEC, output_name);
1784 static int timechart__record(struct timechart *tchart, int argc, const char **argv)
1832 if (tchart->power_only)
1835 if (tchart->tasks_only) {
1840 if (!tchart->with_backtrace)
1926 struct timechart tchart = {
1940 OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
1941 OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only, "output processes data only"),
1957 OPT_INTEGER('n', "proc-num", &tchart.proc_num,
1959 OPT_BOOLEAN('t', "topology", &tchart.topology,
1961 OPT_BOOLEAN(0, "io-skip-eagain", &tchart.skip_eagain,
1963 OPT_CALLBACK(0, "io-min-time", &tchart.min_time, "time",
1966 OPT_CALLBACK(0, "io-merge-dist", &tchart.merge_dist, "time",
1969 OPT_BOOLEAN('f', "force", &tchart.force, "don't complain, do it"),
1978 OPT_BOOLEAN('I', "io-only", &tchart.io_only,
1980 OPT_BOOLEAN('g', "callchain", &tchart.with_backtrace, "record callchain"),
2011 if (tchart.power_only && tchart.tasks_only) {
2022 if (tchart.power_only && tchart.tasks_only) {
2028 if (tchart.io_only)
2031 ret = timechart__record(&tchart, argc, argv);
2038 ret = __cmd_timechart(&tchart, output_name);