Browse Source

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.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1424819620-16043-1-git-send-email-andi@firstfloor.org
[ Fixed the Documentation entry to match the OPT_BOOLEAN one ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Andi Kleen 10 years ago
parent
commit
85c273d2b6

+ 3 - 0
tools/perf/Documentation/perf-record.txt

@@ -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
 each sample. List of captured registers depends on the architecture. This option
 is off by default.
 is off by default.
 
 
+--running-time::
+Record running and enabled time for read events (:S)
+
 SEE ALSO
 SEE ALSO
 --------
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1]
 linkperf:perf-stat[1], linkperf:perf-list[1]

+ 2 - 0
tools/perf/builtin-record.c

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

+ 1 - 0
tools/perf/perf.h

@@ -53,6 +53,7 @@ struct record_opts {
 	bool	     sample_time;
 	bool	     sample_time;
 	bool	     period;
 	bool	     period;
 	bool	     sample_intr_regs;
 	bool	     sample_intr_regs;
+	bool	     running_time;
 	unsigned int freq;
 	unsigned int freq;
 	unsigned int mmap_pages;
 	unsigned int mmap_pages;
 	unsigned int user_freq;
 	unsigned int user_freq;

+ 6 - 0
tools/perf/util/evsel.c

@@ -734,6 +734,12 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 	if (opts->sample_transaction)
 	if (opts->sample_transaction)
 		perf_evsel__set_sample_bit(evsel, 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
 	 * XXX see the function comment above
 	 *
 	 *