linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH 07/11] perf tools: Add perf_evlist__id2sid function to get event ID related data
Date: Mon,  4 Feb 2013 13:33:01 +0100	[thread overview]
Message-ID: <1359981185-16819-8-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1359981185-16819-1-git-send-email-jolsa@redhat.com>

Adding perf_evlist__id2sid function to be able to get ID related
data. This will be helpful for PERF_FORMAT_GROUP samples where
we need to store ID related period value for each event.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/evlist.c | 21 ++++++++++++++++-----
 tools/perf/util/evlist.h |  2 ++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 8789adf..b7565ad 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -335,22 +335,33 @@ static int perf_evlist__id_add_fd(struct perf_evlist *evlist,
 	return 0;
 }
 
-struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
+struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id)
 {
 	struct hlist_head *head;
 	struct hlist_node *pos;
 	struct perf_sample_id *sid;
 	int hash;
 
-	if (evlist->nr_entries == 1)
-		return perf_evlist__first(evlist);
-
 	hash = hash_64(id, PERF_EVLIST__HLIST_BITS);
 	head = &evlist->heads[hash];
 
 	hlist_for_each_entry(sid, pos, head, node)
 		if (sid->id == id)
-			return sid->evsel;
+			return sid;
+
+	return NULL;
+}
+
+struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
+{
+	struct perf_sample_id *sid;
+
+	if (evlist->nr_entries == 1)
+		return perf_evlist__first(evlist);
+
+	sid = perf_evlist__id2sid(evlist, id);
+	if (sid)
+		return sid->evsel;
 
 	if (!perf_evlist__sample_id_all(evlist))
 		return perf_evlist__first(evlist);
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 0b7297c..565f114 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -73,6 +73,8 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
 
 struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
 
+struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
+
 union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
 
 int perf_evlist__open(struct perf_evlist *evlist);
-- 
1.7.11.7


  parent reply	other threads:[~2013-02-04 12:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-04 12:32 [PATCH 00/11] perf tool: Add PERF_SAMPLE_READ sample read support Jiri Olsa
2013-02-04 12:32 ` [PATCH 01/11] perf ui/hist: Add support to display whole group data for raw columns Jiri Olsa
2013-02-06  4:41   ` Namhyung Kim
2013-02-06 22:10   ` [tip:perf/core] perf hists browser: " tip-bot for Jiri Olsa
2013-02-04 12:32 ` [PATCH 02/11] perf: Add PERF_EVENT_IOC_ID ioctl to return event ID Jiri Olsa
2013-05-02 13:38   ` Peter Zijlstra
2013-02-04 12:32 ` [PATCH 03/11] perf: Do not get values from disabled counters in group format read Jiri Olsa
2013-05-02 13:39   ` Peter Zijlstra
2013-02-04 12:32 ` [PATCH 04/11] perf tools: Use PERF_EVENT_IOC_ID perf ioctl to read event id Jiri Olsa
2013-02-04 12:32 ` [PATCH 05/11] perf tools: Add support for parsing PERF_SAMPLE_READ sample type Jiri Olsa
2013-02-04 12:33 ` [PATCH 06/11] perf tools: Fix event ID retrieval for group format read case Jiri Olsa
2013-02-04 12:33 ` Jiri Olsa [this message]
2013-02-04 12:33 ` [PATCH 08/11] perf tools: Add PERF_SAMPLE_READ sample related processing Jiri Olsa
2013-02-04 12:33 ` [PATCH 09/11] perf tools: Add 'S' event/group modifier to read sample value Jiri Olsa
2013-02-04 12:33 ` [PATCH 10/11] perf tests: Add attr record group sampling test Jiri Olsa
2013-02-04 12:33 ` [PATCH 11/11] perf tests: Add parse events tests for leader sampling Jiri Olsa
2013-02-06  4:59 ` [PATCH 00/11] perf tool: Add PERF_SAMPLE_READ sample read support Namhyung Kim

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=1359981185-16819-8-git-send-email-jolsa@redhat.com \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.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).