diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-09-13 03:44:29 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-13 04:22:51 -0400 |
commit | 1fc35b29b4098aa3bf9fc9acb4c1615d0b5dd95d (patch) | |
tree | f4646be85f1f52c5f239ca47930958e85ed119ff /tools/perf | |
parent | b5fae128e41021889777f8ead810cbd2a8b249fc (diff) |
perf sched: Implement the 'perf sched record' subcommand
Implement the 'perf sched record' subcommand that adds a
default list of events, turns on raw sampling and system-wide
tracing and passes off the rest of the command to perf record.
This is more convenient than having to specify the events all
the time.
Before:
$ perf record -a -R -e sched:sched_switch:r -e sched:sched_stat_wait:r -e sched:sched_stat_sleep:r -e sched:sched_stat_iowait:r -e sched:sched_process_exit:r -e sched:sched_process_fork:r -e sched:sched_wakeup:r -e sched:sched_migrate_task:r -c 1 sleep 1
After:
$ perf sched record -f sleep 1
Also fix an assumption in the event string parser that assumed
that strings passed in can be modified. (In this case they wont
be as they come from a readonly constant section.)
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-sched.c | 39 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 3 |
2 files changed, 39 insertions, 3 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index b72544f2b964..ede40c1429a8 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1656,6 +1656,40 @@ static void setup_sorting(void) | |||
1656 | sort_dimension__add((char *)"pid", &cmp_pid); | 1656 | sort_dimension__add((char *)"pid", &cmp_pid); |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | static const char *record_args[] = { | ||
1660 | "record", | ||
1661 | "-a", | ||
1662 | "-R", | ||
1663 | "-c", "1", | ||
1664 | "-e", "sched:sched_switch:r", | ||
1665 | "-e", "sched:sched_stat_wait:r", | ||
1666 | "-e", "sched:sched_stat_sleep:r", | ||
1667 | "-e", "sched:sched_stat_iowait:r", | ||
1668 | "-e", "sched:sched_process_exit:r", | ||
1669 | "-e", "sched:sched_process_fork:r", | ||
1670 | "-e", "sched:sched_wakeup:r", | ||
1671 | "-e", "sched:sched_migrate_task:r", | ||
1672 | }; | ||
1673 | |||
1674 | static int __cmd_record(int argc, const char **argv) | ||
1675 | { | ||
1676 | unsigned int rec_argc, i, j; | ||
1677 | const char **rec_argv; | ||
1678 | |||
1679 | rec_argc = ARRAY_SIZE(record_args) + argc - 1; | ||
1680 | rec_argv = calloc(rec_argc + 1, sizeof(char *)); | ||
1681 | |||
1682 | for (i = 0; i < ARRAY_SIZE(record_args); i++) | ||
1683 | rec_argv[i] = strdup(record_args[i]); | ||
1684 | |||
1685 | for (j = 1; j < (unsigned int)argc; j++, i++) | ||
1686 | rec_argv[i] = argv[j]; | ||
1687 | |||
1688 | BUG_ON(i != rec_argc); | ||
1689 | |||
1690 | return cmd_record(i, rec_argv, NULL); | ||
1691 | } | ||
1692 | |||
1659 | int cmd_sched(int argc, const char **argv, const char *prefix __used) | 1693 | int cmd_sched(int argc, const char **argv, const char *prefix __used) |
1660 | { | 1694 | { |
1661 | symbol__init(); | 1695 | symbol__init(); |
@@ -1666,7 +1700,9 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used) | |||
1666 | if (!argc) | 1700 | if (!argc) |
1667 | usage_with_options(sched_usage, sched_options); | 1701 | usage_with_options(sched_usage, sched_options); |
1668 | 1702 | ||
1669 | if (!strncmp(argv[0], "lat", 3)) { | 1703 | if (!strncmp(argv[0], "rec", 3)) { |
1704 | return __cmd_record(argc, argv); | ||
1705 | } else if (!strncmp(argv[0], "lat", 3)) { | ||
1670 | trace_handler = &lat_ops; | 1706 | trace_handler = &lat_ops; |
1671 | if (argc > 1) { | 1707 | if (argc > 1) { |
1672 | argc = parse_options(argc, argv, latency_options, latency_usage, 0); | 1708 | argc = parse_options(argc, argv, latency_options, latency_usage, 0); |
@@ -1687,6 +1723,5 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used) | |||
1687 | usage_with_options(sched_usage, sched_options); | 1723 | usage_with_options(sched_usage, sched_options); |
1688 | } | 1724 | } |
1689 | 1725 | ||
1690 | |||
1691 | return 0; | 1726 | return 0; |
1692 | } | 1727 | } |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d06c66cd358b..034245e46817 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -525,7 +525,8 @@ static enum event_result parse_tracepoint_event(const char **strp, | |||
525 | 525 | ||
526 | flags = strchr(evt_name, ':'); | 526 | flags = strchr(evt_name, ':'); |
527 | if (flags) { | 527 | if (flags) { |
528 | *flags = '\0'; | 528 | /* split it out: */ |
529 | evt_name = strndup(evt_name, flags - evt_name); | ||
529 | flags++; | 530 | flags++; |
530 | } | 531 | } |
531 | 532 | ||