perf report: Add dump_read function
authorJiri Olsa <jolsa@kernel.org>
Thu, 24 Aug 2017 16:27:32 +0000 (18:27 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 28 Aug 2017 19:43:50 +0000 (16:43 -0300)
Adding dump_read function to gather all the dump output of read
function. Adding output of enabled and running times and id if enabled
(3 new lines with '...' prefix below).

  $ perf record -s ...
  $ perf report -D

  958358311769 0x91f8 [0x40]: PERF_RECORD_READ: 3339 3339 cycles:u 0
  ... time enabled : 958358313731
  ... time running : 958358313731
  ... id           : 80

Committer note:

Do not use 'read' as a variable name as it breaks the build on older
systems, such as RHEL6:

    CC       /tmp/build/perf/util/session.o
  cc1: warnings being treated as errors
  util/session.c: In function 'dump_read':
  util/session.c:1132: error: declaration of 'read' shadows a global declaration
  /usr/include/bits/unistd.h:35: error: shadowed declaration is here
  mv: cannot stat `/tmp/build/perf/util/.session.o.tmp': No such file or directory

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20170824162737.7813-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-report.c
tools/perf/util/session.c

index bace342..9e4004b 100644 (file)
@@ -249,10 +249,6 @@ static int process_read_event(struct perf_tool *tool,
                        return err;
        }
 
-       dump_printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
-                   evsel ? perf_evsel__name(evsel) : "FAIL",
-                   event->read.value);
-
        return 0;
 }
 
index dc453f8..ac86369 100644 (file)
@@ -1127,6 +1127,30 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
                sample_read__printf(sample, evsel->attr.read_format);
 }
 
+static void dump_read(struct perf_evsel *evsel, union perf_event *event)
+{
+       struct read_event *read_event = &event->read;
+       u64 read_format;
+
+       if (!dump_trace)
+               return;
+
+       printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
+              evsel ? perf_evsel__name(evsel) : "FAIL",
+              event->read.value);
+
+       read_format = evsel->attr.read_format;
+
+       if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
+               printf("... time enabled : %" PRIu64 "\n", read_event->time_enabled);
+
+       if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
+               printf("... time running : %" PRIu64 "\n", read_event->time_running);
+
+       if (read_format & PERF_FORMAT_ID)
+               printf("... id           : %" PRIu64 "\n", read_event->id);
+}
+
 static struct machine *machines__find_for_cpumode(struct machines *machines,
                                               union perf_event *event,
                                               struct perf_sample *sample)
@@ -1271,6 +1295,7 @@ static int machines__deliver_event(struct machines *machines,
                        evlist->stats.total_lost_samples += event->lost_samples.lost;
                return tool->lost_samples(tool, event, sample, machine);
        case PERF_RECORD_READ:
+               dump_read(evsel, event);
                return tool->read(tool, event, sample, evsel, machine);
        case PERF_RECORD_THROTTLE:
                return tool->throttle(tool, event, sample, machine);