[PATCH RFC 07/10] perf,report: handle PERF_RECORD_COUNTER_READ

From: kan . liang
Date: Tue Sep 22 2015 - 17:31:49 EST


From: Kan Liang <kan.liang@xxxxxxxxx>

Add function to process PERF_RECORD_COUNTER_READ RECORD type event.
Simply print event name, cpu id, val and time information in
perf report -D.

Signed-off-by: Kan Liang <kan.liang@xxxxxxxxx>
---
tools/perf/builtin-report.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index e4e3f14..1d8dce2 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -207,6 +207,29 @@ static int process_read_event(struct perf_tool *tool,
return 0;
}

+static int process_counter_read_event(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct perf_session *session)
+{
+ struct perf_evlist *evlist = session->evlist;
+ struct perf_evsel *evsel;
+
+ evlist__for_each(evlist, evsel) {
+ if (evsel->idx == event->counter_read.idx)
+ break;
+ }
+
+ hists__inc_nr_events(evsel__hists(evsel), event->header.type);
+
+ dump_printf(": %s CPU %d: val %" PRIu64 " ena %" PRIu64 " run %" PRIu64 " \n",
+ evsel ? perf_evsel__name(evsel) : "FAIL",
+ event->counter_read.cpu,
+ event->counter_read.val,
+ event->counter_read.ena,
+ event->counter_read.run);
+ return 0;
+}
+
/* For pipe mode, sample_type is not currently set */
static int report__setup_sample_type(struct report *rep)
{
@@ -632,6 +655,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
.fork = perf_event__process_fork,
.lost = perf_event__process_lost,
.read = process_read_event,
+ .counter_read = process_counter_read_event,
.attr = perf_event__process_attr,
.tracing_data = perf_event__process_tracing_data,
.build_id = perf_event__process_build_id,
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/