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
3939 --pid=::
4040 Trace on existing process id (comma separated list).
4141
42+-D::
43+--delay::
44+ Time (ms) to wait before starting tracing after program start.
45+
4246 -a::
4347 --all-cpus::
4448 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
4949 int graph_noirqs;
5050 int graph_verbose;
5151 int graph_thresh;
52+ unsigned int initial_delay;
5253 };
5354
5455 struct filter_entry {
@@ -596,13 +597,23 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) · 541 unmodified lines
596597 /* display column headers */
597598 read_tracing_file_to_stdout("trace");
598599
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+ }
602605 }
603606
604607 perf_evlist__start_workload(ftrace->evlist);
605608
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+
606617 while (!done) {
607618 if (poll(&pollfd, 1, -1) < 0)
608619 break;
@@ -827,6 +838,8 @@ int cmd_ftrace(int argc, const char **argv) · 218 unmodified lines
827838 "size of per cpu buffer", parse_buffer_size),
828839 OPT_BOOLEAN(0, "inherit", &ftrace.inherit,
829840 "trace children processes"),
841+ OPT_UINTEGER('D', "delay", &ftrace.initial_delay,
842+ "ms to wait before starting tracing after program start"),
830843 OPT_END()
831844 };
832845

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