linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	Robert Richter <robert.richter@amd.com>
Subject: [PATCH 7/8] perf report: Update event names from header description
Date: Thu, 16 Aug 2012 21:10:23 +0200	[thread overview]
Message-ID: <1345144224-27280-8-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1345144224-27280-1-git-send-email-robert.richter@amd.com>

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>
---
 tools/perf/util/header.c |   52 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 7454cf4..c0311b3 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,
 	return 0;
 }
 
+static struct perf_evsel *
+perf_evlist_find_by_index(struct perf_evlist *evlist, int idx)
+{
+	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node) {
+		if (evsel->idx == idx)
+			return evsel;
+	}
+
+	return NULL;
+}
+
+static void
+perf_evlist__set_event_name(struct perf_evlist *evlist, struct perf_evsel *event)
+{
+	struct perf_evsel *evsel;
+
+	if (!event->name)
+		return;
+
+	evsel = perf_evlist_find_by_index(evlist, event->idx);
+	if (!evsel)
+		return;
+
+	if (evsel->name)
+		return;
+
+	evsel->name = strdup(event->name);
+}
+
+static int
+process_event_desc(struct perf_file_section *section __unused,
+		   struct perf_header *header, int feat __unused, int fd,
+		   void *data __used)
+{
+	struct perf_session *session = container_of(header, struct perf_session, header);
+	struct perf_evsel *evsel, *events = read_event_desc(header, fd);
+
+	if (!events)
+		return 0;
+
+	for (evsel = events; evsel->attr.size; evsel++)
+		perf_evlist__set_event_name(session->evlist, evsel);
+
+	free_event_desc(events);
+
+	return 0;
+}
+
 struct feature_ops {
 	int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
 	void (*print)(struct perf_header *h, int fd, FILE *fp);
@@ -1589,7 +1639,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
 	FEAT_OPA(HEADER_CPUDESC,	cpudesc),
 	FEAT_OPA(HEADER_CPUID,		cpuid),
 	FEAT_OPA(HEADER_TOTAL_MEM,	total_mem),
-	FEAT_OPA(HEADER_EVENT_DESC,	event_desc),
+	FEAT_OPP(HEADER_EVENT_DESC,	event_desc),
 	FEAT_OPA(HEADER_CMDLINE,	cmdline),
 	FEAT_OPF(HEADER_CPU_TOPOLOGY,	cpu_topology),
 	FEAT_OPF(HEADER_NUMA_TOPOLOGY,	numa_topology),
-- 
1.7.8.6



  parent reply	other threads:[~2012-08-16 19:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16 19:10 [PATCH 0/8] perf tools: Various updates Robert Richter
2012-08-16 19:10 ` [PATCH 1/8] perf tools: Fix type for evsel->ids and add size check for ids Robert Richter
2012-08-21 16:24   ` [tip:perf/core] perf tools: Fix type for evsel-> ids " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 2/8] perf tools: Report number of pmu type of unknown events Robert Richter
2012-08-21 16:25   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 3/8] perf tools: Rename some variables for better understanding Robert Richter
2012-08-17 15:34   ` Arnaldo Carvalho de Melo
2012-08-21 16:26   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 4/8] perf tools: Rename global variable 'events' in util/header.c Robert Richter
2012-08-21 16:27   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 5/8] perf tools: Catch event names from command line Robert Richter
2012-08-20 17:42   ` Jiri Olsa
2012-08-21 18:02     ` Robert Richter
2012-08-21 18:03     ` [PATCH 1/2] perf test: Update event names in test cases Robert Richter
2012-08-21 18:03       ` [PATCH 2/2] perf test: Do not abort tests on error Robert Richter
2012-08-27 16:53         ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-27 16:54   ` [tip:perf/core] perf tools: Catch event names from command line tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 6/8] perf tools: Refactor print_event_desc() Robert Richter
2012-08-27 16:55   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-16 19:10 ` Robert Richter [this message]
2012-08-27 16:56   ` [tip:perf/core] perf report: Update event names from header description tip-bot for Robert Richter
2012-08-16 19:10 ` [PATCH 8/8] perf tools: Add pmu mappings to header information Robert Richter
2012-08-27 16:57   ` [tip:perf/core] " tip-bot for Robert Richter
2012-08-17 16:18 ` [PATCH 0/8] perf tools: Various updates Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345144224-27280-8-git-send-email-robert.richter@amd.com \
    --to=robert.richter@amd.com \
    --cc=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).