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 | 39 | --pid=:: |
| 40 | 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 | 46 | -a:: |
| 43 | 47 | --all-cpus:: |
| 44 | 48 | Force system-wide collection. Scripts run without a <command> |
| @@ -49,6 +49,7 @@ struct perf_ftrace { · 48 unmodified lines | ||
| 49 | 49 | int graph_noirqs; |
| 50 | 50 | int graph_verbose; |
| 51 | 51 | int graph_thresh; |
| 52 | + unsigned int initial_delay; | |
| 52 | 53 | }; |
| 53 | 54 | |
| 54 | 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 | 597 | /* display column headers */ |
| 597 | 598 | read_tracing_file_to_stdout("trace"); |
| 598 | 599 | |
| 599 | − if (write_tracing_file("tracing_on", "1") < 0) { | |
| 600 | − pr_err("can't enable tracing\n"); | |
| 601 | − goto out_close_fd; | |
| 600 | + if (!ftrace->initial_delay) { | |
| 601 | + if (write_tracing_file("tracing_on", "1") < 0) { | |
| 602 | + pr_err("can't enable tracing\n"); | |
| 603 | + goto out_close_fd; | |
| 604 | + } | |
| 602 | 605 | } |
| 603 | 606 | |
| 604 | 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 | 617 | while (!done) { |
| 607 | 618 | if (poll(&pollfd, 1, -1) < 0) |
| 608 | 619 | break; |
| @@ -827,6 +838,8 @@ int cmd_ftrace(int argc, const char **argv) · 218 unmodified lines | ||
| 827 | 838 | "size of per cpu buffer", parse_buffer_size), |
| 828 | 839 | OPT_BOOLEAN(0, "inherit", &ftrace.inherit, |
| 829 | 840 | "trace children processes"), |
| 841 | + OPT_UINTEGER('D', "delay", &ftrace.initial_delay, | |
| 842 | + "ms to wait before starting tracing after program start"), | |
| 830 | 843 | OPT_END() |
| 831 | 844 | }; |
| 832 | 845 | |