Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1651186
| From | Adrian Hunter <adrian.hunter@intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH V2 29/37] perf intel-pt: Tidy Intel PT evsel lookup into separate function |
| Date | 2017-05-26 10:30 +0200 |
| Message-ID | <tLiNe-3tM-85@gated-at.bofh.it> (permalink) |
| References | <tLiNb-3tM-9@gated-at.bofh.it> |
| Organization | Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki |
Tidy the lookup of the Intel PT selected event (perf_evsel) into a separate
function.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/intel-pt.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index b670502b0264..a9486b57584f 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1922,24 +1922,29 @@ static int intel_pt_synth_event(struct perf_session *session,
&id, intel_pt_event_synth);
}
+static struct perf_evsel *intel_pt_evsel(struct intel_pt *pt,
+ struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel;
+
+ evlist__for_each_entry(evlist, evsel) {
+ if (evsel->attr.type == pt->pmu_type && evsel->ids)
+ return evsel;
+ }
+
+ return NULL;
+}
+
static int intel_pt_synth_events(struct intel_pt *pt,
struct perf_session *session)
{
struct perf_evlist *evlist = session->evlist;
- struct perf_evsel *evsel;
+ struct perf_evsel *evsel = intel_pt_evsel(pt, evlist);
struct perf_event_attr attr;
- bool found = false;
u64 id;
int err;
- evlist__for_each_entry(evlist, evsel) {
- if (evsel->attr.type == pt->pmu_type && evsel->ids) {
- found = true;
- break;
- }
- }
-
- if (!found) {
+ if (!evsel) {
pr_debug("There are no selected events with Intel Processor Trace data\n");
return 0;
}
--
1.9.1
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH V2 29/37] perf intel-pt: Tidy Intel PT evsel lookup into separate function Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:30 +0200
csiph-web