This adds an option '-D/--delay' to allow us to start tracing some times later after workload is launched.
Unified · Split
| @@ -39,6 +39,10 @@ OPTIONS · 38 unmodified lines | |||
| 39 | --pid=:: | 39 | --pid=:: |
| 40 | Trace on existing process id (comma separated list). | 40 | Trace on existing process id (comma separated list). |
| 41 | 41 | ||
| 42 | -D:: | ||
| 43 | --delay:: | ||
| 44 | Time (ms) to wait before starting tracing after program start. | ||
| 45 | |||
| 42 | -a:: | 46 | -a:: |
| 43 | --all-cpus:: | 47 | --all-cpus:: |
| 44 | Force system-wide collection. Scripts run without a <command> | 48 | Force system-wide collection. Scripts run without a <command> |
| @@ -49,6 +49,7 @@ struct perf_ftrace { · 48 unmodified lines | |||
| 49 | int graph_noirqs; | 49 | int graph_noirqs; |
| 50 | int graph_verbose; | 50 | int graph_verbose; |
| 51 | int graph_thresh; | 51 | int graph_thresh; |
| 52 | unsigned int initial_delay; | ||
| 52 | }; | 53 | }; |
| 53 | 54 | ||
| 54 | struct filter_entry { | 55 | struct filter_entry { |
| @@ -596,13 +597,23 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) · 541 unmodified lines | |||
| 596 | /* display column headers */ | 597 | /* display column headers */ |
| 597 | read_tracing_file_to_stdout("trace"); | 598 | read_tracing_file_to_stdout("trace"); |
| 598 | 599 | ||
| 599 | if (write_tracing_file("tracing_on", "1") < 0) { | 600 | if (!ftrace->initial_delay) { |
| 600 | pr_err("can't enable tracing\n"); | 601 | if (write_tracing_file("tracing_on", "1") < 0) { |
| 601 | goto out_close_fd; | 602 | pr_err("can't enable tracing\n"); |
| 603 | goto out_close_fd; | ||
| 604 | } | ||
| 602 | } | 605 | } |
| 603 | 606 | ||
| 604 | perf_evlist__start_workload(ftrace->evlist); | 607 | perf_evlist__start_workload(ftrace->evlist); |
| 605 | 608 | ||
| 609 | if (ftrace->initial_delay) { | ||
| 610 | usleep(ftrace->initial_delay * 1000); | ||
| 611 | if (write_tracing_file("tracing_on", "1") < 0) { | ||
| 612 | pr_err("can't enable tracing\n"); | ||
| 613 | goto out_close_fd; | ||
| 614 | } | ||
| 615 | } | ||
| 616 | |||
| 606 | while (!done) { | 617 | while (!done) { |
| 607 | if (poll(&pollfd, 1, -1) < 0) | 618 | if (poll(&pollfd, 1, -1) < 0) |
| 608 | break; | 619 | break; |
| @@ -827,6 +838,8 @@ int cmd_ftrace(int argc, const char **argv) · 218 unmodified lines | |||
| 827 | "size of per cpu buffer", parse_buffer_size), | 838 | "size of per cpu buffer", parse_buffer_size), |
| 828 | OPT_BOOLEAN(0, "inherit", &ftrace.inherit, | 839 | OPT_BOOLEAN(0, "inherit", &ftrace.inherit, |
| 829 | "trace children processes"), | 840 | "trace children processes"), |
| 841 | OPT_UINTEGER('D', "delay", &ftrace.initial_delay, | ||
| 842 | "ms to wait before starting tracing after program start"), | ||
| 830 | OPT_END() | 843 | OPT_END() |
| 831 | }; | 844 | }; |
| 832 | 845 | ||