diff options
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r-- | tools/perf/builtin-sched.c | 200 |
1 files changed, 101 insertions, 99 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 5177964943e..fb8b5f83b4a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -2,11 +2,14 @@ | |||
2 | #include "perf.h" | 2 | #include "perf.h" |
3 | 3 | ||
4 | #include "util/util.h" | 4 | #include "util/util.h" |
5 | #include "util/evlist.h" | ||
5 | #include "util/cache.h" | 6 | #include "util/cache.h" |
7 | #include "util/evsel.h" | ||
6 | #include "util/symbol.h" | 8 | #include "util/symbol.h" |
7 | #include "util/thread.h" | 9 | #include "util/thread.h" |
8 | #include "util/header.h" | 10 | #include "util/header.h" |
9 | #include "util/session.h" | 11 | #include "util/session.h" |
12 | #include "util/tool.h" | ||
10 | 13 | ||
11 | #include "util/parse-options.h" | 14 | #include "util/parse-options.h" |
12 | #include "util/trace-event.h" | 15 | #include "util/trace-event.h" |
@@ -19,7 +22,7 @@ | |||
19 | #include <pthread.h> | 22 | #include <pthread.h> |
20 | #include <math.h> | 23 | #include <math.h> |
21 | 24 | ||
22 | static char const *input_name = "perf.data"; | 25 | static const char *input_name; |
23 | 26 | ||
24 | static char default_sort_order[] = "avg, max, switch, runtime"; | 27 | static char default_sort_order[] = "avg, max, switch, runtime"; |
25 | static const char *sort_order = default_sort_order; | 28 | static const char *sort_order = default_sort_order; |
@@ -723,21 +726,21 @@ struct trace_migrate_task_event { | |||
723 | 726 | ||
724 | struct trace_sched_handler { | 727 | struct trace_sched_handler { |
725 | void (*switch_event)(struct trace_switch_event *, | 728 | void (*switch_event)(struct trace_switch_event *, |
726 | struct perf_session *, | 729 | struct machine *, |
727 | struct event *, | 730 | struct event *, |
728 | int cpu, | 731 | int cpu, |
729 | u64 timestamp, | 732 | u64 timestamp, |
730 | struct thread *thread); | 733 | struct thread *thread); |
731 | 734 | ||
732 | void (*runtime_event)(struct trace_runtime_event *, | 735 | void (*runtime_event)(struct trace_runtime_event *, |
733 | struct perf_session *, | 736 | struct machine *, |
734 | struct event *, | 737 | struct event *, |
735 | int cpu, | 738 | int cpu, |
736 | u64 timestamp, | 739 | u64 timestamp, |
737 | struct thread *thread); | 740 | struct thread *thread); |
738 | 741 | ||
739 | void (*wakeup_event)(struct trace_wakeup_event *, | 742 | void (*wakeup_event)(struct trace_wakeup_event *, |
740 | struct perf_session *, | 743 | struct machine *, |
741 | struct event *, | 744 | struct event *, |
742 | int cpu, | 745 | int cpu, |
743 | u64 timestamp, | 746 | u64 timestamp, |
@@ -750,7 +753,7 @@ struct trace_sched_handler { | |||
750 | struct thread *thread); | 753 | struct thread *thread); |
751 | 754 | ||
752 | void (*migrate_task_event)(struct trace_migrate_task_event *, | 755 | void (*migrate_task_event)(struct trace_migrate_task_event *, |
753 | struct perf_session *session, | 756 | struct machine *machine, |
754 | struct event *, | 757 | struct event *, |
755 | int cpu, | 758 | int cpu, |
756 | u64 timestamp, | 759 | u64 timestamp, |
@@ -760,7 +763,7 @@ struct trace_sched_handler { | |||
760 | 763 | ||
761 | static void | 764 | static void |
762 | replay_wakeup_event(struct trace_wakeup_event *wakeup_event, | 765 | replay_wakeup_event(struct trace_wakeup_event *wakeup_event, |
763 | struct perf_session *session __used, | 766 | struct machine *machine __used, |
764 | struct event *event, | 767 | struct event *event, |
765 | int cpu __used, | 768 | int cpu __used, |
766 | u64 timestamp __used, | 769 | u64 timestamp __used, |
@@ -787,7 +790,7 @@ static u64 cpu_last_switched[MAX_CPUS]; | |||
787 | 790 | ||
788 | static void | 791 | static void |
789 | replay_switch_event(struct trace_switch_event *switch_event, | 792 | replay_switch_event(struct trace_switch_event *switch_event, |
790 | struct perf_session *session __used, | 793 | struct machine *machine __used, |
791 | struct event *event, | 794 | struct event *event, |
792 | int cpu, | 795 | int cpu, |
793 | u64 timestamp, | 796 | u64 timestamp, |
@@ -1021,7 +1024,7 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp) | |||
1021 | 1024 | ||
1022 | static void | 1025 | static void |
1023 | latency_switch_event(struct trace_switch_event *switch_event, | 1026 | latency_switch_event(struct trace_switch_event *switch_event, |
1024 | struct perf_session *session, | 1027 | struct machine *machine, |
1025 | struct event *event __used, | 1028 | struct event *event __used, |
1026 | int cpu, | 1029 | int cpu, |
1027 | u64 timestamp, | 1030 | u64 timestamp, |
@@ -1045,8 +1048,8 @@ latency_switch_event(struct trace_switch_event *switch_event, | |||
1045 | die("hm, delta: %" PRIu64 " < 0 ?\n", delta); | 1048 | die("hm, delta: %" PRIu64 " < 0 ?\n", delta); |
1046 | 1049 | ||
1047 | 1050 | ||
1048 | sched_out = perf_session__findnew(session, switch_event->prev_pid); | 1051 | sched_out = machine__findnew_thread(machine, switch_event->prev_pid); |
1049 | sched_in = perf_session__findnew(session, switch_event->next_pid); | 1052 | sched_in = machine__findnew_thread(machine, switch_event->next_pid); |
1050 | 1053 | ||
1051 | out_events = thread_atoms_search(&atom_root, sched_out, &cmp_pid); | 1054 | out_events = thread_atoms_search(&atom_root, sched_out, &cmp_pid); |
1052 | if (!out_events) { | 1055 | if (!out_events) { |
@@ -1074,13 +1077,13 @@ latency_switch_event(struct trace_switch_event *switch_event, | |||
1074 | 1077 | ||
1075 | static void | 1078 | static void |
1076 | latency_runtime_event(struct trace_runtime_event *runtime_event, | 1079 | latency_runtime_event(struct trace_runtime_event *runtime_event, |
1077 | struct perf_session *session, | 1080 | struct machine *machine, |
1078 | struct event *event __used, | 1081 | struct event *event __used, |
1079 | int cpu, | 1082 | int cpu, |
1080 | u64 timestamp, | 1083 | u64 timestamp, |
1081 | struct thread *this_thread __used) | 1084 | struct thread *this_thread __used) |
1082 | { | 1085 | { |
1083 | struct thread *thread = perf_session__findnew(session, runtime_event->pid); | 1086 | struct thread *thread = machine__findnew_thread(machine, runtime_event->pid); |
1084 | struct work_atoms *atoms = thread_atoms_search(&atom_root, thread, &cmp_pid); | 1087 | struct work_atoms *atoms = thread_atoms_search(&atom_root, thread, &cmp_pid); |
1085 | 1088 | ||
1086 | BUG_ON(cpu >= MAX_CPUS || cpu < 0); | 1089 | BUG_ON(cpu >= MAX_CPUS || cpu < 0); |
@@ -1097,7 +1100,7 @@ latency_runtime_event(struct trace_runtime_event *runtime_event, | |||
1097 | 1100 | ||
1098 | static void | 1101 | static void |
1099 | latency_wakeup_event(struct trace_wakeup_event *wakeup_event, | 1102 | latency_wakeup_event(struct trace_wakeup_event *wakeup_event, |
1100 | struct perf_session *session, | 1103 | struct machine *machine, |
1101 | struct event *__event __used, | 1104 | struct event *__event __used, |
1102 | int cpu __used, | 1105 | int cpu __used, |
1103 | u64 timestamp, | 1106 | u64 timestamp, |
@@ -1111,7 +1114,7 @@ latency_wakeup_event(struct trace_wakeup_event *wakeup_event, | |||
1111 | if (!wakeup_event->success) | 1114 | if (!wakeup_event->success) |
1112 | return; | 1115 | return; |
1113 | 1116 | ||
1114 | wakee = perf_session__findnew(session, wakeup_event->pid); | 1117 | wakee = machine__findnew_thread(machine, wakeup_event->pid); |
1115 | atoms = thread_atoms_search(&atom_root, wakee, &cmp_pid); | 1118 | atoms = thread_atoms_search(&atom_root, wakee, &cmp_pid); |
1116 | if (!atoms) { | 1119 | if (!atoms) { |
1117 | thread_atoms_insert(wakee); | 1120 | thread_atoms_insert(wakee); |
@@ -1145,7 +1148,7 @@ latency_wakeup_event(struct trace_wakeup_event *wakeup_event, | |||
1145 | 1148 | ||
1146 | static void | 1149 | static void |
1147 | latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event, | 1150 | latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event, |
1148 | struct perf_session *session, | 1151 | struct machine *machine, |
1149 | struct event *__event __used, | 1152 | struct event *__event __used, |
1150 | int cpu __used, | 1153 | int cpu __used, |
1151 | u64 timestamp, | 1154 | u64 timestamp, |
@@ -1161,7 +1164,7 @@ latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event, | |||
1161 | if (profile_cpu == -1) | 1164 | if (profile_cpu == -1) |
1162 | return; | 1165 | return; |
1163 | 1166 | ||
1164 | migrant = perf_session__findnew(session, migrate_task_event->pid); | 1167 | migrant = machine__findnew_thread(machine, migrate_task_event->pid); |
1165 | atoms = thread_atoms_search(&atom_root, migrant, &cmp_pid); | 1168 | atoms = thread_atoms_search(&atom_root, migrant, &cmp_pid); |
1166 | if (!atoms) { | 1169 | if (!atoms) { |
1167 | thread_atoms_insert(migrant); | 1170 | thread_atoms_insert(migrant); |
@@ -1356,12 +1359,13 @@ static void sort_lat(void) | |||
1356 | static struct trace_sched_handler *trace_handler; | 1359 | static struct trace_sched_handler *trace_handler; |
1357 | 1360 | ||
1358 | static void | 1361 | static void |
1359 | process_sched_wakeup_event(void *data, struct perf_session *session, | 1362 | process_sched_wakeup_event(struct perf_tool *tool __used, |
1360 | struct event *event, | 1363 | struct event *event, |
1361 | int cpu __used, | 1364 | struct perf_sample *sample, |
1362 | u64 timestamp __used, | 1365 | struct machine *machine, |
1363 | struct thread *thread __used) | 1366 | struct thread *thread) |
1364 | { | 1367 | { |
1368 | void *data = sample->raw_data; | ||
1365 | struct trace_wakeup_event wakeup_event; | 1369 | struct trace_wakeup_event wakeup_event; |
1366 | 1370 | ||
1367 | FILL_COMMON_FIELDS(wakeup_event, event, data); | 1371 | FILL_COMMON_FIELDS(wakeup_event, event, data); |
@@ -1373,8 +1377,8 @@ process_sched_wakeup_event(void *data, struct perf_session *session, | |||
1373 | FILL_FIELD(wakeup_event, cpu, event, data); | 1377 | FILL_FIELD(wakeup_event, cpu, event, data); |
1374 | 1378 | ||
1375 | if (trace_handler->wakeup_event) | 1379 | if (trace_handler->wakeup_event) |
1376 | trace_handler->wakeup_event(&wakeup_event, session, event, | 1380 | trace_handler->wakeup_event(&wakeup_event, machine, event, |
1377 | cpu, timestamp, thread); | 1381 | sample->cpu, sample->time, thread); |
1378 | } | 1382 | } |
1379 | 1383 | ||
1380 | /* | 1384 | /* |
@@ -1392,7 +1396,7 @@ static char next_shortname2 = '0'; | |||
1392 | 1396 | ||
1393 | static void | 1397 | static void |
1394 | map_switch_event(struct trace_switch_event *switch_event, | 1398 | map_switch_event(struct trace_switch_event *switch_event, |
1395 | struct perf_session *session, | 1399 | struct machine *machine, |
1396 | struct event *event __used, | 1400 | struct event *event __used, |
1397 | int this_cpu, | 1401 | int this_cpu, |
1398 | u64 timestamp, | 1402 | u64 timestamp, |
@@ -1420,8 +1424,8 @@ map_switch_event(struct trace_switch_event *switch_event, | |||
1420 | die("hm, delta: %" PRIu64 " < 0 ?\n", delta); | 1424 | die("hm, delta: %" PRIu64 " < 0 ?\n", delta); |
1421 | 1425 | ||
1422 | 1426 | ||
1423 | sched_out = perf_session__findnew(session, switch_event->prev_pid); | 1427 | sched_out = machine__findnew_thread(machine, switch_event->prev_pid); |
1424 | sched_in = perf_session__findnew(session, switch_event->next_pid); | 1428 | sched_in = machine__findnew_thread(machine, switch_event->next_pid); |
1425 | 1429 | ||
1426 | curr_thread[this_cpu] = sched_in; | 1430 | curr_thread[this_cpu] = sched_in; |
1427 | 1431 | ||
@@ -1469,14 +1473,15 @@ map_switch_event(struct trace_switch_event *switch_event, | |||
1469 | } | 1473 | } |
1470 | } | 1474 | } |
1471 | 1475 | ||
1472 | |||
1473 | static void | 1476 | static void |
1474 | process_sched_switch_event(void *data, struct perf_session *session, | 1477 | process_sched_switch_event(struct perf_tool *tool __used, |
1475 | struct event *event, | 1478 | struct event *event, |
1476 | int this_cpu, | 1479 | struct perf_sample *sample, |
1477 | u64 timestamp __used, | 1480 | struct machine *machine, |
1478 | struct thread *thread __used) | 1481 | struct thread *thread) |
1479 | { | 1482 | { |
1483 | int this_cpu = sample->cpu; | ||
1484 | void *data = sample->raw_data; | ||
1480 | struct trace_switch_event switch_event; | 1485 | struct trace_switch_event switch_event; |
1481 | 1486 | ||
1482 | FILL_COMMON_FIELDS(switch_event, event, data); | 1487 | FILL_COMMON_FIELDS(switch_event, event, data); |
@@ -1498,19 +1503,20 @@ process_sched_switch_event(void *data, struct perf_session *session, | |||
1498 | nr_context_switch_bugs++; | 1503 | nr_context_switch_bugs++; |
1499 | } | 1504 | } |
1500 | if (trace_handler->switch_event) | 1505 | if (trace_handler->switch_event) |
1501 | trace_handler->switch_event(&switch_event, session, event, | 1506 | trace_handler->switch_event(&switch_event, machine, event, |
1502 | this_cpu, timestamp, thread); | 1507 | this_cpu, sample->time, thread); |
1503 | 1508 | ||
1504 | curr_pid[this_cpu] = switch_event.next_pid; | 1509 | curr_pid[this_cpu] = switch_event.next_pid; |
1505 | } | 1510 | } |
1506 | 1511 | ||
1507 | static void | 1512 | static void |
1508 | process_sched_runtime_event(void *data, struct perf_session *session, | 1513 | process_sched_runtime_event(struct perf_tool *tool __used, |
1509 | struct event *event, | 1514 | struct event *event, |
1510 | int cpu __used, | 1515 | struct perf_sample *sample, |
1511 | u64 timestamp __used, | 1516 | struct machine *machine, |
1512 | struct thread *thread __used) | 1517 | struct thread *thread) |
1513 | { | 1518 | { |
1519 | void *data = sample->raw_data; | ||
1514 | struct trace_runtime_event runtime_event; | 1520 | struct trace_runtime_event runtime_event; |
1515 | 1521 | ||
1516 | FILL_ARRAY(runtime_event, comm, event, data); | 1522 | FILL_ARRAY(runtime_event, comm, event, data); |
@@ -1519,16 +1525,18 @@ process_sched_runtime_event(void *data, struct perf_session *session, | |||
1519 | FILL_FIELD(runtime_event, vruntime, event, data); | 1525 | FILL_FIELD(runtime_event, vruntime, event, data); |
1520 | 1526 | ||
1521 | if (trace_handler->runtime_event) | 1527 | if (trace_handler->runtime_event) |
1522 | trace_handler->runtime_event(&runtime_event, session, event, cpu, timestamp, thread); | 1528 | trace_handler->runtime_event(&runtime_event, machine, event, |
1529 | sample->cpu, sample->time, thread); | ||
1523 | } | 1530 | } |
1524 | 1531 | ||
1525 | static void | 1532 | static void |
1526 | process_sched_fork_event(void *data, | 1533 | process_sched_fork_event(struct perf_tool *tool __used, |
1527 | struct event *event, | 1534 | struct event *event, |
1528 | int cpu __used, | 1535 | struct perf_sample *sample, |
1529 | u64 timestamp __used, | 1536 | struct machine *machine __used, |
1530 | struct thread *thread __used) | 1537 | struct thread *thread) |
1531 | { | 1538 | { |
1539 | void *data = sample->raw_data; | ||
1532 | struct trace_fork_event fork_event; | 1540 | struct trace_fork_event fork_event; |
1533 | 1541 | ||
1534 | FILL_COMMON_FIELDS(fork_event, event, data); | 1542 | FILL_COMMON_FIELDS(fork_event, event, data); |
@@ -1540,13 +1548,14 @@ process_sched_fork_event(void *data, | |||
1540 | 1548 | ||
1541 | if (trace_handler->fork_event) | 1549 | if (trace_handler->fork_event) |
1542 | trace_handler->fork_event(&fork_event, event, | 1550 | trace_handler->fork_event(&fork_event, event, |
1543 | cpu, timestamp, thread); | 1551 | sample->cpu, sample->time, thread); |
1544 | } | 1552 | } |
1545 | 1553 | ||
1546 | static void | 1554 | static void |
1547 | process_sched_exit_event(struct event *event, | 1555 | process_sched_exit_event(struct perf_tool *tool __used, |
1548 | int cpu __used, | 1556 | struct event *event, |
1549 | u64 timestamp __used, | 1557 | struct perf_sample *sample __used, |
1558 | struct machine *machine __used, | ||
1550 | struct thread *thread __used) | 1559 | struct thread *thread __used) |
1551 | { | 1560 | { |
1552 | if (verbose) | 1561 | if (verbose) |
@@ -1554,12 +1563,13 @@ process_sched_exit_event(struct event *event, | |||
1554 | } | 1563 | } |
1555 | 1564 | ||
1556 | static void | 1565 | static void |
1557 | process_sched_migrate_task_event(void *data, struct perf_session *session, | 1566 | process_sched_migrate_task_event(struct perf_tool *tool __used, |
1558 | struct event *event, | 1567 | struct event *event, |
1559 | int cpu __used, | 1568 | struct perf_sample *sample, |
1560 | u64 timestamp __used, | 1569 | struct machine *machine, |
1561 | struct thread *thread __used) | 1570 | struct thread *thread) |
1562 | { | 1571 | { |
1572 | void *data = sample->raw_data; | ||
1563 | struct trace_migrate_task_event migrate_task_event; | 1573 | struct trace_migrate_task_event migrate_task_event; |
1564 | 1574 | ||
1565 | FILL_COMMON_FIELDS(migrate_task_event, event, data); | 1575 | FILL_COMMON_FIELDS(migrate_task_event, event, data); |
@@ -1570,67 +1580,47 @@ process_sched_migrate_task_event(void *data, struct perf_session *session, | |||
1570 | FILL_FIELD(migrate_task_event, cpu, event, data); | 1580 | FILL_FIELD(migrate_task_event, cpu, event, data); |
1571 | 1581 | ||
1572 | if (trace_handler->migrate_task_event) | 1582 | if (trace_handler->migrate_task_event) |
1573 | trace_handler->migrate_task_event(&migrate_task_event, session, | 1583 | trace_handler->migrate_task_event(&migrate_task_event, machine, |
1574 | event, cpu, timestamp, thread); | 1584 | event, sample->cpu, |
1585 | sample->time, thread); | ||
1575 | } | 1586 | } |
1576 | 1587 | ||
1577 | static void process_raw_event(union perf_event *raw_event __used, | 1588 | typedef void (*tracepoint_handler)(struct perf_tool *tool, struct event *event, |
1578 | struct perf_session *session, void *data, int cpu, | 1589 | struct perf_sample *sample, |
1579 | u64 timestamp, struct thread *thread) | 1590 | struct machine *machine, |
1580 | { | 1591 | struct thread *thread); |
1581 | struct event *event; | ||
1582 | int type; | ||
1583 | |||
1584 | |||
1585 | type = trace_parse_common_type(data); | ||
1586 | event = trace_find_event(type); | ||
1587 | |||
1588 | if (!strcmp(event->name, "sched_switch")) | ||
1589 | process_sched_switch_event(data, session, event, cpu, timestamp, thread); | ||
1590 | if (!strcmp(event->name, "sched_stat_runtime")) | ||
1591 | process_sched_runtime_event(data, session, event, cpu, timestamp, thread); | ||
1592 | if (!strcmp(event->name, "sched_wakeup")) | ||
1593 | process_sched_wakeup_event(data, session, event, cpu, timestamp, thread); | ||
1594 | if (!strcmp(event->name, "sched_wakeup_new")) | ||
1595 | process_sched_wakeup_event(data, session, event, cpu, timestamp, thread); | ||
1596 | if (!strcmp(event->name, "sched_process_fork")) | ||
1597 | process_sched_fork_event(data, event, cpu, timestamp, thread); | ||
1598 | if (!strcmp(event->name, "sched_process_exit")) | ||
1599 | process_sched_exit_event(event, cpu, timestamp, thread); | ||
1600 | if (!strcmp(event->name, "sched_migrate_task")) | ||
1601 | process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread); | ||
1602 | } | ||
1603 | 1592 | ||
1604 | static int process_sample_event(union perf_event *event, | 1593 | static int perf_sched__process_tracepoint_sample(struct perf_tool *tool, |
1605 | struct perf_sample *sample, | 1594 | union perf_event *event __used, |
1606 | struct perf_evsel *evsel __used, | 1595 | struct perf_sample *sample, |
1607 | struct perf_session *session) | 1596 | struct perf_evsel *evsel, |
1597 | struct machine *machine) | ||
1608 | { | 1598 | { |
1609 | struct thread *thread; | 1599 | struct thread *thread = machine__findnew_thread(machine, sample->pid); |
1610 | |||
1611 | if (!(session->sample_type & PERF_SAMPLE_RAW)) | ||
1612 | return 0; | ||
1613 | 1600 | ||
1614 | thread = perf_session__findnew(session, sample->pid); | ||
1615 | if (thread == NULL) { | 1601 | if (thread == NULL) { |
1616 | pr_debug("problem processing %d event, skipping it.\n", | 1602 | pr_debug("problem processing %s event, skipping it.\n", |
1617 | event->header.type); | 1603 | evsel->name); |
1618 | return -1; | 1604 | return -1; |
1619 | } | 1605 | } |
1620 | 1606 | ||
1621 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 1607 | evsel->hists.stats.total_period += sample->period; |
1608 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); | ||
1622 | 1609 | ||
1623 | if (profile_cpu != -1 && profile_cpu != (int)sample->cpu) | 1610 | if (evsel->handler.func != NULL) { |
1624 | return 0; | 1611 | tracepoint_handler f = evsel->handler.func; |
1625 | 1612 | ||
1626 | process_raw_event(event, session, sample->raw_data, sample->cpu, | 1613 | if (evsel->handler.data == NULL) |
1627 | sample->time, thread); | 1614 | evsel->handler.data = trace_find_event(evsel->attr.config); |
1615 | |||
1616 | f(tool, evsel->handler.data, sample, machine, thread); | ||
1617 | } | ||
1628 | 1618 | ||
1629 | return 0; | 1619 | return 0; |
1630 | } | 1620 | } |
1631 | 1621 | ||
1632 | static struct perf_event_ops event_ops = { | 1622 | static struct perf_tool perf_sched = { |
1633 | .sample = process_sample_event, | 1623 | .sample = perf_sched__process_tracepoint_sample, |
1634 | .comm = perf_event__process_comm, | 1624 | .comm = perf_event__process_comm, |
1635 | .lost = perf_event__process_lost, | 1625 | .lost = perf_event__process_lost, |
1636 | .fork = perf_event__process_task, | 1626 | .fork = perf_event__process_task, |
@@ -1640,13 +1630,25 @@ static struct perf_event_ops event_ops = { | |||
1640 | static void read_events(bool destroy, struct perf_session **psession) | 1630 | static void read_events(bool destroy, struct perf_session **psession) |
1641 | { | 1631 | { |
1642 | int err = -EINVAL; | 1632 | int err = -EINVAL; |
1633 | const struct perf_evsel_str_handler handlers[] = { | ||
1634 | { "sched:sched_switch", process_sched_switch_event, }, | ||
1635 | { "sched:sched_stat_runtime", process_sched_runtime_event, }, | ||
1636 | { "sched:sched_wakeup", process_sched_wakeup_event, }, | ||
1637 | { "sched:sched_wakeup_new", process_sched_wakeup_event, }, | ||
1638 | { "sched:sched_process_fork", process_sched_fork_event, }, | ||
1639 | { "sched:sched_process_exit", process_sched_exit_event, }, | ||
1640 | { "sched:sched_migrate_task", process_sched_migrate_task_event, }, | ||
1641 | }; | ||
1643 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | 1642 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, |
1644 | 0, false, &event_ops); | 1643 | 0, false, &perf_sched); |
1645 | if (session == NULL) | 1644 | if (session == NULL) |
1646 | die("No Memory"); | 1645 | die("No Memory"); |
1647 | 1646 | ||
1647 | err = perf_evlist__set_tracepoints_handlers_array(session->evlist, handlers); | ||
1648 | assert(err == 0); | ||
1649 | |||
1648 | if (perf_session__has_traces(session, "record -R")) { | 1650 | if (perf_session__has_traces(session, "record -R")) { |
1649 | err = perf_session__process_events(session, &event_ops); | 1651 | err = perf_session__process_events(session, &perf_sched); |
1650 | if (err) | 1652 | if (err) |
1651 | die("Failed to process events, error %d", err); | 1653 | die("Failed to process events, error %d", err); |
1652 | 1654 | ||