diff options
-rw-r--r-- | tools/perf/Documentation/perf-record.txt | 4 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 9 | ||||
-rw-r--r-- | tools/perf/perf.h | 1 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 3 |
4 files changed, 15 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index c407897f0435..82bffac036e1 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt | |||
@@ -209,6 +209,10 @@ overrides that and uses per-thread mmaps. A side-effect of that is that | |||
209 | inheritance is automatically disabled. --per-thread is ignored with a warning | 209 | inheritance is automatically disabled. --per-thread is ignored with a warning |
210 | if combined with -a or -C options. | 210 | if combined with -a or -C options. |
211 | 211 | ||
212 | --initial-delay msecs:: | ||
213 | After starting the program, wait msecs before measuring. This is useful to | ||
214 | filter out the startup phase of the program, which is often very different. | ||
215 | |||
212 | SEE ALSO | 216 | SEE ALSO |
213 | -------- | 217 | -------- |
214 | linkperf:perf-stat[1], linkperf:perf-list[1] | 218 | linkperf:perf-stat[1], linkperf:perf-list[1] |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 88600158400e..07d4cf8d3fd3 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -499,7 +499,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
499 | * (apart from group members) have enable_on_exec=1 set, | 499 | * (apart from group members) have enable_on_exec=1 set, |
500 | * so don't spoil it by prematurely enabling them. | 500 | * so don't spoil it by prematurely enabling them. |
501 | */ | 501 | */ |
502 | if (!target__none(&opts->target)) | 502 | if (!target__none(&opts->target) && !opts->initial_delay) |
503 | perf_evlist__enable(rec->evlist); | 503 | perf_evlist__enable(rec->evlist); |
504 | 504 | ||
505 | /* | 505 | /* |
@@ -508,6 +508,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
508 | if (forks) | 508 | if (forks) |
509 | perf_evlist__start_workload(rec->evlist); | 509 | perf_evlist__start_workload(rec->evlist); |
510 | 510 | ||
511 | if (opts->initial_delay) { | ||
512 | usleep(opts->initial_delay * 1000); | ||
513 | perf_evlist__enable(rec->evlist); | ||
514 | } | ||
515 | |||
511 | for (;;) { | 516 | for (;;) { |
512 | int hits = rec->samples; | 517 | int hits = rec->samples; |
513 | 518 | ||
@@ -877,6 +882,8 @@ const struct option record_options[] = { | |||
877 | OPT_CALLBACK('G', "cgroup", &record.evlist, "name", | 882 | OPT_CALLBACK('G', "cgroup", &record.evlist, "name", |
878 | "monitor event in cgroup name only", | 883 | "monitor event in cgroup name only", |
879 | parse_cgroups), | 884 | parse_cgroups), |
885 | OPT_UINTEGER(0, "initial-delay", &record.opts.initial_delay, | ||
886 | "ms to wait before starting measurement after program start"), | ||
880 | OPT_STRING('u', "uid", &record.opts.target.uid_str, "user", | 887 | OPT_STRING('u', "uid", &record.opts.target.uid_str, "user", |
881 | "user to profile"), | 888 | "user to profile"), |
882 | 889 | ||
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index b1cc84b01d5b..af1ce6e14a93 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -269,6 +269,7 @@ struct record_opts { | |||
269 | u64 user_interval; | 269 | u64 user_interval; |
270 | u16 stack_dump_size; | 270 | u16 stack_dump_size; |
271 | bool sample_transaction; | 271 | bool sample_transaction; |
272 | unsigned initial_delay; | ||
272 | }; | 273 | }; |
273 | 274 | ||
274 | #endif | 275 | #endif |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ade8d9c1c431..cd4630abfa43 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -658,7 +658,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) | |||
658 | * Setting enable_on_exec for independent events and | 658 | * Setting enable_on_exec for independent events and |
659 | * group leaders for traced executed by perf. | 659 | * group leaders for traced executed by perf. |
660 | */ | 660 | */ |
661 | if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel)) | 661 | if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel) && |
662 | !opts->initial_delay) | ||
662 | attr->enable_on_exec = 1; | 663 | attr->enable_on_exec = 1; |
663 | } | 664 | } |
664 | 665 | ||