diff options
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r-- | tools/perf/builtin-sched.c | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index d8c51b2f263f..0f3c65518a2c 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -737,12 +737,12 @@ static int replay_fork_event(struct perf_sched *sched, | |||
737 | 737 | ||
738 | if (verbose) { | 738 | if (verbose) { |
739 | printf("fork event\n"); | 739 | printf("fork event\n"); |
740 | printf("... parent: %s/%d\n", parent->comm, parent->tid); | 740 | printf("... parent: %s/%d\n", thread__comm_str(parent), parent->tid); |
741 | printf("... child: %s/%d\n", child->comm, child->tid); | 741 | printf("... child: %s/%d\n", thread__comm_str(child), child->tid); |
742 | } | 742 | } |
743 | 743 | ||
744 | register_pid(sched, parent->tid, parent->comm); | 744 | register_pid(sched, parent->tid, thread__comm_str(parent)); |
745 | register_pid(sched, child->tid, child->comm); | 745 | register_pid(sched, child->tid, thread__comm_str(child)); |
746 | return 0; | 746 | return 0; |
747 | } | 747 | } |
748 | 748 | ||
@@ -1077,7 +1077,7 @@ static int latency_migrate_task_event(struct perf_sched *sched, | |||
1077 | if (!atoms) { | 1077 | if (!atoms) { |
1078 | if (thread_atoms_insert(sched, migrant)) | 1078 | if (thread_atoms_insert(sched, migrant)) |
1079 | return -1; | 1079 | return -1; |
1080 | register_pid(sched, migrant->tid, migrant->comm); | 1080 | register_pid(sched, migrant->tid, thread__comm_str(migrant)); |
1081 | atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid); | 1081 | atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid); |
1082 | if (!atoms) { | 1082 | if (!atoms) { |
1083 | pr_err("migration-event: Internal tree error"); | 1083 | pr_err("migration-event: Internal tree error"); |
@@ -1111,13 +1111,13 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ | |||
1111 | /* | 1111 | /* |
1112 | * Ignore idle threads: | 1112 | * Ignore idle threads: |
1113 | */ | 1113 | */ |
1114 | if (!strcmp(work_list->thread->comm, "swapper")) | 1114 | if (!strcmp(thread__comm_str(work_list->thread), "swapper")) |
1115 | return; | 1115 | return; |
1116 | 1116 | ||
1117 | sched->all_runtime += work_list->total_runtime; | 1117 | sched->all_runtime += work_list->total_runtime; |
1118 | sched->all_count += work_list->nb_atoms; | 1118 | sched->all_count += work_list->nb_atoms; |
1119 | 1119 | ||
1120 | ret = printf(" %s:%d ", work_list->thread->comm, work_list->thread->tid); | 1120 | ret = printf(" %s:%d ", thread__comm_str(work_list->thread), work_list->thread->tid); |
1121 | 1121 | ||
1122 | for (i = 0; i < 24 - ret; i++) | 1122 | for (i = 0; i < 24 - ret; i++) |
1123 | printf(" "); | 1123 | printf(" "); |
@@ -1334,7 +1334,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, | |||
1334 | printf(" %12.6f secs ", (double)timestamp/1e9); | 1334 | printf(" %12.6f secs ", (double)timestamp/1e9); |
1335 | if (new_shortname) { | 1335 | if (new_shortname) { |
1336 | printf("%s => %s:%d\n", | 1336 | printf("%s => %s:%d\n", |
1337 | sched_in->shortname, sched_in->comm, sched_in->tid); | 1337 | sched_in->shortname, thread__comm_str(sched_in), sched_in->tid); |
1338 | } else { | 1338 | } else { |
1339 | printf("\n"); | 1339 | printf("\n"); |
1340 | } | 1340 | } |
@@ -1427,8 +1427,8 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_ | |||
1427 | evsel->hists.stats.total_period += sample->period; | 1427 | evsel->hists.stats.total_period += sample->period; |
1428 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); | 1428 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); |
1429 | 1429 | ||
1430 | if (evsel->handler.func != NULL) { | 1430 | if (evsel->handler != NULL) { |
1431 | tracepoint_handler f = evsel->handler.func; | 1431 | tracepoint_handler f = evsel->handler; |
1432 | err = f(tool, evsel, sample, machine); | 1432 | err = f(tool, evsel, sample, machine); |
1433 | } | 1433 | } |
1434 | 1434 | ||
@@ -1446,8 +1446,12 @@ static int perf_sched__read_events(struct perf_sched *sched, | |||
1446 | { "sched:sched_migrate_task", process_sched_migrate_task_event, }, | 1446 | { "sched:sched_migrate_task", process_sched_migrate_task_event, }, |
1447 | }; | 1447 | }; |
1448 | struct perf_session *session; | 1448 | struct perf_session *session; |
1449 | struct perf_data_file file = { | ||
1450 | .path = input_name, | ||
1451 | .mode = PERF_DATA_MODE_READ, | ||
1452 | }; | ||
1449 | 1453 | ||
1450 | session = perf_session__new(input_name, O_RDONLY, 0, false, &sched->tool); | 1454 | session = perf_session__new(&file, false, &sched->tool); |
1451 | if (session == NULL) { | 1455 | if (session == NULL) { |
1452 | pr_debug("No Memory for session\n"); | 1456 | pr_debug("No Memory for session\n"); |
1453 | return -1; | 1457 | return -1; |
@@ -1651,29 +1655,27 @@ static int __cmd_record(int argc, const char **argv) | |||
1651 | return cmd_record(i, rec_argv, NULL); | 1655 | return cmd_record(i, rec_argv, NULL); |
1652 | } | 1656 | } |
1653 | 1657 | ||
1654 | static const char default_sort_order[] = "avg, max, switch, runtime"; | ||
1655 | static struct perf_sched sched = { | ||
1656 | .tool = { | ||
1657 | .sample = perf_sched__process_tracepoint_sample, | ||
1658 | .comm = perf_event__process_comm, | ||
1659 | .lost = perf_event__process_lost, | ||
1660 | .fork = perf_sched__process_fork_event, | ||
1661 | .ordered_samples = true, | ||
1662 | }, | ||
1663 | .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid), | ||
1664 | .sort_list = LIST_HEAD_INIT(sched.sort_list), | ||
1665 | .start_work_mutex = PTHREAD_MUTEX_INITIALIZER, | ||
1666 | .work_done_wait_mutex = PTHREAD_MUTEX_INITIALIZER, | ||
1667 | .curr_pid = { [0 ... MAX_CPUS - 1] = -1 }, | ||
1668 | .sort_order = default_sort_order, | ||
1669 | .replay_repeat = 10, | ||
1670 | .profile_cpu = -1, | ||
1671 | .next_shortname1 = 'A', | ||
1672 | .next_shortname2 = '0', | ||
1673 | }; | ||
1674 | |||
1675 | int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) | 1658 | int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) |
1676 | { | 1659 | { |
1660 | const char default_sort_order[] = "avg, max, switch, runtime"; | ||
1661 | struct perf_sched sched = { | ||
1662 | .tool = { | ||
1663 | .sample = perf_sched__process_tracepoint_sample, | ||
1664 | .comm = perf_event__process_comm, | ||
1665 | .lost = perf_event__process_lost, | ||
1666 | .fork = perf_sched__process_fork_event, | ||
1667 | .ordered_samples = true, | ||
1668 | }, | ||
1669 | .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid), | ||
1670 | .sort_list = LIST_HEAD_INIT(sched.sort_list), | ||
1671 | .start_work_mutex = PTHREAD_MUTEX_INITIALIZER, | ||
1672 | .work_done_wait_mutex = PTHREAD_MUTEX_INITIALIZER, | ||
1673 | .sort_order = default_sort_order, | ||
1674 | .replay_repeat = 10, | ||
1675 | .profile_cpu = -1, | ||
1676 | .next_shortname1 = 'A', | ||
1677 | .next_shortname2 = '0', | ||
1678 | }; | ||
1677 | const struct option latency_options[] = { | 1679 | const struct option latency_options[] = { |
1678 | OPT_STRING('s', "sort", &sched.sort_order, "key[,key2...]", | 1680 | OPT_STRING('s', "sort", &sched.sort_order, "key[,key2...]", |
1679 | "sort by key(s): runtime, switch, avg, max"), | 1681 | "sort by key(s): runtime, switch, avg, max"), |
@@ -1729,6 +1731,10 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1729 | .switch_event = replay_switch_event, | 1731 | .switch_event = replay_switch_event, |
1730 | .fork_event = replay_fork_event, | 1732 | .fork_event = replay_fork_event, |
1731 | }; | 1733 | }; |
1734 | unsigned int i; | ||
1735 | |||
1736 | for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++) | ||
1737 | sched.curr_pid[i] = -1; | ||
1732 | 1738 | ||
1733 | argc = parse_options(argc, argv, sched_options, sched_usage, | 1739 | argc = parse_options(argc, argv, sched_options, sched_usage, |
1734 | PARSE_OPT_STOP_AT_NON_OPTION); | 1740 | PARSE_OPT_STOP_AT_NON_OPTION); |