mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] perf, tools: Fix --delay option in stat man page
@ 2014-01-07 22:14 Andi Kleen
  2014-01-07 22:14 ` [PATCH 2/2] perf, tools: Add --delay support to perf record Andi Kleen
  2014-01-14 16:39 ` [tip:perf/core] perf stat: Fix --delay option in man page tip-bot for Andi Kleen
  0 siblings, 2 replies; 4+ messages in thread
From: Andi Kleen @ 2014-01-07 22:14 UTC (permalink / raw)
  To: acme; +Cc: jolsa, namhyung, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

The --delay option was documented as --initial-delay in the perf
stat manpage. Fix this.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/Documentation/perf-stat.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 80c7da6..29ee857 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -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.
 
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] perf, tools: Add --delay support to perf record
  2014-01-07 22:14 [PATCH 1/2] perf, tools: Fix --delay option in stat man page Andi Kleen
@ 2014-01-07 22:14 ` Andi Kleen
  2014-01-08  8:08   ` Namhyung Kim
  2014-01-14 16:39 ` [tip:perf/core] perf stat: Fix --delay option in man page tip-bot for Andi Kleen
  1 sibling, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2014-01-07 22:14 UTC (permalink / raw)
  To: acme; +Cc: jolsa, namhyung, linux-kernel, Andi Kleen

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. Add --delay to perf record too.
-D was already taken for record, so there is only a long option.

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                  | 5 +++--
 4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 43b42c4..e349151 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -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]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7c8020a..110158e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -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()
 };
 
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index b079304..d052f1d 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -268,6 +268,7 @@ struct perf_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 46dd4c2..4a70656 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -689,14 +689,15 @@ void perf_evsel__config(struct perf_evsel *evsel,
 	 * Disabling only independent events or group leaders,
 	 * keeping group members enabled.
 	 */
-	if (perf_evsel__is_group_leader(evsel))
+	if (perf_evsel__is_group_leader(evsel) || opts->initial_delay)
 		attr->disabled = 1;
 
 	/*
 	 * 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	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] perf, tools: Add --delay support to perf record
  2014-01-07 22:14 ` [PATCH 2/2] perf, tools: Add --delay support to perf record Andi Kleen
@ 2014-01-08  8:08   ` Namhyung Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2014-01-08  8:08 UTC (permalink / raw)
  To: Andi Kleen; +Cc: acme, jolsa, linux-kernel, Andi Kleen

Hi Andi,

On Tue,  7 Jan 2014 14:14:07 -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. Add --delay to perf record too.
> -D was already taken for record, so there is only a long option.
>
> 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                  | 5 +++--
>  4 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> index 43b42c4..e349151 100644
> --- a/tools/perf/Documentation/perf-record.txt
> +++ b/tools/perf/Documentation/perf-record.txt
> @@ -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]
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 7c8020a..110158e 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -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()
>  };
>  
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index b079304..d052f1d 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -268,6 +268,7 @@ struct perf_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 46dd4c2..4a70656 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -689,14 +689,15 @@ void perf_evsel__config(struct perf_evsel *evsel,
>  	 * Disabling only independent events or group leaders,
>  	 * keeping group members enabled.
>  	 */
> -	if (perf_evsel__is_group_leader(evsel))
> +	if (perf_evsel__is_group_leader(evsel) || opts->initial_delay)
>  		attr->disabled = 1;

It seems this hunk is not needed since it'll disable group member events
which is not what we want.  Note that the perf_evlist__enable/disable()
only work for the leaders.

Thanks,
Namhyung

>  
>  	/*
>  	 * 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	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf stat: Fix --delay option in man page
  2014-01-07 22:14 [PATCH 1/2] perf, tools: Fix --delay option in stat man page Andi Kleen
  2014-01-07 22:14 ` [PATCH 2/2] perf, tools: Add --delay support to perf record Andi Kleen
@ 2014-01-14 16:39 ` tip-bot for Andi Kleen
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Andi Kleen @ 2014-01-14 16:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, namhyung, jolsa, ak, tglx

Commit-ID:  8f3dd2b096c348033e55d4a4fb8c0f672559657e
Gitweb:     http://git.kernel.org/tip/8f3dd2b096c348033e55d4a4fb8c0f672559657e
Author:     Andi Kleen <ak@linux.intel.com>
AuthorDate: Tue, 7 Jan 2014 14:14:06 -0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 13 Jan 2014 10:06:24 -0300

perf stat: Fix --delay option in man page

The --delay option was documented as --initial-delay in the manpage. Fix this.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1389132847-31982-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-stat.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 80c7da6..29ee857 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -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.
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-14 16:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-07 22:14 [PATCH 1/2] perf, tools: Fix --delay option in stat man page Andi Kleen
2014-01-07 22:14 ` [PATCH 2/2] perf, tools: Add --delay support to perf record Andi Kleen
2014-01-08  8:08   ` Namhyung Kim
2014-01-14 16:39 ` [tip:perf/core] perf stat: Fix --delay option in man page 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

all inboxes | Powered by JetHome®