aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2017-05-26 04:17:30 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-06-30 10:44:35 -0400
commit85a564d26dfb45bbf0c0095e0fcee3bdc4a49a85 (patch)
treed76f673e734ec5180763483bf26a5a83cad48113 /tools
parent406a180501f6d0d4e43d5acc5f580abfc95c742d (diff)
perf intel-pt: Tidy Intel PT evsel lookup into separate function
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/intel-pt.c25
1 files 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,
1922 &id, intel_pt_event_synth); 1922 &id, intel_pt_event_synth);
1923} 1923}
1924 1924
1925static struct perf_evsel *intel_pt_evsel(struct intel_pt *pt,
1926 struct perf_evlist *evlist)
1927{
1928 struct perf_evsel *evsel;
1929
1930 evlist__for_each_entry(evlist, evsel) {
1931 if (evsel->attr.type == pt->pmu_type && evsel->ids)
1932 return evsel;
1933 }
1934
1935 return NULL;
1936}
1937
1925static int intel_pt_synth_events(struct intel_pt *pt, 1938static int intel_pt_synth_events(struct intel_pt *pt,
1926 struct perf_session *session) 1939 struct perf_session *session)
1927{ 1940{
1928 struct perf_evlist *evlist = session->evlist; 1941 struct perf_evlist *evlist = session->evlist;
1929 struct perf_evsel *evsel; 1942 struct perf_evsel *evsel = intel_pt_evsel(pt, evlist);
1930 struct perf_event_attr attr; 1943 struct perf_event_attr attr;
1931 bool found = false;
1932 u64 id; 1944 u64 id;
1933 int err; 1945 int err;
1934 1946
1935 evlist__for_each_entry(evlist, evsel) { 1947 if (!evsel) {
1936 if (evsel->attr.type == pt->pmu_type && evsel->ids) {
1937 found = true;
1938 break;
1939 }
1940 }
1941
1942 if (!found) {
1943 pr_debug("There are no selected events with Intel Processor Trace data\n"); 1948 pr_debug("There are no selected events with Intel Processor Trace data\n");
1944 return 0; 1949 return 0;
1945 } 1950 }