aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2012-08-16 15:10:23 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-22 12:47:17 -0400
commit7c2f7afd36cc111dd08eb8eb8ef74fb6564fd131 (patch)
tree3607f74e83926116a88e83c8d8612abb396c28b6 /tools/perf/util
parent4e1b9c679fcb208275b55eb8fc46c2d58ef6a2ee (diff)
perf report: Update event names from header description
Name events based on the event description in the perf.data header. Example output: $ perf report | grep '^#.*event' # event : name = ibs_op/cnt_ctl=1/GH, type = 7, config = 0x80000, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 0, precise_ip = 0, id = { 49, 50, 51, 52, 53, 54, 55, 56 } # event : name = ibs_fetch/config=0/, type = 6, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0, id = { 57, 58, 59, 60, 61, 62, 63, 64 } # Samples: 20K of event 'ibs_op/cnt_ctl=1/GH' # Samples: 4K of event 'ibs_fetch/config=0/' Note the new pmu event syntax of the names. Signed-off-by: Robert Richter <robert.richter@amd.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1345144224-27280-8-git-send-email-robert.richter@amd.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/header.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 7454cf4eedb9..69374deeb4a8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1556,6 +1556,56 @@ static int process_build_id(struct perf_file_section *section,
1556 return 0; 1556 return 0;
1557} 1557}
1558 1558
1559static struct perf_evsel *
1560perf_evlist__find_by_index(struct perf_evlist *evlist, int idx)
1561{
1562 struct perf_evsel *evsel;
1563
1564 list_for_each_entry(evsel, &evlist->entries, node) {
1565 if (evsel->idx == idx)
1566 return evsel;
1567 }
1568
1569 return NULL;
1570}
1571
1572static void
1573perf_evlist__set_event_name(struct perf_evlist *evlist, struct perf_evsel *event)
1574{
1575 struct perf_evsel *evsel;
1576
1577 if (!event->name)
1578 return;
1579
1580 evsel = perf_evlist__find_by_index(evlist, event->idx);
1581 if (!evsel)
1582 return;
1583
1584 if (evsel->name)
1585 return;
1586
1587 evsel->name = strdup(event->name);
1588}
1589
1590static int
1591process_event_desc(struct perf_file_section *section __unused,
1592 struct perf_header *header, int feat __unused, int fd,
1593 void *data __used)
1594{
1595 struct perf_session *session = container_of(header, struct perf_session, header);
1596 struct perf_evsel *evsel, *events = read_event_desc(header, fd);
1597
1598 if (!events)
1599 return 0;
1600
1601 for (evsel = events; evsel->attr.size; evsel++)
1602 perf_evlist__set_event_name(session->evlist, evsel);
1603
1604 free_event_desc(events);
1605
1606 return 0;
1607}
1608
1559struct feature_ops { 1609struct feature_ops {
1560 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist); 1610 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
1561 void (*print)(struct perf_header *h, int fd, FILE *fp); 1611 void (*print)(struct perf_header *h, int fd, FILE *fp);
@@ -1589,7 +1639,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
1589 FEAT_OPA(HEADER_CPUDESC, cpudesc), 1639 FEAT_OPA(HEADER_CPUDESC, cpudesc),
1590 FEAT_OPA(HEADER_CPUID, cpuid), 1640 FEAT_OPA(HEADER_CPUID, cpuid),
1591 FEAT_OPA(HEADER_TOTAL_MEM, total_mem), 1641 FEAT_OPA(HEADER_TOTAL_MEM, total_mem),
1592 FEAT_OPA(HEADER_EVENT_DESC, event_desc), 1642 FEAT_OPP(HEADER_EVENT_DESC, event_desc),
1593 FEAT_OPA(HEADER_CMDLINE, cmdline), 1643 FEAT_OPA(HEADER_CMDLINE, cmdline),
1594 FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology), 1644 FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology),
1595 FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology), 1645 FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology),