diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-sched.c | 90 |
1 files changed, 58 insertions, 32 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 10fcd49e298b..e01cc63b98cc 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -30,9 +30,6 @@ static struct thread *last_match; | |||
30 | static struct perf_header *header; | 30 | static struct perf_header *header; |
31 | static u64 sample_type; | 31 | static u64 sample_type; |
32 | 32 | ||
33 | static int replay_mode; | ||
34 | static int lat_mode; | ||
35 | |||
36 | static char default_sort_order[] = "avg, max, switch, runtime"; | 33 | static char default_sort_order[] = "avg, max, switch, runtime"; |
37 | static char *sort_order = default_sort_order; | 34 | static char *sort_order = default_sort_order; |
38 | 35 | ||
@@ -623,9 +620,11 @@ static void test_calibrations(void) | |||
623 | printf("the sleep test took %Ld nsecs\n", T1-T0); | 620 | printf("the sleep test took %Ld nsecs\n", T1-T0); |
624 | } | 621 | } |
625 | 622 | ||
623 | static unsigned long replay_repeat = 10; | ||
624 | |||
626 | static void __cmd_replay(void) | 625 | static void __cmd_replay(void) |
627 | { | 626 | { |
628 | long nr_iterations = 10, i; | 627 | unsigned long i; |
629 | 628 | ||
630 | calibrate_run_measurement_overhead(); | 629 | calibrate_run_measurement_overhead(); |
631 | calibrate_sleep_measurement_overhead(); | 630 | calibrate_sleep_measurement_overhead(); |
@@ -651,7 +650,7 @@ static void __cmd_replay(void) | |||
651 | 650 | ||
652 | create_tasks(); | 651 | create_tasks(); |
653 | printf("------------------------------------------------------------\n"); | 652 | printf("------------------------------------------------------------\n"); |
654 | for (i = 0; i < nr_iterations; i++) | 653 | for (i = 0; i < replay_repeat; i++) |
655 | run_one_test(); | 654 | run_one_test(); |
656 | } | 655 | } |
657 | 656 | ||
@@ -1623,21 +1622,45 @@ more: | |||
1623 | } | 1622 | } |
1624 | 1623 | ||
1625 | static const char * const sched_usage[] = { | 1624 | static const char * const sched_usage[] = { |
1626 | "perf sched [<options>] <command>", | 1625 | "perf sched [<options>] {record|latency|replay}", |
1627 | NULL | 1626 | NULL |
1628 | }; | 1627 | }; |
1629 | 1628 | ||
1630 | static const struct option options[] = { | 1629 | static const struct option sched_options[] = { |
1630 | OPT_BOOLEAN('v', "verbose", &verbose, | ||
1631 | "be more verbose (show symbol address, etc)"), | ||
1631 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 1632 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
1632 | "dump raw trace in ASCII"), | 1633 | "dump raw trace in ASCII"), |
1633 | OPT_BOOLEAN('r', "replay", &replay_mode, | 1634 | OPT_END() |
1634 | "replay sched behaviour from traces"), | 1635 | }; |
1635 | OPT_BOOLEAN('l', "latency", &lat_mode, | 1636 | |
1636 | "measure various latencies"), | 1637 | static const char * const latency_usage[] = { |
1638 | "perf sched latency [<options>]", | ||
1639 | NULL | ||
1640 | }; | ||
1641 | |||
1642 | static const struct option latency_options[] = { | ||
1637 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", | 1643 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", |
1638 | "sort by key(s): runtime, switch, avg, max"), | 1644 | "sort by key(s): runtime, switch, avg, max"), |
1639 | OPT_BOOLEAN('v', "verbose", &verbose, | 1645 | OPT_BOOLEAN('v', "verbose", &verbose, |
1640 | "be more verbose (show symbol address, etc)"), | 1646 | "be more verbose (show symbol address, etc)"), |
1647 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | ||
1648 | "dump raw trace in ASCII"), | ||
1649 | OPT_END() | ||
1650 | }; | ||
1651 | |||
1652 | static const char * const replay_usage[] = { | ||
1653 | "perf sched replay [<options>]", | ||
1654 | NULL | ||
1655 | }; | ||
1656 | |||
1657 | static const struct option replay_options[] = { | ||
1658 | OPT_INTEGER('r', "repeat", &replay_repeat, | ||
1659 | "repeat the workload replay N times (-1: infinite)"), | ||
1660 | OPT_BOOLEAN('v', "verbose", &verbose, | ||
1661 | "be more verbose (show symbol address, etc)"), | ||
1662 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | ||
1663 | "dump raw trace in ASCII"), | ||
1641 | OPT_END() | 1664 | OPT_END() |
1642 | }; | 1665 | }; |
1643 | 1666 | ||
@@ -1649,7 +1672,7 @@ static void setup_sorting(void) | |||
1649 | tok; tok = strtok_r(NULL, ", ", &tmp)) { | 1672 | tok; tok = strtok_r(NULL, ", ", &tmp)) { |
1650 | if (sort_dimension__add(tok, &sort_list) < 0) { | 1673 | if (sort_dimension__add(tok, &sort_list) < 0) { |
1651 | error("Unknown --sort key: `%s'", tok); | 1674 | error("Unknown --sort key: `%s'", tok); |
1652 | usage_with_options(sched_usage, options); | 1675 | usage_with_options(latency_usage, latency_options); |
1653 | } | 1676 | } |
1654 | } | 1677 | } |
1655 | 1678 | ||
@@ -1663,29 +1686,32 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used) | |||
1663 | symbol__init(); | 1686 | symbol__init(); |
1664 | page_size = getpagesize(); | 1687 | page_size = getpagesize(); |
1665 | 1688 | ||
1666 | argc = parse_options(argc, argv, options, sched_usage, 0); | 1689 | argc = parse_options(argc, argv, sched_options, sched_usage, |
1667 | if (argc) { | 1690 | PARSE_OPT_STOP_AT_NON_OPTION); |
1668 | /* | 1691 | if (!argc) |
1669 | * Special case: if there's an argument left then assume tha | 1692 | usage_with_options(sched_usage, sched_options); |
1670 | * it's a symbol filter: | ||
1671 | */ | ||
1672 | if (argc > 1) | ||
1673 | usage_with_options(sched_usage, options); | ||
1674 | } | ||
1675 | 1693 | ||
1676 | if (replay_mode) | 1694 | if (!strncmp(argv[0], "lat", 3)) { |
1677 | trace_handler = &replay_ops; | ||
1678 | else if (lat_mode) | ||
1679 | trace_handler = &lat_ops; | 1695 | trace_handler = &lat_ops; |
1680 | else | 1696 | if (argc > 1) { |
1681 | usage_with_options(sched_usage, options); | 1697 | argc = parse_options(argc, argv, latency_options, latency_usage, 0); |
1682 | 1698 | if (argc) | |
1683 | setup_sorting(); | 1699 | usage_with_options(latency_usage, latency_options); |
1684 | 1700 | setup_sorting(); | |
1685 | if (replay_mode) | 1701 | } |
1686 | __cmd_replay(); | ||
1687 | else if (lat_mode) | ||
1688 | __cmd_lat(); | 1702 | __cmd_lat(); |
1703 | } else if (!strncmp(argv[0], "rep", 3)) { | ||
1704 | trace_handler = &replay_ops; | ||
1705 | if (argc) { | ||
1706 | argc = parse_options(argc, argv, replay_options, replay_usage, 0); | ||
1707 | if (argc) | ||
1708 | usage_with_options(replay_usage, replay_options); | ||
1709 | } | ||
1710 | __cmd_replay(); | ||
1711 | } else { | ||
1712 | usage_with_options(sched_usage, sched_options); | ||
1713 | } | ||
1714 | |||
1689 | 1715 | ||
1690 | return 0; | 1716 | return 0; |
1691 | } | 1717 | } |