* [PATCH] perf, tools: Add --initial-delay support to perf record v3
@ 2014-01-11 21:38 Andi Kleen
2014-01-13 8:57 ` Namhyung Kim
2014-01-14 16:41 ` [tip:perf/core] perf record: Add --initial-delay option tip-bot for Andi Kleen
0 siblings, 2 replies; 3+ messages in thread
From: Andi Kleen @ 2014-01-11 21:38 UTC (permalink / raw)
To: acme; +Cc: jolsa, linux-kernel, Andi Kleen, Namhyung Kim
From: Andi Kleen <ak@linux.intel.com>
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.
--no-delay was already taken, so add a --initial-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)
v3: port to latest perf/core
rename to --initial-delay to avoid conflict with --no-delay
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
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(-)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index c407897..82bffac 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
inheritance is automatically disabled. --per-thread is ignored with a warning
if combined with -a or -C options.
+--initial-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]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 8860015..07d4cf8 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)
* (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(rec->evlist);
/*
@@ -508,6 +508,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
if (forks)
perf_evlist__start_workload(rec->evlist);
+ if (opts->initial_delay) {
+ usleep(opts->initial_delay * 1000);
+ perf_evlist__enable(rec->evlist);
+ }
+
for (;;) {
int hits = rec->samples;
@@ -877,6 +882,8 @@ const struct option record_options[] = {
OPT_CALLBACK('G', "cgroup", &record.evlist, "name",
"monitor event in cgroup name only",
parse_cgroups),
+ OPT_UINTEGER(0, "initial-delay", &record.opts.initial_delay,
+ "ms to wait before starting measurement after program start"),
OPT_STRING('u', "uid", &record.opts.target.uid_str, "user",
"user to profile"),
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index b1cc84b..af1ce6e 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -269,6 +269,7 @@ struct record_opts {
u64 user_interval;
u16 stack_dump_size;
bool sample_transaction;
+ unsigned initial_delay;
};
#endif
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ade8d9c..cd4630a 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)
* 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;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf, tools: Add --initial-delay support to perf record v3
2014-01-11 21:38 [PATCH] perf, tools: Add --initial-delay support to perf record v3 Andi Kleen
@ 2014-01-13 8:57 ` Namhyung Kim
2014-01-14 16:41 ` [tip:perf/core] perf record: Add --initial-delay option tip-bot for Andi Kleen
1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2014-01-13 8:57 UTC (permalink / raw)
To: Andi Kleen; +Cc: acme, jolsa, linux-kernel, Andi Kleen
Hi Andi,
On Sat, 11 Jan 2014 13:38:27 -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> 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.
>
> --no-delay was already taken, so add a --initial-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)
> v3: port to latest perf/core
> rename to --initial-delay to avoid conflict with --no-delay
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:perf/core] perf record: Add --initial-delay option
2014-01-11 21:38 [PATCH] perf, tools: Add --initial-delay support to perf record v3 Andi Kleen
2014-01-13 8:57 ` Namhyung Kim
@ 2014-01-14 16:41 ` tip-bot for Andi Kleen
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Andi Kleen @ 2014-01-14 16:41 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, namhyung, jolsa, ak, tglx
Commit-ID: 6619a53ef7572b9eaf7aa71ff7f74c0d06b3817b
Gitweb: http://git.kernel.org/tip/6619a53ef7572b9eaf7aa71ff7f74c0d06b3817b
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Sat, 11 Jan 2014 13:38:27 -0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 13 Jan 2014 10:07:03 -0300
perf record: Add --initial-delay option
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.
--no-delay was already taken, so add a --initial-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)
v3: port to latest perf/core
rename to --initial-delay to avoid conflict with --no-delay
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1389476307-2124-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
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(-)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index c407897..82bffac 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
inheritance is automatically disabled. --per-thread is ignored with a warning
if combined with -a or -C options.
+--initial-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]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 8860015..07d4cf8 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)
* (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(rec->evlist);
/*
@@ -508,6 +508,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
if (forks)
perf_evlist__start_workload(rec->evlist);
+ if (opts->initial_delay) {
+ usleep(opts->initial_delay * 1000);
+ perf_evlist__enable(rec->evlist);
+ }
+
for (;;) {
int hits = rec->samples;
@@ -877,6 +882,8 @@ const struct option record_options[] = {
OPT_CALLBACK('G', "cgroup", &record.evlist, "name",
"monitor event in cgroup name only",
parse_cgroups),
+ OPT_UINTEGER(0, "initial-delay", &record.opts.initial_delay,
+ "ms to wait before starting measurement after program start"),
OPT_STRING('u', "uid", &record.opts.target.uid_str, "user",
"user to profile"),
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index b1cc84b..af1ce6e 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -269,6 +269,7 @@ struct record_opts {
u64 user_interval;
u16 stack_dump_size;
bool sample_transaction;
+ unsigned initial_delay;
};
#endif
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ade8d9c..cd4630a 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)
* 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;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-14 16:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-11 21:38 [PATCH] perf, tools: Add --initial-delay support to perf record v3 Andi Kleen
2014-01-13 8:57 ` Namhyung Kim
2014-01-14 16:41 ` [tip:perf/core] perf record: Add --initial-delay option tip-bot for Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox