aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-09-11 06:12:54 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-13 04:22:49 -0400
commitf2858d8ad9858e63c87257553c5721cba5db95ae (patch)
tree6b3d74454ec63901f28d0acd2144429167ec6fcb
parentdaa1d7a5eafc0a3a91a9add6a9a9f1bcaed63108 (diff)
perf sched: Add 'perf sched latency' and 'perf sched replay'
Separate the option parsing cleanly and add two variants: - 'perf sched latency' (can be abbreviated via 'perf sched lat') - 'perf sched replay' (can be abbreviated via 'perf sched rep') Also add a repeat count option to replay and add a separation set of options for replay. Do the sorting setup only in the latency sub-command. Display separate help screens for 'perf sched' and 'perf sched replay -h' - i.e. further separation of the sub-commands. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/builtin-sched.c90
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;
30static struct perf_header *header; 30static struct perf_header *header;
31static u64 sample_type; 31static u64 sample_type;
32 32
33static int replay_mode;
34static int lat_mode;
35
36static char default_sort_order[] = "avg, max, switch, runtime"; 33static char default_sort_order[] = "avg, max, switch, runtime";
37static char *sort_order = default_sort_order; 34static 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
623static unsigned long replay_repeat = 10;
624
626static void __cmd_replay(void) 625static 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
1625static const char * const sched_usage[] = { 1624static 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
1630static const struct option options[] = { 1629static 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"), 1637static const char * const latency_usage[] = {
1638 "perf sched latency [<options>]",
1639 NULL
1640};
1641
1642static 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
1652static const char * const replay_usage[] = {
1653 "perf sched replay [<options>]",
1654 NULL
1655};
1656
1657static 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}