History

perf ftrace: Add option -D/--delay to delay tracing

This adds an option '-D/--delay' to allow us to start tracing some times later after workload is launched.

Changbin Du committed 6 years ago

Commit 6555c2f1 parent a8f87a52 files · +20 −3Browse files

Unified · Split

2 files
  1. tools/perf/Documentation/perf-ftrace.txt +4 −0
  2. tools/perf/builtin-ftrace.c +16 −3
tools/perf/Documentation/perf-ftrace.txt+4−0
@@ -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>
tools/perf/builtin-ftrace.c+16−3
@@ -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
54struct filter_entry {55struct 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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t