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

1 // SPDX-License-Identifier: GPL-2.0
3 #include "perf-sys.h"
21 #include "util/time-utils.h"
24 #include <subcmd/parse-options.h>
25 #include "util/trace-event.h"
131 struct perf_sample *sample, struct machine *machine);
134 struct perf_sample *sample, struct machine *machine);
137 struct perf_sample *sample, struct machine *machine);
145 struct perf_sample *sample,
178 * Track the current task - that way we can know whether there's any
242 /* per thread run time data */
244 u64 last_time; /* time of previous sched in/out event */
245 u64 dt_run; /* run time */
246 u64 dt_sleep; /* time between CPU access by sleep (off cpu) */
247 u64 dt_iowait; /* time between CPU access by iowait (off cpu) */
248 u64 dt_preempt; /* time between CPU access by preempt (off cpu) */
249 u64 dt_delay; /* time between wakeup and sched-in */
250 u64 ready_to_run; /* time of wakeup */
269 /* per event run time data */
271 u64 *last_time; /* time this event was last seen per cpu */
275 /* per cpu idle time data */
304 } while (T1 + sched->run_measurement_overhead < T0 + nsecs); in burn_nsecs()
326 delta = T1-T0; in calibrate_run_measurement_overhead()
329 sched->run_measurement_overhead = min_delta; in calibrate_run_measurement_overhead()
343 delta = T1-T0; in calibrate_sleep_measurement_overhead()
346 min_delta -= 10000; in calibrate_sleep_measurement_overhead()
347 sched->sleep_measurement_overhead = min_delta; in calibrate_sleep_measurement_overhead()
356 unsigned long idx = task->nr_events; in get_new_event()
359 event->timestamp = timestamp; in get_new_event()
360 event->nr = idx; in get_new_event()
362 task->nr_events++; in get_new_event()
363 size = sizeof(struct sched_atom *) * task->nr_events; in get_new_event()
364 task->atoms = realloc(task->atoms, size); in get_new_event()
365 BUG_ON(!task->atoms); in get_new_event()
367 task->atoms[idx] = event; in get_new_event()
374 if (!task->nr_events) in last_event()
377 return task->atoms[task->nr_events - 1]; in last_event()
389 if (curr_event && curr_event->type == SCHED_EVENT_RUN) { in add_sched_event_run()
390 sched->nr_run_events_optimized++; in add_sched_event_run()
391 curr_event->duration += duration; in add_sched_event_run()
397 event->type = SCHED_EVENT_RUN; in add_sched_event_run()
398 event->duration = duration; in add_sched_event_run()
400 sched->nr_run_events++; in add_sched_event_run()
409 event->type = SCHED_EVENT_WAKEUP; in add_sched_event_wakeup()
410 event->wakee = wakee; in add_sched_event_wakeup()
413 if (!wakee_event || wakee_event->type != SCHED_EVENT_SLEEP) { in add_sched_event_wakeup()
414 sched->targetless_wakeups++; in add_sched_event_wakeup()
417 if (wakee_event->wait_sem) { in add_sched_event_wakeup()
418 sched->multitarget_wakeups++; in add_sched_event_wakeup()
422 wakee_event->wait_sem = zalloc(sizeof(*wakee_event->wait_sem)); in add_sched_event_wakeup()
423 sem_init(wakee_event->wait_sem, 0, 0); in add_sched_event_wakeup()
424 wakee_event->specific_wait = 1; in add_sched_event_wakeup()
425 event->wait_sem = wakee_event->wait_sem; in add_sched_event_wakeup()
427 sched->nr_wakeup_events++; in add_sched_event_wakeup()
435 event->type = SCHED_EVENT_SLEEP; in add_sched_event_sleep()
437 sched->nr_sleep_events++; in add_sched_event_sleep()
446 if (sched->pid_to_task == NULL) { in register_pid()
449 BUG_ON((sched->pid_to_task = calloc(pid_max, sizeof(struct task_desc *))) == NULL); in register_pid()
452 BUG_ON((sched->pid_to_task = realloc(sched->pid_to_task, (pid + 1) * in register_pid()
455 sched->pid_to_task[pid_max++] = NULL; in register_pid()
458 task = sched->pid_to_task[pid]; in register_pid()
464 task->pid = pid; in register_pid()
465 task->nr = sched->nr_tasks; in register_pid()
466 strcpy(task->comm, comm); in register_pid()
468 * every task starts in sleeping state - this gets ignored in register_pid()
473 sched->pid_to_task[pid] = task; in register_pid()
474 sched->nr_tasks++; in register_pid()
475 sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_desc *)); in register_pid()
476 BUG_ON(!sched->tasks); in register_pid()
477 sched->tasks[task->nr] = task; in register_pid()
480 printf("registered task #%ld, PID %ld (%s)\n", sched->nr_tasks, pid, comm); in register_pid()
491 for (i = 0; i < sched->nr_tasks; i++) { in print_task_traces()
492 task = sched->tasks[i]; in print_task_traces()
494 task->nr, task->comm, task->pid, task->nr_events); in print_task_traces()
503 for (i = 0; i < sched->nr_tasks; i++) { in add_cross_task_wakeups()
504 task1 = sched->tasks[i]; in add_cross_task_wakeups()
506 if (j == sched->nr_tasks) in add_cross_task_wakeups()
508 task2 = sched->tasks[j]; in add_cross_task_wakeups()
518 switch (atom->type) { in perf_sched__process_event()
520 burn_nsecs(sched, atom->duration); in perf_sched__process_event()
523 if (atom->wait_sem) in perf_sched__process_event()
524 ret = sem_wait(atom->wait_sem); in perf_sched__process_event()
528 if (atom->wait_sem) in perf_sched__process_event()
529 ret = sem_post(atom->wait_sem); in perf_sched__process_event()
568 fd = sys_perf_event_open(&attr, 0, -1, -1, in self_open_counters()
573 if (sched->force) { in self_open_counters()
574 BUG_ON(getrlimit(RLIMIT_NOFILE, &limit) == -1); in self_open_counters()
575 limit.rlim_cur += sched->nr_tasks - cur_task; in self_open_counters()
580 if (setrlimit(RLIMIT_NOFILE, &limit) == -1) { in self_open_counters()
586 strcpy(info, "Have a try with -f option\n"); in self_open_counters()
616 struct task_desc *this_task = parms->task; in thread_func()
617 struct perf_sched *sched = parms->sched; in thread_func()
621 int fd = parms->fd; in thread_func()
625 sprintf(comm2, ":%s", this_task->comm); in thread_func()
630 while (!sched->thread_funcs_exit) { in thread_func()
631 ret = sem_post(&this_task->ready_for_work); in thread_func()
633 mutex_lock(&sched->start_work_mutex); in thread_func()
634 mutex_unlock(&sched->start_work_mutex); in thread_func()
638 for (i = 0; i < this_task->nr_events; i++) { in thread_func()
639 this_task->curr_event = i; in thread_func()
640 perf_sched__process_event(sched, this_task->atoms[i]); in thread_func()
644 this_task->cpu_usage = cpu_usage_1 - cpu_usage_0; in thread_func()
645 ret = sem_post(&this_task->work_done_sem); in thread_func()
648 mutex_lock(&sched->work_done_wait_mutex); in thread_func()
649 mutex_unlock(&sched->work_done_wait_mutex); in thread_func()
655 EXCLUSIVE_LOCK_FUNCTION(sched->start_work_mutex) in create_tasks()
656 EXCLUSIVE_LOCK_FUNCTION(sched->work_done_wait_mutex) in create_tasks()
668 mutex_lock(&sched->start_work_mutex); in create_tasks()
669 mutex_lock(&sched->work_done_wait_mutex); in create_tasks()
670 for (i = 0; i < sched->nr_tasks; i++) { in create_tasks()
673 parms->task = task = sched->tasks[i]; in create_tasks()
674 parms->sched = sched; in create_tasks()
675 parms->fd = self_open_counters(sched, i); in create_tasks()
676 sem_init(&task->sleep_sem, 0, 0); in create_tasks()
677 sem_init(&task->ready_for_work, 0, 0); in create_tasks()
678 sem_init(&task->work_done_sem, 0, 0); in create_tasks()
679 task->curr_event = 0; in create_tasks()
680 err = pthread_create(&task->thread, &attr, thread_func, parms); in create_tasks()
686 UNLOCK_FUNCTION(sched->start_work_mutex) in destroy_tasks()
687 UNLOCK_FUNCTION(sched->work_done_wait_mutex) in destroy_tasks()
693 mutex_unlock(&sched->start_work_mutex); in destroy_tasks()
694 mutex_unlock(&sched->work_done_wait_mutex); in destroy_tasks()
696 for (i = 0; i < sched->nr_tasks; i++) { in destroy_tasks()
697 task = sched->tasks[i]; in destroy_tasks()
698 err = pthread_join(task->thread, NULL); in destroy_tasks()
700 sem_destroy(&task->sleep_sem); in destroy_tasks()
701 sem_destroy(&task->ready_for_work); in destroy_tasks()
702 sem_destroy(&task->work_done_sem); in destroy_tasks()
707 EXCLUSIVE_LOCKS_REQUIRED(sched->work_done_wait_mutex) in wait_for_tasks()
708 EXCLUSIVE_LOCKS_REQUIRED(sched->start_work_mutex) in wait_for_tasks()
714 sched->start_time = get_nsecs(); in wait_for_tasks()
715 sched->cpu_usage = 0; in wait_for_tasks()
716 mutex_unlock(&sched->work_done_wait_mutex); in wait_for_tasks()
718 for (i = 0; i < sched->nr_tasks; i++) { in wait_for_tasks()
719 task = sched->tasks[i]; in wait_for_tasks()
720 ret = sem_wait(&task->ready_for_work); in wait_for_tasks()
722 sem_init(&task->ready_for_work, 0, 0); in wait_for_tasks()
724 mutex_lock(&sched->work_done_wait_mutex); in wait_for_tasks()
728 mutex_unlock(&sched->start_work_mutex); in wait_for_tasks()
730 for (i = 0; i < sched->nr_tasks; i++) { in wait_for_tasks()
731 task = sched->tasks[i]; in wait_for_tasks()
732 ret = sem_wait(&task->work_done_sem); in wait_for_tasks()
734 sem_init(&task->work_done_sem, 0, 0); in wait_for_tasks()
735 sched->cpu_usage += task->cpu_usage; in wait_for_tasks()
736 task->cpu_usage = 0; in wait_for_tasks()
740 if (!sched->runavg_cpu_usage) in wait_for_tasks()
741 sched->runavg_cpu_usage = sched->cpu_usage; in wait_for_tasks()
742 …sched->runavg_cpu_usage = (sched->runavg_cpu_usage * (sched->replay_repeat - 1) + sched->cpu_usage… in wait_for_tasks()
744 sched->parent_cpu_usage = cpu_usage_1 - cpu_usage_0; in wait_for_tasks()
745 if (!sched->runavg_parent_cpu_usage) in wait_for_tasks()
746 sched->runavg_parent_cpu_usage = sched->parent_cpu_usage; in wait_for_tasks()
747 sched->runavg_parent_cpu_usage = (sched->runavg_parent_cpu_usage * (sched->replay_repeat - 1) + in wait_for_tasks()
748 sched->parent_cpu_usage)/sched->replay_repeat; in wait_for_tasks()
750 mutex_lock(&sched->start_work_mutex); in wait_for_tasks()
752 for (i = 0; i < sched->nr_tasks; i++) { in wait_for_tasks()
753 task = sched->tasks[i]; in wait_for_tasks()
754 sem_init(&task->sleep_sem, 0, 0); in wait_for_tasks()
755 task->curr_event = 0; in wait_for_tasks()
760 EXCLUSIVE_LOCKS_REQUIRED(sched->work_done_wait_mutex) in run_one_test()
761 EXCLUSIVE_LOCKS_REQUIRED(sched->start_work_mutex) in run_one_test()
769 delta = T1 - T0; in run_one_test()
770 sched->sum_runtime += delta; in run_one_test()
771 sched->nr_runs++; in run_one_test()
773 avg_delta = sched->sum_runtime / sched->nr_runs; in run_one_test()
775 fluct = avg_delta - delta; in run_one_test()
777 fluct = delta - avg_delta; in run_one_test()
778 sched->sum_fluct += fluct; in run_one_test()
779 if (!sched->run_avg) in run_one_test()
780 sched->run_avg = delta; in run_one_test()
781 sched->run_avg = (sched->run_avg * (sched->replay_repeat - 1) + delta) / sched->replay_repeat; in run_one_test()
783 printf("#%-3ld: %0.3f, ", sched->nr_runs, (double)delta / NSEC_PER_MSEC); in run_one_test()
785 printf("ravg: %0.2f, ", (double)sched->run_avg / NSEC_PER_MSEC); in run_one_test()
788 (double)sched->cpu_usage / NSEC_PER_MSEC, (double)sched->runavg_cpu_usage / NSEC_PER_MSEC); in run_one_test()
793 * accurate than the sched->sum_exec_runtime based statistics: in run_one_test()
796 (double)sched->parent_cpu_usage / NSEC_PER_MSEC, in run_one_test()
797 (double)sched->runavg_parent_cpu_usage / NSEC_PER_MSEC); in run_one_test()
802 if (sched->nr_sleep_corrections) in run_one_test()
803 printf(" (%ld sleep corrections)\n", sched->nr_sleep_corrections); in run_one_test()
804 sched->nr_sleep_corrections = 0; in run_one_test()
815 printf("the run test took %" PRIu64 " nsecs\n", T1 - T0); in test_calibrations()
821 printf("the sleep test took %" PRIu64 " nsecs\n", T1 - T0); in test_calibrations()
826 struct evsel *evsel, struct perf_sample *sample, in replay_wakeup_event() argument
829 const char *comm = evsel__strval(evsel, sample, "comm"); in replay_wakeup_event()
830 const u32 pid = evsel__intval(evsel, sample, "pid"); in replay_wakeup_event()
836 printf(" ... pid %d woke up %s/%d\n", sample->tid, comm, pid); in replay_wakeup_event()
839 waker = register_pid(sched, sample->tid, "<unknown>"); in replay_wakeup_event()
842 add_sched_event_wakeup(sched, waker, sample->time, wakee); in replay_wakeup_event()
848 struct perf_sample *sample, in replay_switch_event() argument
851 const char *prev_comm = evsel__strval(evsel, sample, "prev_comm"), in replay_switch_event()
852 *next_comm = evsel__strval(evsel, sample, "next_comm"); in replay_switch_event()
853 const u32 prev_pid = evsel__intval(evsel, sample, "prev_pid"), in replay_switch_event()
854 next_pid = evsel__intval(evsel, sample, "next_pid"); in replay_switch_event()
855 const char prev_state = evsel__taskstate(evsel, sample, "prev_state"); in replay_switch_event()
857 u64 timestamp0, timestamp = sample->time; in replay_switch_event()
858 int cpu = sample->cpu; in replay_switch_event()
867 timestamp0 = sched->cpu_last_switched[cpu]; in replay_switch_event()
869 delta = timestamp - timestamp0; in replay_switch_event()
875 return -1; in replay_switch_event()
884 sched->cpu_last_switched[cpu] = timestamp; in replay_switch_event()
898 child = machine__findnew_thread(machine, event->fork.pid, in replay_fork_event()
899 event->fork.tid); in replay_fork_event()
900 parent = machine__findnew_thread(machine, event->fork.ppid, in replay_fork_event()
901 event->fork.ptid); in replay_fork_event()
931 r->prio = -1; in init_prio()
945 init_stats(&r->run_stats); in thread__init_runtime()
975 ret = sort->cmp(l, r); in thread_lat_cmp()
987 struct rb_node *node = root->rb_root.rb_node; in thread_atoms_search()
998 node = node->rb_left; in thread_atoms_search()
1000 node = node->rb_right; in thread_atoms_search()
1002 BUG_ON(thread != atoms->thread); in thread_atoms_search()
1013 struct rb_node **new = &(root->rb_root.rb_node), *parent = NULL; in __thread_latency_insert()
1026 new = &((*new)->rb_left); in __thread_latency_insert()
1028 new = &((*new)->rb_right); in __thread_latency_insert()
1033 rb_link_node(&data->node, parent, new); in __thread_latency_insert()
1034 rb_insert_color_cached(&data->node, root, leftmost); in __thread_latency_insert()
1042 return -1; in thread_atoms_insert()
1045 atoms->thread = thread__get(thread); in thread_atoms_insert()
1046 INIT_LIST_HEAD(&atoms->work_list); in thread_atoms_insert()
1047 __thread_latency_insert(&sched->atom_root, atoms, &sched->cmp_pid); in thread_atoms_insert()
1059 return -1; in add_sched_out_event()
1062 atom->sched_out_time = timestamp; in add_sched_out_event()
1065 atom->state = THREAD_WAIT_CPU; in add_sched_out_event()
1066 atom->wake_up_time = atom->sched_out_time; in add_sched_out_event()
1069 list_add_tail(&atom->list, &atoms->work_list); in add_sched_out_event()
1079 BUG_ON(list_empty(&atoms->work_list)); in add_runtime_event()
1081 atom = list_entry(atoms->work_list.prev, struct work_atom, list); in add_runtime_event()
1083 atom->runtime += delta; in add_runtime_event()
1084 atoms->total_runtime += delta; in add_runtime_event()
1093 if (list_empty(&atoms->work_list)) in add_sched_in_event()
1096 atom = list_entry(atoms->work_list.prev, struct work_atom, list); in add_sched_in_event()
1098 if (atom->state != THREAD_WAIT_CPU) in add_sched_in_event()
1101 if (timestamp < atom->wake_up_time) { in add_sched_in_event()
1102 atom->state = THREAD_IGNORE; in add_sched_in_event()
1106 atom->state = THREAD_SCHED_IN; in add_sched_in_event()
1107 atom->sched_in_time = timestamp; in add_sched_in_event()
1109 delta = atom->sched_in_time - atom->wake_up_time; in add_sched_in_event()
1110 atoms->total_lat += delta; in add_sched_in_event()
1111 if (delta > atoms->max_lat) { in add_sched_in_event()
1112 atoms->max_lat = delta; in add_sched_in_event()
1113 atoms->max_lat_start = atom->wake_up_time; in add_sched_in_event()
1114 atoms->max_lat_end = timestamp; in add_sched_in_event()
1116 atoms->nb_atoms++; in add_sched_in_event()
1121 struct perf_sample *sample, in latency_switch_event() argument
1124 const u32 prev_pid = evsel__intval(evsel, sample, "prev_pid"), in latency_switch_event()
1125 next_pid = evsel__intval(evsel, sample, "next_pid"); in latency_switch_event()
1126 const char prev_state = evsel__taskstate(evsel, sample, "prev_state"); in latency_switch_event()
1129 u64 timestamp0, timestamp = sample->time; in latency_switch_event()
1130 int cpu = sample->cpu, err = -1; in latency_switch_event()
1135 timestamp0 = sched->cpu_last_switched[cpu]; in latency_switch_event()
1136 sched->cpu_last_switched[cpu] = timestamp; in latency_switch_event()
1138 delta = timestamp - timestamp0; in latency_switch_event()
1144 return -1; in latency_switch_event()
1147 sched_out = machine__findnew_thread(machine, -1, prev_pid); in latency_switch_event()
1148 sched_in = machine__findnew_thread(machine, -1, next_pid); in latency_switch_event()
1152 out_events = thread_atoms_search(&sched->atom_root, sched_out, &sched->cmp_pid); in latency_switch_event()
1156 out_events = thread_atoms_search(&sched->atom_root, sched_out, &sched->cmp_pid); in latency_switch_event()
1158 pr_err("out-event: Internal tree error"); in latency_switch_event()
1163 return -1; in latency_switch_event()
1165 in_events = thread_atoms_search(&sched->atom_root, sched_in, &sched->cmp_pid); in latency_switch_event()
1169 in_events = thread_atoms_search(&sched->atom_root, sched_in, &sched->cmp_pid); in latency_switch_event()
1171 pr_err("in-event: Internal tree error"); in latency_switch_event()
1191 struct perf_sample *sample, in latency_runtime_event() argument
1194 const u32 pid = evsel__intval(evsel, sample, "pid"); in latency_runtime_event()
1195 const u64 runtime = evsel__intval(evsel, sample, "runtime"); in latency_runtime_event()
1196 struct thread *thread = machine__findnew_thread(machine, -1, pid); in latency_runtime_event()
1197 struct work_atoms *atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid); in latency_runtime_event()
1198 u64 timestamp = sample->time; in latency_runtime_event()
1199 int cpu = sample->cpu, err = -1; in latency_runtime_event()
1202 return -1; in latency_runtime_event()
1208 atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid); in latency_runtime_event()
1210 pr_err("in-event: Internal tree error"); in latency_runtime_event()
1226 struct perf_sample *sample, in latency_wakeup_event() argument
1229 const u32 pid = evsel__intval(evsel, sample, "pid"); in latency_wakeup_event()
1233 u64 timestamp = sample->time; in latency_wakeup_event()
1234 int err = -1; in latency_wakeup_event()
1236 wakee = machine__findnew_thread(machine, -1, pid); in latency_wakeup_event()
1238 return -1; in latency_wakeup_event()
1239 atoms = thread_atoms_search(&sched->atom_root, wakee, &sched->cmp_pid); in latency_wakeup_event()
1243 atoms = thread_atoms_search(&sched->atom_root, wakee, &sched->cmp_pid); in latency_wakeup_event()
1245 pr_err("wakeup-event: Internal tree error"); in latency_wakeup_event()
1252 BUG_ON(list_empty(&atoms->work_list)); in latency_wakeup_event()
1254 atom = list_entry(atoms->work_list.prev, struct work_atom, list); in latency_wakeup_event()
1259 * on run queue and wakeup only change ->state to TASK_RUNNING, in latency_wakeup_event()
1260 * then we should not set the ->wake_up_time when wake up a in latency_wakeup_event()
1267 if (sched->profile_cpu == -1 && atom->state != THREAD_SLEEPING) in latency_wakeup_event()
1270 sched->nr_timestamps++; in latency_wakeup_event()
1271 if (atom->sched_out_time > timestamp) { in latency_wakeup_event()
1272 sched->nr_unordered_timestamps++; in latency_wakeup_event()
1276 atom->state = THREAD_WAIT_CPU; in latency_wakeup_event()
1277 atom->wake_up_time = timestamp; in latency_wakeup_event()
1287 struct perf_sample *sample, in latency_migrate_task_event() argument
1290 const u32 pid = evsel__intval(evsel, sample, "pid"); in latency_migrate_task_event()
1291 u64 timestamp = sample->time; in latency_migrate_task_event()
1295 int err = -1; in latency_migrate_task_event()
1300 if (sched->profile_cpu == -1) in latency_migrate_task_event()
1303 migrant = machine__findnew_thread(machine, -1, pid); in latency_migrate_task_event()
1305 return -1; in latency_migrate_task_event()
1306 atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid); in latency_migrate_task_event()
1311 atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid); in latency_migrate_task_event()
1313 pr_err("migration-event: Internal tree error"); in latency_migrate_task_event()
1320 BUG_ON(list_empty(&atoms->work_list)); in latency_migrate_task_event()
1322 atom = list_entry(atoms->work_list.prev, struct work_atom, list); in latency_migrate_task_event()
1323 atom->sched_in_time = atom->sched_out_time = atom->wake_up_time = timestamp; in latency_migrate_task_event()
1325 sched->nr_timestamps++; in latency_migrate_task_event()
1327 if (atom->sched_out_time > timestamp) in latency_migrate_task_event()
1328 sched->nr_unordered_timestamps++; in latency_migrate_task_event()
1342 if (!work_list->nb_atoms) in output_lat_thread()
1347 if (!strcmp(thread__comm_str(work_list->thread), "swapper")) in output_lat_thread()
1350 sched->all_runtime += work_list->total_runtime; in output_lat_thread()
1351 sched->all_count += work_list->nb_atoms; in output_lat_thread()
1353 if (work_list->num_merged > 1) { in output_lat_thread()
1354 ret = printf(" %s:(%d) ", thread__comm_str(work_list->thread), in output_lat_thread()
1355 work_list->num_merged); in output_lat_thread()
1357 ret = printf(" %s:%d ", thread__comm_str(work_list->thread), in output_lat_thread()
1358 thread__tid(work_list->thread)); in output_lat_thread()
1361 for (i = 0; i < 24 - ret; i++) in output_lat_thread()
1364 avg = work_list->total_lat / work_list->nb_atoms; in output_lat_thread()
1365 timestamp__scnprintf_usec(work_list->max_lat_start, max_lat_start, sizeof(max_lat_start)); in output_lat_thread()
1366 timestamp__scnprintf_usec(work_list->max_lat_end, max_lat_end, sizeof(max_lat_end)); in output_lat_thread()
1369 (double)work_list->total_runtime / NSEC_PER_MSEC, in output_lat_thread()
1370 work_list->nb_atoms, (double)avg / NSEC_PER_MSEC, in output_lat_thread()
1371 (double)work_list->max_lat / NSEC_PER_MSEC, in output_lat_thread()
1379 if (RC_CHK_EQUAL(l->thread, r->thread)) in pid_cmp()
1381 l_tid = thread__tid(l->thread); in pid_cmp()
1382 r_tid = thread__tid(r->thread); in pid_cmp()
1384 return -1; in pid_cmp()
1387 return (int)(RC_CHK_ACCESS(l->thread) - RC_CHK_ACCESS(r->thread)); in pid_cmp()
1394 if (!l->nb_atoms) in avg_cmp()
1395 return -1; in avg_cmp()
1397 if (!r->nb_atoms) in avg_cmp()
1400 avgl = l->total_lat / l->nb_atoms; in avg_cmp()
1401 avgr = r->total_lat / r->nb_atoms; in avg_cmp()
1404 return -1; in avg_cmp()
1413 if (l->max_lat < r->max_lat) in max_cmp()
1414 return -1; in max_cmp()
1415 if (l->max_lat > r->max_lat) in max_cmp()
1423 if (l->nb_atoms < r->nb_atoms) in switch_cmp()
1424 return -1; in switch_cmp()
1425 if (l->nb_atoms > r->nb_atoms) in switch_cmp()
1433 if (l->total_runtime < r->total_runtime) in runtime_cmp()
1434 return -1; in runtime_cmp()
1435 if (l->total_runtime > r->total_runtime) in runtime_cmp()
1473 if (!strcmp(available_sorts[i]->name, tok)) { in sort_dimension__add()
1474 list_add_tail(&available_sorts[i]->list, list); in sort_dimension__add()
1480 return -1; in sort_dimension__add()
1486 struct rb_root_cached *root = &sched->atom_root; in perf_sched__sort_lat()
1496 __thread_latency_insert(&sched->sorted_atom_root, data, &sched->sort_list); in perf_sched__sort_lat()
1498 if (root == &sched->atom_root) { in perf_sched__sort_lat()
1499 root = &sched->merged_atom_root; in perf_sched__sort_lat()
1506 struct perf_sample *sample, in process_sched_wakeup_event() argument
1511 if (sched->tp_handler->wakeup_event) in process_sched_wakeup_event()
1512 return sched->tp_handler->wakeup_event(sched, evsel, sample, machine); in process_sched_wakeup_event()
1519 struct perf_sample *sample __maybe_unused, in process_sched_wakeup_ignore()
1547 if (!sched->map.color_pids || !thread || thread__priv(thread)) in map__findnew_thread()
1550 if (thread_map__has(sched->map.color_pids, tid)) in map__findnew_thread()
1559 bool fuzzy_match = sched->map.fuzzy; in sched_match_task()
1560 struct strlist *task_names = sched->map.task_names; in sched_match_task()
1564 bool match_found = fuzzy_match ? !!strstr(comm_str, node->s) : in sched_match_task()
1565 !strcmp(comm_str, node->s); in sched_match_task()
1578 .cpu = sched->map.comp ? sched->map.comp_cpus[i].cpu : i, in print_sched_map()
1580 struct thread *curr_thread = sched->curr_thread[cpu.cpu]; in print_sched_map()
1581 struct thread *curr_out_thread = sched->curr_out_thread[cpu.cpu]; in print_sched_map()
1591 if (sched->map.color_cpus && perf_cpu_map__has(sched->map.color_cpus, cpu)) in print_sched_map()
1599 thread_to_check = sched_out ? sched->curr_out_thread[cpu.cpu] : in print_sched_map()
1600 sched->curr_thread[cpu.cpu]; in print_sched_map()
1609 color_fprintf(stdout, color, "- "); in print_sched_map()
1611 curr_tr = thread__get_runtime(sched->curr_thread[cpu.cpu]); in print_sched_map()
1614 curr_tr->shortname); in print_sched_map()
1617 color_fprintf(stdout, pid_color, "%2s ", curr_tr->shortname); in print_sched_map()
1624 struct perf_sample *sample, struct machine *machine) in map_switch_event() argument
1626 const u32 next_pid = evsel__intval(evsel, sample, "next_pid"); in map_switch_event()
1627 const u32 prev_pid = evsel__intval(evsel, sample, "prev_pid"); in map_switch_event()
1631 u64 timestamp0, timestamp = sample->time; in map_switch_event()
1634 .cpu = sample->cpu, in map_switch_event()
1645 if (this_cpu.cpu > sched->max_cpu.cpu) in map_switch_event()
1646 sched->max_cpu = this_cpu; in map_switch_event()
1648 if (sched->map.comp) { in map_switch_event()
1649 cpus_nr = bitmap_weight(sched->map.comp_cpus_mask, MAX_CPUS); in map_switch_event()
1650 if (!__test_and_set_bit(this_cpu.cpu, sched->map.comp_cpus_mask)) { in map_switch_event()
1651 sched->map.comp_cpus[cpus_nr++] = this_cpu; in map_switch_event()
1655 cpus_nr = sched->max_cpu.cpu; in map_switch_event()
1657 timestamp0 = sched->cpu_last_switched[this_cpu.cpu]; in map_switch_event()
1658 sched->cpu_last_switched[this_cpu.cpu] = timestamp; in map_switch_event()
1660 delta = timestamp - timestamp0; in map_switch_event()
1666 return -1; in map_switch_event()
1669 sched_in = map__findnew_thread(sched, machine, -1, next_pid); in map_switch_event()
1670 sched_out = map__findnew_thread(sched, machine, -1, prev_pid); in map_switch_event()
1672 return -1; in map_switch_event()
1677 return -1; in map_switch_event()
1680 sched->curr_thread[this_cpu.cpu] = thread__get(sched_in); in map_switch_event()
1681 sched->curr_out_thread[this_cpu.cpu] = thread__get(sched_out); in map_switch_event()
1685 if (!tr->shortname[0]) { in map_switch_event()
1688 * Don't allocate a letter-number for swapper:0 in map_switch_event()
1691 tr->shortname[0] = '.'; in map_switch_event()
1692 tr->shortname[1] = ' '; in map_switch_event()
1693 } else if (!sched->map.task_name || sched_match_task(sched, str)) { in map_switch_event()
1694 tr->shortname[0] = sched->next_shortname1; in map_switch_event()
1695 tr->shortname[1] = sched->next_shortname2; in map_switch_event()
1697 if (sched->next_shortname1 < 'Z') { in map_switch_event()
1698 sched->next_shortname1++; in map_switch_event()
1700 sched->next_shortname1 = 'A'; in map_switch_event()
1701 if (sched->next_shortname2 < '9') in map_switch_event()
1702 sched->next_shortname2++; in map_switch_event()
1704 sched->next_shortname2 = '0'; in map_switch_event()
1707 tr->shortname[0] = '-'; in map_switch_event()
1708 tr->shortname[1] = ' '; in map_switch_event()
1713 if (sched->map.cpus && !perf_cpu_map__has(sched->map.cpus, this_cpu)) in map_switch_event()
1719 * Check which of sched_in and sched_out matches the passed --task-name in map_switch_event()
1722 if (sched->map.task_name && !sched_match_task(sched, str)) { in map_switch_event()
1730 if (!(sched->map.task_name && !sched_match_task(sched, str))) in map_switch_event()
1740 if (new_shortname || tr->comm_changed || (verbose > 0 && thread__tid(sched_in))) { in map_switch_event()
1747 tr->shortname, thread__comm_str(sched_in), thread__tid(sched_in)); in map_switch_event()
1748 tr->comm_changed = false; in map_switch_event()
1751 if (sched->map.comp && new_cpu) in map_switch_event()
1760 if (sched->map.task_name) { in map_switch_event()
1761 tr = thread__get_runtime(sched->curr_out_thread[this_cpu.cpu]); in map_switch_event()
1762 if (strcmp(tr->shortname, "") == 0) in map_switch_event()
1777 if (sched->map.task_name) in map_switch_event()
1787 struct perf_sample *sample, in process_sched_switch_event() argument
1791 int this_cpu = sample->cpu, err = 0; in process_sched_switch_event()
1792 u32 prev_pid = evsel__intval(evsel, sample, "prev_pid"), in process_sched_switch_event()
1793 next_pid = evsel__intval(evsel, sample, "next_pid"); in process_sched_switch_event()
1795 if (sched->curr_pid[this_cpu] != (u32)-1) { in process_sched_switch_event()
1800 if (sched->curr_pid[this_cpu] != prev_pid) in process_sched_switch_event()
1801 sched->nr_context_switch_bugs++; in process_sched_switch_event()
1804 if (sched->tp_handler->switch_event) in process_sched_switch_event()
1805 err = sched->tp_handler->switch_event(sched, evsel, sample, machine); in process_sched_switch_event()
1807 sched->curr_pid[this_cpu] = next_pid; in process_sched_switch_event()
1813 struct perf_sample *sample, in process_sched_runtime_event() argument
1818 if (sched->tp_handler->runtime_event) in process_sched_runtime_event()
1819 return sched->tp_handler->runtime_event(sched, evsel, sample, machine); in process_sched_runtime_event()
1826 struct perf_sample *sample, in perf_sched__process_fork_event() argument
1832 perf_event__process_fork(tool, event, sample, machine); in perf_sched__process_fork_event()
1835 if (sched->tp_handler->fork_event) in perf_sched__process_fork_event()
1836 return sched->tp_handler->fork_event(sched, event, machine); in perf_sched__process_fork_event()
1843 struct perf_sample *sample, in process_sched_migrate_task_event() argument
1848 if (sched->tp_handler->migrate_task_event) in process_sched_migrate_task_event()
1849 return sched->tp_handler->migrate_task_event(sched, evsel, sample, machine); in process_sched_migrate_task_event()
1856 struct perf_sample *sample,
1861 struct perf_sample *sample, in perf_sched__process_tracepoint_sample() argument
1867 if (evsel->handler != NULL) { in perf_sched__process_tracepoint_sample()
1868 tracepoint_handler f = evsel->handler; in perf_sched__process_tracepoint_sample()
1869 err = f(tool, evsel, sample, machine); in perf_sched__process_tracepoint_sample()
1877 struct perf_sample *sample, in perf_sched__process_comm() argument
1884 err = perf_event__process_comm(tool, event, sample, machine); in perf_sched__process_comm()
1888 thread = machine__find_thread(machine, sample->pid, sample->tid); in perf_sched__process_comm()
1891 return -1; in perf_sched__process_comm()
1897 return -1; in perf_sched__process_comm()
1900 tr->comm_changed = true; in perf_sched__process_comm()
1920 .force = sched->force, in perf_sched__read_events()
1922 int rc = -1; in perf_sched__read_events()
1924 session = perf_session__new(&data, &sched->tool); in perf_sched__read_events()
1930 symbol__init(&session->header.env); in perf_sched__read_events()
1933 if (evlist__find_tracepoint_by_name(session->evlist, "sched:sched_waking")) in perf_sched__read_events()
1939 if (perf_session__has_traces(session, "record -R")) { in perf_sched__read_events()
1946 sched->nr_events = session->evlist->stats.nr_events[0]; in perf_sched__read_events()
1947 sched->nr_lost_events = session->evlist->stats.total_lost; in perf_sched__read_events()
1948 sched->nr_lost_chunks = session->evlist->stats.nr_events[PERF_RECORD_LOST]; in perf_sched__read_events()
1966 nsecs -= msecs * NSEC_PER_MSEC; in print_sched_time()
1973 * first time it is used.
1977 struct evsel_runtime *r = evsel->priv; in evsel__get_runtime()
1981 evsel->priv = r; in evsel__get_runtime()
1988 * save last time event was seen per cpu
1997 if ((cpu >= r->ncpu) || (r->last_time == NULL)) { in evsel__save_time()
1999 void *p = r->last_time; in evsel__save_time()
2001 p = realloc(r->last_time, n * sizeof(u64)); in evsel__save_time()
2005 r->last_time = p; in evsel__save_time()
2006 for (i = r->ncpu; i < n; ++i) in evsel__save_time()
2007 r->last_time[i] = (u64) 0; in evsel__save_time()
2009 r->ncpu = n; in evsel__save_time()
2012 r->last_time[cpu] = timestamp; in evsel__save_time()
2015 /* returns last time this event was seen on the given cpu */
2020 if ((r == NULL) || (r->last_time == NULL) || (cpu >= r->ncpu)) in evsel__get_time()
2023 return r->last_time[cpu]; in evsel__get_time()
2051 /* prio field format: xxx or xxx->yyy */
2055 struct perf_sample *sample) in timehist_get_priostr() argument
2058 int prev_prio = (int)evsel__intval(evsel, sample, "prev_prio"); in timehist_get_priostr()
2061 if (tr->prio != prev_prio && tr->prio != -1) in timehist_get_priostr()
2062 scnprintf(prio_str, sizeof(prio_str), "%d->%d", tr->prio, prev_prio); in timehist_get_priostr()
2071 u32 ncpus = sched->max_cpu.cpu + 1; in timehist_header()
2074 printf("%15s %6s ", "time", "cpu"); in timehist_header()
2076 if (sched->show_cpu_visual) { in timehist_header()
2086 if (sched->show_prio) { in timehist_header()
2087 printf(" %-*s %-*s %9s %9s %9s", in timehist_header()
2089 "wait time", "sch delay", "run time"); in timehist_header()
2091 printf(" %-*s %9s %9s %9s", comm_width, in timehist_header()
2092 "task name", "wait time", "sch delay", "run time"); in timehist_header()
2095 if (sched->show_state) in timehist_header()
2103 printf("%15s %-6s ", "", ""); in timehist_header()
2105 if (sched->show_cpu_visual) in timehist_header()
2108 if (sched->show_prio) { in timehist_header()
2109 printf(" %-*s %-*s %9s %9s %9s", in timehist_header()
2113 printf(" %-*s %9s %9s %9s", comm_width, in timehist_header()
2117 if (sched->show_state) in timehist_header()
2127 if (sched->show_cpu_visual) in timehist_header()
2130 if (sched->show_prio) { in timehist_header()
2140 if (sched->show_state) in timehist_header()
2148 struct perf_sample *sample, in timehist_print_sample() argument
2154 const char *next_comm = evsel__strval(evsel, sample, "next_comm"); in timehist_print_sample()
2155 const u32 next_pid = evsel__intval(evsel, sample, "next_pid"); in timehist_print_sample()
2156 u32 max_cpus = sched->max_cpu.cpu + 1; in timehist_print_sample()
2161 if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) in timehist_print_sample()
2165 printf("%15s [%04d] ", tstr, sample->cpu); in timehist_print_sample()
2167 if (sched->show_cpu_visual) { in timehist_print_sample()
2174 if (i == sample->cpu) in timehist_print_sample()
2183 printf(" %-*s ", comm_width, timehist_get_commstr(thread)); in timehist_print_sample()
2185 if (sched->show_prio) in timehist_print_sample()
2186 printf(" %-*s ", MAX_PRIO_STR_LEN, timehist_get_priostr(evsel, thread, sample)); in timehist_print_sample()
2188 wait_time = tr->dt_sleep + tr->dt_iowait + tr->dt_preempt; in timehist_print_sample()
2191 print_sched_time(tr->dt_delay, 6); in timehist_print_sample()
2192 print_sched_time(tr->dt_run, 6); in timehist_print_sample()
2194 if (sched->show_state) in timehist_print_sample()
2197 if (sched->show_next) { in timehist_print_sample()
2199 printf(" %-*s", comm_width, nstr); in timehist_print_sample()
2202 if (sched->show_wakeups && !sched->show_next) in timehist_print_sample()
2203 printf(" %-*s", comm_width, ""); in timehist_print_sample()
2208 if (sched->show_callchain) in timehist_print_sample()
2211 sample__fprintf_sym(sample, al, 0, in timehist_print_sample()
2222 * Explanation of delta-time stats:
2224 * t = time of current schedule out event
2225 * tprev = time of previous sched out event
2226 * also time of schedule-in event for current task
2227 * last_time = time of last sched change event for current task
2228 * (i.e, time process was last scheduled out)
2229 * ready_to_run = time of wakeup for current task
2231 * -----|------------|------------|------------|------
2233 * time to run
2235 * |-------- dt_wait --------|
2236 * |- dt_delay -|-- dt_run --|
2238 * dt_run = run time of current task
2239 * dt_wait = time between last schedule out event for task and tprev
2240 * represents time spent off the cpu
2241 * dt_delay = time between wakeup and schedule-in of task
2247 r->dt_delay = 0; in timehist_update_runtime_stats()
2248 r->dt_sleep = 0; in timehist_update_runtime_stats()
2249 r->dt_iowait = 0; in timehist_update_runtime_stats()
2250 r->dt_preempt = 0; in timehist_update_runtime_stats()
2251 r->dt_run = 0; in timehist_update_runtime_stats()
2254 r->dt_run = t - tprev; in timehist_update_runtime_stats()
2255 if (r->ready_to_run) { in timehist_update_runtime_stats()
2256 if (r->ready_to_run > tprev) in timehist_update_runtime_stats()
2257 pr_debug("time travel: wakeup time for task > previous sched_switch event\n"); in timehist_update_runtime_stats()
2259 r->dt_delay = tprev - r->ready_to_run; in timehist_update_runtime_stats()
2262 if (r->last_time > tprev) in timehist_update_runtime_stats()
2263 pr_debug("time travel: last sched out time for task > previous sched_switch event\n"); in timehist_update_runtime_stats()
2264 else if (r->last_time) { in timehist_update_runtime_stats()
2265 u64 dt_wait = tprev - r->last_time; in timehist_update_runtime_stats()
2267 if (r->last_state == 'R') in timehist_update_runtime_stats()
2268 r->dt_preempt = dt_wait; in timehist_update_runtime_stats()
2269 else if (r->last_state == 'D') in timehist_update_runtime_stats()
2270 r->dt_iowait = dt_wait; in timehist_update_runtime_stats()
2272 r->dt_sleep = dt_wait; in timehist_update_runtime_stats()
2276 update_stats(&r->run_stats, r->dt_run); in timehist_update_runtime_stats()
2278 r->total_run_time += r->dt_run; in timehist_update_runtime_stats()
2279 r->total_delay_time += r->dt_delay; in timehist_update_runtime_stats()
2280 r->total_sleep_time += r->dt_sleep; in timehist_update_runtime_stats()
2281 r->total_iowait_time += r->dt_iowait; in timehist_update_runtime_stats()
2282 r->total_preempt_time += r->dt_preempt; in timehist_update_runtime_stats()
2285 static bool is_idle_sample(struct perf_sample *sample, in is_idle_sample() argument
2290 return evsel__intval(evsel, sample, "prev_pid") == 0; in is_idle_sample()
2292 return sample->pid == 0; in is_idle_sample()
2296 struct perf_sample *sample, in save_task_callchain() argument
2303 /* want main thread for process - has maps */ in save_task_callchain()
2304 thread = machine__findnew_thread(machine, sample->pid, sample->pid); in save_task_callchain()
2306 pr_debug("Failed to get thread for pid %d.\n", sample->pid); in save_task_callchain()
2310 if (!sched->show_callchain || sample->callchain == NULL) in save_task_callchain()
2315 if (thread__resolve_callchain(thread, cursor, evsel, sample, in save_task_callchain()
2316 NULL, NULL, sched->max_stack + 2) != 0) { in save_task_callchain()
2333 sym = node->ms.sym; in save_task_callchain()
2335 if (!strcmp(sym->name, "schedule") || in save_task_callchain()
2336 !strcmp(sym->name, "__schedule") || in save_task_callchain()
2337 !strcmp(sym->name, "preempt_schedule")) in save_task_callchain()
2338 sym->ignore = 1; in save_task_callchain()
2353 return -ENOMEM; in init_idle_thread()
2355 init_prio(&itr->tr); in init_idle_thread()
2356 init_stats(&itr->tr.run_stats); in init_idle_thread()
2357 callchain_init(&itr->callchain); in init_idle_thread()
2358 callchain_cursor_reset(&itr->cursor); in init_idle_thread()
2374 return -ENOMEM; in init_idle_threads()
2382 return -ENOMEM; in init_idle_threads()
2443 struct perf_sample *sample) in save_idle_callchain() argument
2447 if (!sched->show_callchain || sample->callchain == NULL) in save_idle_callchain()
2454 callchain_cursor__copy(&itr->cursor, cursor); in save_idle_callchain()
2458 struct perf_sample *sample, in timehist_get_thread() argument
2464 if (is_idle_sample(sample, evsel)) { in timehist_get_thread()
2465 thread = get_idle_thread(sample->cpu); in timehist_get_thread()
2467 pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu); in timehist_get_thread()
2470 /* there were samples with tid 0 but non-zero pid */ in timehist_get_thread()
2471 thread = machine__findnew_thread(machine, sample->pid, in timehist_get_thread()
2472 sample->tid ?: sample->pid); in timehist_get_thread()
2474 pr_debug("Failed to get thread for tid %d. skipping sample.\n", in timehist_get_thread()
2475 sample->tid); in timehist_get_thread()
2478 save_task_callchain(sched, sample, evsel, machine); in timehist_get_thread()
2479 if (sched->idle_hist) { in timehist_get_thread()
2483 idle = get_idle_thread(sample->cpu); in timehist_get_thread()
2485 pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu); in timehist_get_thread()
2493 itr->last_thread = thread; in timehist_get_thread()
2496 if (evsel__intval(evsel, sample, "next_pid") == 0) in timehist_get_thread()
2497 save_idle_callchain(sched, itr, sample); in timehist_get_thread()
2507 struct perf_sample *sample) in timehist_skip_sample() argument
2510 int prio = -1; in timehist_skip_sample()
2515 sched->skipped_samples++; in timehist_skip_sample()
2518 if (sched->prio_str) { in timehist_skip_sample()
2526 if (tr && tr->prio != -1) in timehist_skip_sample()
2527 prio = tr->prio; in timehist_skip_sample()
2529 prio = evsel__intval(evsel, sample, "prev_prio"); in timehist_skip_sample()
2531 if (prio != -1 && !test_bit(prio, sched->prio_bitmap)) { in timehist_skip_sample()
2533 sched->skipped_samples++; in timehist_skip_sample()
2537 if (sched->idle_hist) { in timehist_skip_sample()
2540 else if (evsel__intval(evsel, sample, "prev_pid") != 0 && in timehist_skip_sample()
2541 evsel__intval(evsel, sample, "next_pid") != 0) in timehist_skip_sample()
2550 struct perf_sample *sample, in timehist_print_wakeup_event() argument
2557 thread = machine__findnew_thread(machine, sample->pid, sample->tid); in timehist_print_wakeup_event()
2562 if (timehist_skip_sample(sched, thread, evsel, sample) && in timehist_print_wakeup_event()
2563 timehist_skip_sample(sched, awakened, evsel, sample)) { in timehist_print_wakeup_event()
2567 timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr)); in timehist_print_wakeup_event()
2568 printf("%15s [%04d] ", tstr, sample->cpu); in timehist_print_wakeup_event()
2569 if (sched->show_cpu_visual) in timehist_print_wakeup_event()
2570 printf(" %*s ", sched->max_cpu.cpu + 1, ""); in timehist_print_wakeup_event()
2572 printf(" %-*s ", comm_width, timehist_get_commstr(thread)); in timehist_print_wakeup_event()
2585 struct perf_sample *sample __maybe_unused, in timehist_sched_wakeup_ignore()
2594 struct perf_sample *sample, in timehist_sched_wakeup_event() argument
2600 /* want pid of awakened task not pid in sample */ in timehist_sched_wakeup_event()
2601 const u32 pid = evsel__intval(evsel, sample, "pid"); in timehist_sched_wakeup_event()
2605 return -1; in timehist_sched_wakeup_event()
2609 return -1; in timehist_sched_wakeup_event()
2611 if (tr->ready_to_run == 0) in timehist_sched_wakeup_event()
2612 tr->ready_to_run = sample->time; in timehist_sched_wakeup_event()
2615 if (sched->show_wakeups && in timehist_sched_wakeup_event()
2616 !perf_time__skip_sample(&sched->ptime, sample->time)) in timehist_sched_wakeup_event()
2617 timehist_print_wakeup_event(sched, evsel, sample, machine, thread); in timehist_sched_wakeup_event()
2624 struct perf_sample *sample, in timehist_print_migration_event() argument
2633 if (sched->summary_only) in timehist_print_migration_event()
2636 max_cpus = sched->max_cpu.cpu + 1; in timehist_print_migration_event()
2637 ocpu = evsel__intval(evsel, sample, "orig_cpu"); in timehist_print_migration_event()
2638 dcpu = evsel__intval(evsel, sample, "dest_cpu"); in timehist_print_migration_event()
2640 thread = machine__findnew_thread(machine, sample->pid, sample->tid); in timehist_print_migration_event()
2644 if (timehist_skip_sample(sched, thread, evsel, sample) && in timehist_print_migration_event()
2645 timehist_skip_sample(sched, migrated, evsel, sample)) { in timehist_print_migration_event()
2649 timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr)); in timehist_print_migration_event()
2650 printf("%15s [%04d] ", tstr, sample->cpu); in timehist_print_migration_event()
2652 if (sched->show_cpu_visual) { in timehist_print_migration_event()
2658 c = (i == sample->cpu) ? 'm' : ' '; in timehist_print_migration_event()
2664 printf(" %-*s ", comm_width, timehist_get_commstr(thread)); in timehist_print_migration_event()
2678 struct perf_sample *sample, in timehist_migrate_task_event() argument
2684 /* want pid of migrated task not pid in sample */ in timehist_migrate_task_event()
2685 const u32 pid = evsel__intval(evsel, sample, "pid"); in timehist_migrate_task_event()
2689 return -1; in timehist_migrate_task_event()
2693 return -1; in timehist_migrate_task_event()
2695 tr->migrations++; in timehist_migrate_task_event()
2698 timehist_print_migration_event(sched, evsel, sample, machine, thread); in timehist_migrate_task_event()
2704 struct perf_sample *sample, in timehist_update_task_prio() argument
2709 const u32 next_pid = evsel__intval(evsel, sample, "next_pid"); in timehist_update_task_prio()
2710 const u32 next_prio = evsel__intval(evsel, sample, "next_prio"); in timehist_update_task_prio()
2713 thread = get_idle_thread(sample->cpu); in timehist_update_task_prio()
2715 thread = machine__findnew_thread(machine, -1, next_pid); in timehist_update_task_prio()
2724 tr->prio = next_prio; in timehist_update_task_prio()
2730 struct perf_sample *sample, in timehist_sched_change_event() argument
2734 struct perf_time_interval *ptime = &sched->ptime; in timehist_sched_change_event()
2738 u64 tprev, t = sample->time; in timehist_sched_change_event()
2740 const char state = evsel__taskstate(evsel, sample, "prev_state"); in timehist_sched_change_event()
2743 if (machine__resolve(machine, &al, sample) < 0) { in timehist_sched_change_event()
2745 event->header.type); in timehist_sched_change_event()
2746 rc = -1; in timehist_sched_change_event()
2750 if (sched->show_prio || sched->prio_str) in timehist_sched_change_event()
2751 timehist_update_task_prio(evsel, sample, machine); in timehist_sched_change_event()
2753 thread = timehist_get_thread(sched, sample, machine, evsel); in timehist_sched_change_event()
2755 rc = -1; in timehist_sched_change_event()
2759 if (timehist_skip_sample(sched, thread, evsel, sample)) in timehist_sched_change_event()
2764 rc = -1; in timehist_sched_change_event()
2768 tprev = evsel__get_time(evsel, sample->cpu); in timehist_sched_change_event()
2771 * If start time given: in timehist_sched_change_event()
2772 * - sample time is under window user cares about - skip sample in timehist_sched_change_event()
2773 * - tprev is under window user cares about - reset to start of window in timehist_sched_change_event()
2775 if (ptime->start && ptime->start > t) in timehist_sched_change_event()
2778 if (tprev && ptime->start > tprev) in timehist_sched_change_event()
2779 tprev = ptime->start; in timehist_sched_change_event()
2782 * If end time given: in timehist_sched_change_event()
2783 * - previous sched event is out of window - we are done in timehist_sched_change_event()
2784 * - sample time is beyond window user cares about - reset it in timehist_sched_change_event()
2785 * to close out stats for time window interest in timehist_sched_change_event()
2786 * - If tprev is 0, that is, sched_in event for current task is in timehist_sched_change_event()
2788 * within time window interest - ignore it in timehist_sched_change_event()
2790 if (ptime->end) { in timehist_sched_change_event()
2791 if (!tprev || tprev > ptime->end) in timehist_sched_change_event()
2794 if (t > ptime->end) in timehist_sched_change_event()
2795 t = ptime->end; in timehist_sched_change_event()
2798 if (!sched->idle_hist || thread__tid(thread) == 0) { in timehist_sched_change_event()
2799 if (!cpu_list || test_bit(sample->cpu, cpu_bitmap)) in timehist_sched_change_event()
2802 if (sched->idle_hist) { in timehist_sched_change_event()
2806 if (itr->last_thread == NULL) in timehist_sched_change_event()
2809 /* add current idle time as last thread's runtime */ in timehist_sched_change_event()
2810 last_tr = thread__get_runtime(itr->last_thread); in timehist_sched_change_event()
2816 * remove delta time of last thread as it's not updated in timehist_sched_change_event()
2818 * time. we only care total run time and run stat. in timehist_sched_change_event()
2820 last_tr->dt_run = 0; in timehist_sched_change_event()
2821 last_tr->dt_delay = 0; in timehist_sched_change_event()
2822 last_tr->dt_sleep = 0; in timehist_sched_change_event()
2823 last_tr->dt_iowait = 0; in timehist_sched_change_event()
2824 last_tr->dt_preempt = 0; in timehist_sched_change_event()
2826 if (itr->cursor.nr) in timehist_sched_change_event()
2827 callchain_append(&itr->callchain, &itr->cursor, t - tprev); in timehist_sched_change_event()
2829 itr->last_thread = NULL; in timehist_sched_change_event()
2832 if (!sched->summary_only) in timehist_sched_change_event()
2833 timehist_print_sample(sched, evsel, sample, &al, thread, t, state); in timehist_sched_change_event()
2837 if (sched->hist_time.start == 0 && t >= ptime->start) in timehist_sched_change_event()
2838 sched->hist_time.start = t; in timehist_sched_change_event()
2839 if (ptime->end == 0 || t <= ptime->end) in timehist_sched_change_event()
2840 sched->hist_time.end = t; in timehist_sched_change_event()
2843 /* time of this sched_switch event becomes last time task seen */ in timehist_sched_change_event()
2844 tr->last_time = sample->time; in timehist_sched_change_event()
2846 /* last state is used to determine where to account wait time */ in timehist_sched_change_event()
2847 tr->last_state = state; in timehist_sched_change_event()
2849 /* sched out event for task so reset ready to run time */ in timehist_sched_change_event()
2851 tr->ready_to_run = t; in timehist_sched_change_event()
2853 tr->ready_to_run = 0; in timehist_sched_change_event()
2856 evsel__save_time(evsel, sample->time, sample->cpu); in timehist_sched_change_event()
2865 struct perf_sample *sample, in timehist_sched_switch_event() argument
2868 return timehist_sched_change_event(tool, event, evsel, sample, machine); in timehist_sched_switch_event()
2873 struct perf_sample *sample, in process_lost() argument
2878 timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr)); in process_lost()
2880 printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu); in process_lost()
2889 double mean = avg_stats(&r->run_stats); in print_thread_runtime()
2894 (u64) r->run_stats.n); in print_thread_runtime()
2896 print_sched_time(r->total_run_time, 8); in print_thread_runtime()
2897 stddev = rel_stddev_stats(stddev_stats(&r->run_stats), mean); in print_thread_runtime()
2898 print_sched_time(r->run_stats.min, 6); in print_thread_runtime()
2902 print_sched_time(r->run_stats.max, 6); in print_thread_runtime()
2905 printf(" %5" PRIu64, r->migrations); in print_thread_runtime()
2914 (u64) r->run_stats.n); in print_thread_waittime()
2916 print_sched_time(r->total_run_time, 8); in print_thread_waittime()
2917 print_sched_time(r->total_sleep_time, 6); in print_thread_waittime()
2919 print_sched_time(r->total_iowait_time, 6); in print_thread_waittime()
2921 print_sched_time(r->total_preempt_time, 6); in print_thread_waittime()
2923 print_sched_time(r->total_delay_time, 6); in print_thread_waittime()
2943 if (r && r->run_stats.n) { in show_thread_runtime()
2944 stats->task_count++; in show_thread_runtime()
2945 stats->sched_count += r->run_stats.n; in show_thread_runtime()
2946 stats->total_run_time += r->total_run_time; in show_thread_runtime()
2948 if (stats->sched->show_state) in show_thread_runtime()
2959 const char *sep = " <- "; in callchain__fprintf_folded()
2968 ret = callchain__fprintf_folded(fp, node->parent); in callchain__fprintf_folded()
2971 list_for_each_entry(chain, &node->val, list) { in callchain__fprintf_folded()
2972 if (chain->ip >= PERF_CONTEXT_MAX) in callchain__fprintf_folded()
2974 if (chain->ms.sym && chain->ms.sym->ignore) in callchain__fprintf_folded()
2992 printf(" %16s %8s %s\n", "Idle time (msec)", "Count", "Callchains"); in timehist_print_idlehist_callchain()
3001 print_sched_time(chain->hit, 12); in timehist_print_idlehist_callchain()
3003 ret += fprintf(fp, " %8d ", chain->count); in timehist_print_idlehist_callchain()
3014 struct machine *m = &session->machines.host; in timehist_print_summary()
3020 u64 hist_time = sched->hist_time.end - sched->hist_time.start; in timehist_print_summary()
3025 if (sched->idle_hist) { in timehist_print_summary()
3026 printf("\nIdle-time summary\n"); in timehist_print_summary()
3027 printf("%*s parent sched-out ", comm_width, "comm"); in timehist_print_summary()
3028 printf(" idle-time min-idle avg-idle max-idle stddev migrations\n"); in timehist_print_summary()
3029 } else if (sched->show_state) { in timehist_print_summary()
3030 printf("\nWait-time summary\n"); in timehist_print_summary()
3031 printf("%*s parent sched-in ", comm_width, "comm"); in timehist_print_summary()
3032 printf(" run-time sleep iowait preempt delay\n"); in timehist_print_summary()
3035 printf("%*s parent sched-in ", comm_width, "comm"); in timehist_print_summary()
3036 printf(" run-time min-run avg-run max-run stddev migrations\n"); in timehist_print_summary()
3040 sched->show_state ? "(msec)" : "%"); in timehist_print_summary()
3049 if (sched->skipped_samples && !sched->idle_hist) in timehist_print_summary()
3062 if (r && r->run_stats.n) { in timehist_print_summary()
3063 totals.sched_count += r->run_stats.n; in timehist_print_summary()
3065 print_sched_time(r->total_run_time, 6); in timehist_print_summary()
3066 printf(" msec (%6.2f%%)\n", 100.0 * r->total_run_time / hist_time); in timehist_print_summary()
3068 printf(" CPU %2d idle entire time window\n", i); in timehist_print_summary()
3071 if (sched->idle_hist && sched->show_callchain) { in timehist_print_summary()
3089 callchain_param.sort(&itr->sorted_root.rb_root, &itr->callchain, in timehist_print_summary()
3093 print_sched_time(itr->tr.total_run_time, 6); in timehist_print_summary()
3095 timehist_print_idlehist_callchain(&itr->sorted_root); in timehist_print_summary()
3105 printf(" Total run time (msec): "); in timehist_print_summary()
3109 printf(" Total scheduling time (msec): "); in timehist_print_summary()
3111 printf(" (x %d)\n", sched->max_cpu.cpu); in timehist_print_summary()
3117 struct perf_sample *sample,
3122 struct perf_sample *sample, in perf_timehist__process_sample() argument
3129 .cpu = sample->cpu, in perf_timehist__process_sample()
3132 if (this_cpu.cpu > sched->max_cpu.cpu) in perf_timehist__process_sample()
3133 sched->max_cpu = this_cpu; in perf_timehist__process_sample()
3135 if (evsel->handler != NULL) { in perf_timehist__process_sample()
3136 sched_handler f = evsel->handler; in perf_timehist__process_sample()
3138 err = f(tool, event, evsel, sample, machine); in perf_timehist__process_sample()
3150 list_for_each_entry(evsel, &evlist->core.entries, core.node) { in timehist_check_attr()
3154 return -1; in timehist_check_attr()
3158 if (sched->show_callchain && in timehist_check_attr()
3162 sched->show_callchain = 0; in timehist_check_attr()
3174 const char *str = sched->prio_str; in timehist_parse_prio_str()
3182 if (start_prio >= MAX_PRIO || (*p != '\0' && *p != ',' && *p != '-')) in timehist_parse_prio_str()
3183 return -1; in timehist_parse_prio_str()
3185 if (*p == '-') { in timehist_parse_prio_str()
3191 return -1; in timehist_parse_prio_str()
3194 return -1; in timehist_parse_prio_str()
3200 __set_bit(start_prio, sched->prio_bitmap); in timehist_parse_prio_str()
3225 .force = sched->force, in perf_sched__timehist()
3230 int err = -1; in perf_sched__timehist()
3235 sched->tool.sample = perf_timehist__process_sample; in perf_sched__timehist()
3236 sched->tool.mmap = perf_event__process_mmap; in perf_sched__timehist()
3237 sched->tool.comm = perf_event__process_comm; in perf_sched__timehist()
3238 sched->tool.exit = perf_event__process_exit; in perf_sched__timehist()
3239 sched->tool.fork = perf_event__process_fork; in perf_sched__timehist()
3240 sched->tool.lost = process_lost; in perf_sched__timehist()
3241 sched->tool.attr = perf_event__process_attr; in perf_sched__timehist()
3242 sched->tool.tracing_data = perf_event__process_tracing_data; in perf_sched__timehist()
3243 sched->tool.build_id = perf_event__process_build_id; in perf_sched__timehist()
3245 sched->tool.ordering_requires_timestamps = true; in perf_sched__timehist()
3247 symbol_conf.use_callchain = sched->show_callchain; in perf_sched__timehist()
3249 session = perf_session__new(&data, &sched->tool); in perf_sched__timehist()
3259 evlist = session->evlist; in perf_sched__timehist()
3261 symbol__init(&session->header.env); in perf_sched__timehist()
3263 if (perf_time__parse_str(&sched->ptime, sched->time_str) != 0) { in perf_sched__timehist()
3264 pr_err("Invalid time string\n"); in perf_sched__timehist()
3265 err = -EINVAL; in perf_sched__timehist()
3280 if (evlist__find_tracepoint_by_name(session->evlist, "sched:sched_waking")) in perf_sched__timehist()
3283 /* setup per-evsel handlers */ in perf_sched__timehist()
3288 if (!evlist__find_tracepoint_by_name(session->evlist, "sched:sched_switch")) { in perf_sched__timehist()
3293 if (sched->show_migrations && in perf_sched__timehist()
3297 /* pre-allocate struct for per-CPU idle stats */ in perf_sched__timehist()
3298 sched->max_cpu.cpu = session->header.env.nr_cpus_online; in perf_sched__timehist()
3299 if (sched->max_cpu.cpu == 0) in perf_sched__timehist()
3300 sched->max_cpu.cpu = 4; in perf_sched__timehist()
3301 if (init_idle_threads(sched->max_cpu.cpu)) in perf_sched__timehist()
3305 if (sched->summary_only) in perf_sched__timehist()
3306 sched->summary = sched->summary_only; in perf_sched__timehist()
3308 if (!sched->summary_only) in perf_sched__timehist()
3317 sched->nr_events = evlist->stats.nr_events[0]; in perf_sched__timehist()
3318 sched->nr_lost_events = evlist->stats.total_lost; in perf_sched__timehist()
3319 sched->nr_lost_chunks = evlist->stats.nr_events[PERF_RECORD_LOST]; in perf_sched__timehist()
3321 if (sched->summary) in perf_sched__timehist()
3334 if (sched->nr_unordered_timestamps && sched->nr_timestamps) { in print_bad_events()
3336 (double)sched->nr_unordered_timestamps/(double)sched->nr_timestamps*100.0, in print_bad_events()
3337 sched->nr_unordered_timestamps, sched->nr_timestamps); in print_bad_events()
3339 if (sched->nr_lost_events && sched->nr_events) { in print_bad_events()
3341 (double)sched->nr_lost_events/(double)sched->nr_events * 100.0, in print_bad_events()
3342 sched->nr_lost_events, sched->nr_events, sched->nr_lost_chunks); in print_bad_events()
3344 if (sched->nr_context_switch_bugs && sched->nr_timestamps) { in print_bad_events()
3346 (double)sched->nr_context_switch_bugs/(double)sched->nr_timestamps*100.0, in print_bad_events()
3347 sched->nr_context_switch_bugs, sched->nr_timestamps); in print_bad_events()
3348 if (sched->nr_lost_events) in print_bad_events()
3356 struct rb_node **new = &(root->rb_root.rb_node), *parent = NULL; in __merge_work_atoms()
3358 const char *comm = thread__comm_str(data->thread), *this_comm; in __merge_work_atoms()
3367 this_comm = thread__comm_str(this->thread); in __merge_work_atoms()
3370 new = &((*new)->rb_left); in __merge_work_atoms()
3372 new = &((*new)->rb_right); in __merge_work_atoms()
3375 this->num_merged++; in __merge_work_atoms()
3376 this->total_runtime += data->total_runtime; in __merge_work_atoms()
3377 this->nb_atoms += data->nb_atoms; in __merge_work_atoms()
3378 this->total_lat += data->total_lat; in __merge_work_atoms()
3379 list_splice(&data->work_list, &this->work_list); in __merge_work_atoms()
3380 if (this->max_lat < data->max_lat) { in __merge_work_atoms()
3381 this->max_lat = data->max_lat; in __merge_work_atoms()
3382 this->max_lat_start = data->max_lat_start; in __merge_work_atoms()
3383 this->max_lat_end = data->max_lat_end; in __merge_work_atoms()
3390 data->num_merged++; in __merge_work_atoms()
3391 rb_link_node(&data->node, parent, new); in __merge_work_atoms()
3392 rb_insert_color_cached(&data->node, root, leftmost); in __merge_work_atoms()
3400 if (sched->skip_merge) in perf_sched__merge_lat()
3403 while ((node = rb_first_cached(&sched->atom_root))) { in perf_sched__merge_lat()
3404 rb_erase_cached(node, &sched->atom_root); in perf_sched__merge_lat()
3406 __merge_work_atoms(&sched->merged_atom_root, data); in perf_sched__merge_lat()
3414 sched->cpu_last_switched = calloc(MAX_CPUS, sizeof(*(sched->cpu_last_switched))); in setup_cpus_switch_event()
3415 if (!sched->cpu_last_switched) in setup_cpus_switch_event()
3416 return -1; in setup_cpus_switch_event()
3418 sched->curr_pid = malloc(MAX_CPUS * sizeof(*(sched->curr_pid))); in setup_cpus_switch_event()
3419 if (!sched->curr_pid) { in setup_cpus_switch_event()
3420 zfree(&sched->cpu_last_switched); in setup_cpus_switch_event()
3421 return -1; in setup_cpus_switch_event()
3425 sched->curr_pid[i] = -1; in setup_cpus_switch_event()
3432 zfree(&sched->curr_pid); in free_cpus_switch_event()
3433 zfree(&sched->cpu_last_switched); in free_cpus_switch_event()
3438 int rc = -1; in perf_sched__lat()
3452 …tf("\n -------------------------------------------------------------------------------------------… in perf_sched__lat()
3454 …intf(" -------------------------------------------------------------------------------------------… in perf_sched__lat()
3456 next = rb_first_cached(&sched->sorted_atom_root); in perf_sched__lat()
3464 thread__zput(work_list->thread); in perf_sched__lat()
3467 …printf(" -----------------------------------------------------------------------------------------… in perf_sched__lat()
3469 (double)sched->all_runtime / NSEC_PER_MSEC, sched->all_count); in perf_sched__lat()
3471 printf(" ---------------------------------------------------\n"); in perf_sched__lat()
3485 sched->max_cpu.cpu = sysconf(_SC_NPROCESSORS_CONF); in setup_map_cpus()
3487 if (sched->map.comp) { in setup_map_cpus()
3488 sched->map.comp_cpus = zalloc(sched->max_cpu.cpu * sizeof(int)); in setup_map_cpus()
3489 if (!sched->map.comp_cpus) in setup_map_cpus()
3490 return -1; in setup_map_cpus()
3493 if (sched->map.cpus_str) { in setup_map_cpus()
3494 sched->map.cpus = perf_cpu_map__new(sched->map.cpus_str); in setup_map_cpus()
3495 if (!sched->map.cpus) { in setup_map_cpus()
3496 pr_err("failed to get cpus map from %s\n", sched->map.cpus_str); in setup_map_cpus()
3497 zfree(&sched->map.comp_cpus); in setup_map_cpus()
3498 return -1; in setup_map_cpus()
3509 if (!sched->map.color_pids_str) in setup_color_pids()
3512 map = thread_map__new_by_tid_str(sched->map.color_pids_str); in setup_color_pids()
3514 pr_err("failed to get thread map from %s\n", sched->map.color_pids_str); in setup_color_pids()
3515 return -1; in setup_color_pids()
3518 sched->map.color_pids = map; in setup_color_pids()
3526 if (!sched->map.color_cpus_str) in setup_color_cpus()
3529 map = perf_cpu_map__new(sched->map.color_cpus_str); in setup_color_cpus()
3531 pr_err("failed to get thread map from %s\n", sched->map.color_cpus_str); in setup_color_cpus()
3532 return -1; in setup_color_cpus()
3535 sched->map.color_cpus = map; in setup_color_cpus()
3541 int rc = -1; in perf_sched__map()
3543 sched->curr_thread = calloc(MAX_CPUS, sizeof(*(sched->curr_thread))); in perf_sched__map()
3544 if (!sched->curr_thread) in perf_sched__map()
3547 sched->curr_out_thread = calloc(MAX_CPUS, sizeof(*(sched->curr_out_thread))); in perf_sched__map()
3548 if (!sched->curr_out_thread) in perf_sched__map()
3571 perf_cpu_map__put(sched->map.color_cpus); in perf_sched__map()
3574 perf_thread_map__put(sched->map.color_pids); in perf_sched__map()
3577 zfree(&sched->map.comp_cpus); in perf_sched__map()
3578 perf_cpu_map__put(sched->map.cpus); in perf_sched__map()
3584 zfree(&sched->curr_thread); in perf_sched__map()
3593 mutex_init(&sched->start_work_mutex); in perf_sched__replay()
3594 mutex_init(&sched->work_done_wait_mutex); in perf_sched__replay()
3609 printf("nr_run_events: %ld\n", sched->nr_run_events); in perf_sched__replay()
3610 printf("nr_sleep_events: %ld\n", sched->nr_sleep_events); in perf_sched__replay()
3611 printf("nr_wakeup_events: %ld\n", sched->nr_wakeup_events); in perf_sched__replay()
3613 if (sched->targetless_wakeups) in perf_sched__replay()
3614 printf("target-less wakeups: %ld\n", sched->targetless_wakeups); in perf_sched__replay()
3615 if (sched->multitarget_wakeups) in perf_sched__replay()
3616 printf("multi-target wakeups: %ld\n", sched->multitarget_wakeups); in perf_sched__replay()
3617 if (sched->nr_run_events_optimized) in perf_sched__replay()
3619 sched->nr_run_events_optimized); in perf_sched__replay()
3624 sched->thread_funcs_exit = false; in perf_sched__replay()
3626 printf("------------------------------------------------------------\n"); in perf_sched__replay()
3627 if (sched->replay_repeat == 0) in perf_sched__replay()
3628 sched->replay_repeat = UINT_MAX; in perf_sched__replay()
3630 for (i = 0; i < sched->replay_repeat; i++) in perf_sched__replay()
3633 sched->thread_funcs_exit = true; in perf_sched__replay()
3640 mutex_destroy(&sched->start_work_mutex); in perf_sched__replay()
3641 mutex_destroy(&sched->work_done_wait_mutex); in perf_sched__replay()
3648 char *tmp, *tok, *str = strdup(sched->sort_order); in setup_sorting()
3652 if (sort_dimension__add(tok, &sched->sort_list) < 0) { in setup_sorting()
3654 "Unknown --sort key: `%s'", tok); in setup_sorting()
3660 sort_dimension__add("pid", &sched->cmp_pid); in setup_sorting()
3680 "-a", in __cmd_record()
3681 "-R", in __cmd_record()
3682 "-m", "1024", in __cmd_record()
3683 "-c", "1", in __cmd_record()
3684 "-e", "sched:sched_switch", in __cmd_record()
3685 "-e", "sched:sched_stat_runtime", in __cmd_record()
3686 "-e", "sched:sched_process_fork", in __cmd_record()
3687 "-e", "sched:sched_wakeup_new", in __cmd_record()
3688 "-e", "sched:sched_migrate_task", in __cmd_record()
3698 "-e", "sched:sched_stat_wait", in __cmd_record()
3699 "-e", "sched:sched_stat_sleep", in __cmd_record()
3700 "-e", "sched:sched_stat_iowait", in __cmd_record()
3709 * +2 for either "-e", "sched:sched_wakeup" or in __cmd_record()
3710 * "-e", "sched:sched_waking" in __cmd_record()
3712 rec_argc = ARRAY_SIZE(record_args) + 2 + schedstat_argc + argc - 1; in __cmd_record()
3715 return -ENOMEM; in __cmd_record()
3719 return -ENOMEM; in __cmd_record()
3725 rec_argv[i++] = strdup("-e"); in __cmd_record()
3759 .profile_cpu = -1, in cmd_sched()
3771 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, in cmd_sched()
3793 OPT_STRING(0, "color-pids", &sched.map.color_pids_str, "pids", in cmd_sched()
3795 OPT_STRING(0, "color-cpus", &sched.map.color_cpus_str, "cpus", in cmd_sched()
3799 OPT_STRING(0, "task-name", &sched.map.task_name, "task", in cmd_sched()
3801 OPT_BOOLEAN(0, "fuzzy-name", &sched.map.fuzzy, in cmd_sched()
3810 OPT_BOOLEAN('g', "call-graph", &sched.show_callchain, in cmd_sched()
3812 OPT_UINTEGER(0, "max-stack", &sched.max_stack, in cmd_sched()
3818 OPT_BOOLEAN('S', "with-summary", &sched.summary, in cmd_sched()
3823 OPT_BOOLEAN('V', "cpu-visual", &sched.show_cpu_visual, "Add CPU visual"), in cmd_sched()
3824 OPT_BOOLEAN('I', "idle-hist", &sched.idle_hist, "Show idle events only"), in cmd_sched()
3825 OPT_STRING(0, "time", &sched.time_str, "str", in cmd_sched()
3826 "Time span for analysis (start,stop)"), in cmd_sched()
3827 OPT_BOOLEAN(0, "state", &sched.show_state, "Show task state when sched-out"), in cmd_sched()
3833 OPT_BOOLEAN(0, "show-prio", &sched.show_prio, "Show task priority"), in cmd_sched()
3879 sched.tool.sample = perf_sched__process_tracepoint_sample; in cmd_sched()
3916 return -1; in cmd_sched()
3940 pr_err(" Error: -s and -[n|w] are mutually exclusive.\n"); in cmd_sched()
3946 return -EINVAL; in cmd_sched()