Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf report: Fix per task mult-counter stat reporting

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>

authored by

Peter Zijlstra and committed by
Ingo Molnar
8f18aec5 1c222bce

+35 -5
+27 -4
tools/perf/builtin-report.c
··· 112 112 struct perf_event_header header; 113 113 u32 pid,tid; 114 114 u64 value; 115 - u64 format[3]; 115 + u64 time_enabled; 116 + u64 time_running; 117 + u64 id; 116 118 }; 117 119 118 120 typedef union event_union { ··· 1692 1690 dprintf(".\n"); 1693 1691 } 1694 1692 1693 + static struct perf_header *header; 1694 + 1695 + static struct perf_counter_attr *perf_header__find_attr(u64 id) 1696 + { 1697 + int i; 1698 + 1699 + for (i = 0; i < header->attrs; i++) { 1700 + struct perf_header_attr *attr = header->attr[i]; 1701 + int j; 1702 + 1703 + for (j = 0; j < attr->ids; j++) { 1704 + if (attr->id[j] == id) 1705 + return &attr->attr; 1706 + } 1707 + } 1708 + 1709 + return NULL; 1710 + } 1711 + 1695 1712 static int 1696 1713 process_read_event(event_t *event, unsigned long offset, unsigned long head) 1697 1714 { 1698 - dprintf("%p [%p]: PERF_EVENT_READ: %d %d %Lu\n", 1715 + struct perf_counter_attr *attr = perf_header__find_attr(event->read.id); 1716 + 1717 + dprintf("%p [%p]: PERF_EVENT_READ: %d %d %s %Lu\n", 1699 1718 (void *)(offset + head), 1700 1719 (void *)(long)(event->header.size), 1701 1720 event->read.pid, 1702 1721 event->read.tid, 1722 + attr ? __event_name(attr->type, attr->config) 1723 + : "FAIL", 1703 1724 event->read.value); 1704 1725 1705 1726 return 0; ··· 1767 1742 1768 1743 return 0; 1769 1744 } 1770 - 1771 - static struct perf_header *header; 1772 1745 1773 1746 static u64 perf_header__sample_type(void) 1774 1747 {
+7 -1
tools/perf/util/parse-events.c
··· 223 223 { 224 224 u64 config = attrs[counter].config; 225 225 int type = attrs[counter].type; 226 + 227 + return __event_name(type, config); 228 + } 229 + 230 + char *__event_name(int type, u64 config) 231 + { 226 232 static char buf[32]; 227 233 228 - if (attrs[counter].type == PERF_TYPE_RAW) { 234 + if (type == PERF_TYPE_RAW) { 229 235 sprintf(buf, "raw 0x%llx", config); 230 236 return buf; 231 237 }
+1
tools/perf/util/parse-events.h
··· 10 10 extern struct perf_counter_attr attrs[MAX_COUNTERS]; 11 11 12 12 extern char *event_name(int ctr); 13 + extern char *__event_name(int type, u64 config); 13 14 14 15 extern int parse_events(const struct option *opt, const char *str, int unset); 15 16