perf, tools: Fix --delay option in stat man page
PATCH 1/2 perf, tools: Fix --delay option in stat man page
From: Andi Kleen <[email protected]>
The --delay option was documented as --initial-delay in the perf stat manpage. Fix this.
--- tools/perf/Documentation/perf-stat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Documentation/perf-stat.txt +1 -1
@@ -133,7 +133,7 @@ use --per-core in addition to -a. (system-wide). The output includes the core number and the number of online logical processors on that physical processor. -D msecs:: ---initial-delay msecs:: +--delay msecs:: After starting the program, wait msecs before measuring. This is useful to filter out the startup phase of the program, which is often very different.
Signature · 1 line
1.8.3.1
PATCH 2/2 perf, tools: Add --delay support to perf record v2
From: Andi Kleen <[email protected]>
perf stat has a --delay option to delay measuring the workload. This is useful to skip measuring the startup phase of the program, which is often very different from the main workload.
The same is useful for perf record when sampling. Add --delay to perf record too. -D was already taken for record, so there is only a long option.
v2: Don't disable group members (Namhyung Kim)
--- tools/perf/Documentation/perf-record.txt | 4 ++++ tools/perf/builtin-record.c | 9 ++++++++- tools/perf/perf.h | 1 + tools/perf/util/evsel.c | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-record.txt +4 -0
@@ -207,6 +207,10 @@ Force the use of per-cpu mmaps. By default, when tasks are specified (i.e. -p, forces per-cpu mmaps. A side-effect of that is that inheritance is automatically enabled. Add the -i option also to disable inheritance. +--delay msecs:: +After starting the program, wait msecs before measuring. This is useful to +filter out the startup phase of the program, which is often very different. + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +8 -1
@@ -506,7 +506,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)* (apart from group members) have enable_on_exec=1 set, * so don't spoil it by prematurely enabling them. */ -if (!target__none (&opts->target)) +if (!target__none (&opts->target) && !opts->initial_delay)perf_evlist__enable (evsel_list);/*
@@ -515,6 +515,11 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)if (forks)perf_evlist__start_workload (evsel_list); +if (opts->initial_delay) { +usleep (opts->initial_delay *1000 ); +perf_evlist__enable (evsel_list); + } +for (;;) {int hits = rec->samples;
@@ -890,6 +895,8 @@ const struct option record_options[] = { "sample transaction flags (special events only)"),OPT_BOOLEAN (0 ,"force-per-cpu" , &record.opts.target.force_per_cpu,"force the use of per-cpu mmaps" ), +OPT_UINTEGER (0 ,"delay" , &record.opts.initial_delay, +"ms to wait before starting measurement after program start" ), OPT_END() };
tools/perf/perf.h +1 -0
@@ -268,6 +268,7 @@ struct perf_record_opts {u64 user_interval;u16 stack_dump_size;bool sample_transaction; + unsigned initial_delay; };#endif
tools/perf/util/evsel.c +2 -1
@@ -696,7 +696,8 @@ void perf_evsel__config(struct perf_evsel *evsel,* Setting enable_on_exec for independent events and * group leaders for traced executed by perf. */ -if (target__none (&opts->target) &&perf_evsel__is_group_leader (evsel)) +if (target__none (&opts->target) &&perf_evsel__is_group_leader (evsel) && + !opts->initial_delay) attr->enable_on_exec =1 ; }
Signature · 1 line
1.8.3.1
Re: [PATCH 2/2] perf, tools: Add --delay support to perf record v2
Quoted 48 lines · Andi Kleen
From: Andi Kleen <[email protected]>
perf stat has a --delay option to delay measuring the workload. This is useful to skip measuring the startup phase of the program, which is often very different from the main workload.
The same is useful for perf record when sampling. Add --delay to perf record too. -D was already taken for record, so there is only a long option.
v2: Don't disable group members (Namhyung Kim)
Cc Namhyung Kim <[email protected]>Signed-off-by Andi Kleen <[email protected]>--- tools/perf/Documentation/perf-record.txt | 4 ++++ tools/perf/builtin-record.c | 9 ++++++++- tools/perf/perf.h | 1 + tools/perf/util/evsel.c | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-)tools/perf/Documentation/perf-record.txt +4
-0@@ -207,6 +207,10 @@ Force the use of per-cpu mmaps. By default, when tasks are specified (i.e. -p, forces per-cpu mmaps. A side-effect of that is that inheritance is automatically enabled. Add the -i option also to disable inheritance. +--delay msecs:: +After starting the program, wait msecs before measuring. This is useful to +filter out the startup phase of the program, which is often very different. + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-list[1]tools/perf/builtin-record.c +1
-1@@ -506,7 +506,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)* (apart from group members) have enable_on_exec=1 set, * so don't spoil it by prematurely enabling them. */ -if (!target__none (&opts->target)) +if (!target__none (&opts->target) && !opts->initial_delay)perf_evlist__enable (evsel_list);/*
tools/perf/builtin-record.c static int __cmd_record(struct perf_record *rec, int argc, const char **argv) · line 522
Quoted 8 lines
tools/perf/builtin-record.c +5
-0@@ -515,6 +515,11 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)if (forks)perf_evlist__start_workload (evsel_list); +if (opts->initial_delay) { +usleep (opts->initial_delay *1000 ); +perf_evlist__enable (evsel_list); + } +
evsel_list no longer works due to:
6346015 perf record: Remove old evsel_list usage
jirka