Commit 6555c2f6 authored by Changbin Du's avatar Changbin Du Committed by Arnaldo Carvalho de Melo

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.
Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: http://lore.kernel.org/lkml/20200808023141.14227-16-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a8f87a5c
...@@ -39,6 +39,10 @@ OPTIONS ...@@ -39,6 +39,10 @@ OPTIONS
--pid=:: --pid=::
Trace on existing process id (comma separated list). Trace on existing process id (comma separated list).
-D::
--delay::
Time (ms) to wait before starting tracing after program start.
-a:: -a::
--all-cpus:: --all-cpus::
Force system-wide collection. Scripts run without a <command> Force system-wide collection. Scripts run without a <command>
......
...@@ -49,6 +49,7 @@ struct perf_ftrace { ...@@ -49,6 +49,7 @@ struct perf_ftrace {
int graph_noirqs; int graph_noirqs;
int graph_verbose; int graph_verbose;
int graph_thresh; int graph_thresh;
unsigned int initial_delay;
}; };
struct filter_entry { struct filter_entry {
...@@ -596,13 +597,23 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) ...@@ -596,13 +597,23 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
/* display column headers */ /* display column headers */
read_tracing_file_to_stdout("trace"); read_tracing_file_to_stdout("trace");
if (write_tracing_file("tracing_on", "1") < 0) { if (!ftrace->initial_delay) {
pr_err("can't enable tracing\n"); if (write_tracing_file("tracing_on", "1") < 0) {
goto out_close_fd; pr_err("can't enable tracing\n");
goto out_close_fd;
}
} }
perf_evlist__start_workload(ftrace->evlist); perf_evlist__start_workload(ftrace->evlist);
if (ftrace->initial_delay) {
usleep(ftrace->initial_delay * 1000);
if (write_tracing_file("tracing_on", "1") < 0) {
pr_err("can't enable tracing\n");
goto out_close_fd;
}
}
while (!done) { while (!done) {
if (poll(&pollfd, 1, -1) < 0) if (poll(&pollfd, 1, -1) < 0)
break; break;
...@@ -827,6 +838,8 @@ int cmd_ftrace(int argc, const char **argv) ...@@ -827,6 +838,8 @@ int cmd_ftrace(int argc, const char **argv)
"size of per cpu buffer", parse_buffer_size), "size of per cpu buffer", parse_buffer_size),
OPT_BOOLEAN(0, "inherit", &ftrace.inherit, OPT_BOOLEAN(0, "inherit", &ftrace.inherit,
"trace children processes"), "trace children processes"),
OPT_UINTEGER('D', "delay", &ftrace.initial_delay,
"ms to wait before starting tracing after program start"),
OPT_END() OPT_END()
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment