Skip to contentSkip to conversation

perf, tools, record: Support recording running/enabled time

PATCH Applied Andi Kleen 5 participants 5 messages Feb 24, 2015 – Feb 26, 2015 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 perf, tools, record: Support recording running/enabled time

From: Andi Kleen <[email protected]>

Add an option to perf record to record running/enabled time for read events, similar to what stat does.

This is useful to understand multiplexing problems.

Right now the report support is not great, but at least report -D already supports it.

---
 tools/perf/Documentation/perf-record.txt | 3 +++
 tools/perf/builtin-record.c              | 2 ++
 tools/perf/perf.h                        | 1 +
 tools/perf/util/evsel.c                  | 6 ++++++
 4 files changed, 12 insertions(+)
tools/perf/Documentation/perf-record.txt +3 -0
index 1c7e50f..f293e96 100644
@@ -241,6 +241,9 @@ Capture machine state (registers) at interrupt, i.e., on counter overflows for
 each sample. List of captured registers depends on the architecture. This option
 is off by default.
 
+--running::
+Record running and enabled time for read events (:S)
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +2 -0
index d0d02a8..4fdad06 100644
@@ -839,6 +839,8 @@ struct option __record_options[] = {
 		    "use per-thread mmaps"),
 	OPT_BOOLEAN('I', "intr-regs", &record.opts.sample_intr_regs,
 		    "Sample machine registers on interrupt"),
+	OPT_BOOLEAN(0, "running-time", &record.opts.running_time,
+		    "Record running/enabled time of read (:S) events"),
 	OPT_END()
 };
 
tools/perf/perf.h +1 -0
index 1dabb85..1caa70a 100644
@@ -53,6 +53,7 @@ struct record_opts {
 	bool	     sample_time;
 	bool	     period;
 	bool	     sample_intr_regs;
+	bool	     running_time;
 	unsigned int freq;
 	unsigned int mmap_pages;
 	unsigned int user_freq;
tools/perf/util/evsel.c +6 -0
index f93e520..bb4eff2 100644
@@ -734,6 +734,12 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 	if (opts->sample_transaction)
 		perf_evsel__set_sample_bit(evsel, TRANSACTION);
 
+	if (opts->running_time) {
+		evsel->attr.read_format |=
+			PERF_FORMAT_TOTAL_TIME_ENABLED |
+			PERF_FORMAT_TOTAL_TIME_RUNNING;
+	}
+
 	/*
 	 * XXX see the function comment above
 	 *
Signature · 1 line
1.9.3
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andi Kleen

From: Andi Kleen <[email protected]>

Add an option to perf record to record running/enabled time for read events, similar to what stat does.

This is useful to understand multiplexing problems.

Right now the report support is not great, but at least report -D already supports it.

yep, report -D displays it nicely

thanks,
jirka

maintainer Applied
#2 lore raw

Em Wed, Feb 25, 2015 at 04:13:06PM +0100, Jiri Olsa escreveu:

Quoted 6 lines · Andi Kleen
Quoted 5 lines

From: Andi Kleen <[email protected]>

Add an option to perf record to record running/enabled time for read events, similar to what stat does.

Quoted 8 lines
Quoted 4 lines

This is useful to understand multiplexing problems.

Right now the report support is not great, but at least report -D already supports it.

yep, report -D displays it nicely

Thanks, applied.

- Arnaldo

#3 lore raw
In reply to Andi Kleen
Quoted 17 lines · Andi Kleen
tools/perf/Documentation/perf-record.txt +3 -0
@@ -241,6 +241,9 @@ Capture machine state (registers) at interrupt, i.e., on counter overflows for
  each sample. List of captured registers depends on the architecture. This option
  is off by default.
 
+--running::
+Record running and enabled time for read events (:S)
+
  SEE ALSO
  --------
  linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +0 -0
index d0d02a8..4fdad06 100644

tools/perf/builtin-record.c struct option __record_options[] = { · line 844

Quoted 6 lines
tools/perf/builtin-record.c +2 -0
@@ -839,6 +839,8 @@ struct option __record_options[] = {
  		    "use per-thread mmaps"),
  	OPT_BOOLEAN('I', "intr-regs", &record.opts.sample_intr_regs,
  		    "Sample machine registers on interrupt"),
+	OPT_BOOLEAN(0, "running-time", &record.opts.running_time,
+		    "Record running/enabled time of read (:S) events"),
  	OPT_END()

Documentation differs from option in the record command.

David

#4 lore raw

[tip:perf/core] perf record: Support recording running/ enabled time

In reply to Andi Kleen
perf record: Support recording running/enabled time
Commit-ID:  85c273d2b6569706762cf400079ca0699e007d81
Gitweb:     http://git.kernel.org/tip/85c273d2b6569706762cf400079ca0699e007d81
Author:     Andi Kleen <[email protected]>
AuthorDate: Tue, 24 Feb 2015 15:13:40 -0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 25 Feb 2015 12:42:23 -0300

perf record: Support recording running/enabled time

Add an option to perf record to record running/enabled time for read events, similar to what stat does.

This is useful to understand multiplexing problems.

Right now the report support is not great, but at least report -D already supports it.

Cc Namhyung Kim <[email protected]>
[ Fixed the Documentation entry to match the OPT_BOOLEAN one ]
---
 tools/perf/Documentation/perf-record.txt | 3 +++
 tools/perf/builtin-record.c              | 2 ++
 tools/perf/perf.h                        | 1 +
 tools/perf/util/evsel.c                  | 6 ++++++
 4 files changed, 12 insertions(+)
tools/perf/Documentation/perf-record.txt +3 -0
index 1c7e50f..cae75c1 100644
@@ -241,6 +241,9 @@ Capture machine state (registers) at interrupt, i.e., on counter overflows for
 each sample. List of captured registers depends on the architecture. This option
 is off by default.
 
+--running-time::
+Record running and enabled time for read events (:S)
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +2 -0
index d0d02a8..4fdad06 100644
@@ -839,6 +839,8 @@ struct option __record_options[] = {
 		    "use per-thread mmaps"),
 	OPT_BOOLEAN('I', "intr-regs", &record.opts.sample_intr_regs,
 		    "Sample machine registers on interrupt"),
+	OPT_BOOLEAN(0, "running-time", &record.opts.running_time,
+		    "Record running/enabled time of read (:S) events"),
 	OPT_END()
 };
 
tools/perf/perf.h +1 -0
index 1dabb85..1caa70a 100644
@@ -53,6 +53,7 @@ struct record_opts {
 	bool	     sample_time;
 	bool	     period;
 	bool	     sample_intr_regs;
+	bool	     running_time;
 	unsigned int freq;
 	unsigned int mmap_pages;
 	unsigned int user_freq;
tools/perf/util/evsel.c +6 -0
index f93e520..bb4eff2 100644
@@ -734,6 +734,12 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 	if (opts->sample_transaction)
 		perf_evsel__set_sample_bit(evsel, TRANSACTION);
 
+	if (opts->running_time) {
+		evsel->attr.read_format |=
+			PERF_FORMAT_TOTAL_TIME_ENABLED |
+			PERF_FORMAT_TOTAL_TIME_RUNNING;
+	}
+
 	/*
 	 * XXX see the function comment above
 	 *