perf report: Fix per task mult-counter stat reporting
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Thu, 6 Aug 2009 17:40:28 +0000 (19:40 +0200)
committerIngo Molnar <mingo@elte.hu>
Sun, 9 Aug 2009 10:54:35 +0000 (12:54 +0200)
Brice Goglin reported:

> I can easily sort them by thread id, but I don't know how to match
> my 4 events with each group of 4 lines.

Also report the counter id and the time running/enabled
stats (in case the counter got time-shared).

Reported-by: Brice Goglin <Brice.Goglin@inria.fr>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Tested-by: Brice Goglin <Brice.Goglin@inria.fr>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-report.c
tools/perf/util/parse-events.c
tools/perf/util/parse-events.h

index da402e186561bb397bdd8618d66086e1d17d2546..84205462e07b85110ced638a081b8b8680325aad 100644 (file)
@@ -112,7 +112,9 @@ struct read_event {
        struct perf_event_header header;
        u32 pid,tid;
        u64 value;
-       u64 format[3];
+       u64 time_enabled;
+       u64 time_running;
+       u64 id;
 };
 
 typedef union event_union {
@@ -1690,14 +1692,37 @@ static void trace_event(event_t *event)
        dprintf(".\n");
 }
 
+static struct perf_header      *header;
+
+static struct perf_counter_attr *perf_header__find_attr(u64 id)
+{
+       int i;
+
+       for (i = 0; i < header->attrs; i++) {
+               struct perf_header_attr *attr = header->attr[i];
+               int j;
+
+               for (j = 0; j < attr->ids; j++) {
+                       if (attr->id[j] == id)
+                               return &attr->attr;
+               }
+       }
+
+       return NULL;
+}
+
 static int
 process_read_event(event_t *event, unsigned long offset, unsigned long head)
 {
-       dprintf("%p [%p]: PERF_EVENT_READ: %d %d %Lu\n",
+       struct perf_counter_attr *attr = perf_header__find_attr(event->read.id);
+
+       dprintf("%p [%p]: PERF_EVENT_READ: %d %d %s %Lu\n",
                        (void *)(offset + head),
                        (void *)(long)(event->header.size),
                        event->read.pid,
                        event->read.tid,
+                       attr ? __event_name(attr->type, attr->config)
+                            : "FAIL",
                        event->read.value);
 
        return 0;
@@ -1743,8 +1768,6 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
        return 0;
 }
 
-static struct perf_header      *header;
-
 static u64 perf_header__sample_type(void)
 {
        u64 sample_type = 0;
index 7bdad8df22a66b5ea10e85cdbe9b5bea806f4bb4..f77407b5832e94011a060f79007c2362d26c933c 100644 (file)
@@ -223,9 +223,15 @@ char *event_name(int counter)
 {
        u64 config = attrs[counter].config;
        int type = attrs[counter].type;
+
+       return __event_name(type, config);
+}
+
+char *__event_name(int type, u64 config)
+{
        static char buf[32];
 
-       if (attrs[counter].type == PERF_TYPE_RAW) {
+       if (type == PERF_TYPE_RAW) {
                sprintf(buf, "raw 0x%llx", config);
                return buf;
        }
index 1ea5d09b6eb14221db27cebdc9091f03c29bf53b..192a962e3a0fbe15b294dc6f1f5e9e787f68e32e 100644 (file)
@@ -10,6 +10,7 @@ extern int                    nr_counters;
 extern struct perf_counter_attr attrs[MAX_COUNTERS];
 
 extern char *event_name(int ctr);
+extern char *__event_name(int type, u64 config);
 
 extern int parse_events(const struct option *opt, const char *str, int unset);