]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf intel-pt: Tidy Intel PT evsel lookup into separate function
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 26 May 2017 08:17:30 +0000 (11:17 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 30 Jun 2017 14:44:35 +0000 (11:44 -0300)
Tidy the lookup of the Intel PT selected event (perf_evsel) into a separate
function.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1495786658-18063-30-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/intel-pt.c

index b670502b026444c0bb57199f2929e9e425c14f21..a9486b57584f4ae2b330e5f020805bc7ceb3dc7e 100644 (file)
@@ -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;
        }