aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/arch
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-07-17 12:33:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-24 16:46:43 -0400
commit11fa7cb86b56d3610043ba2ac6cbd81feab4b7c4 (patch)
tree873474f97b28cd777ec81971614ef6c3c5b0e5f7 /tools/perf/arch
parent3d49807870f08d6f3406b77efd94bb3788372162 (diff)
perf tools: Pass Intel PT information for decoding MTC and CYC
Record additional information in the AUXTRACE_INFO event in preparation for decoding MTC and CYC packets. Pass the information to the decoder. The AUXTRACE_INFO record can be extended by using the size to indicate the presence of new members. The additional information includes PMU config bit positions and the TSC to CTC (hardware crystal clock) ratio needed to decode MTC packets. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1437150840-31811-20-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/arch')
-rw-r--r--tools/perf/arch/x86/util/intel-pt.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 145975b003a7..faae9289bcf6 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -18,6 +18,7 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/bitops.h> 19#include <linux/bitops.h>
20#include <linux/log2.h> 20#include <linux/log2.h>
21#include <cpuid.h>
21 22
22#include "../../perf.h" 23#include "../../perf.h"
23#include "../../util/session.h" 24#include "../../util/session.h"
@@ -261,6 +262,15 @@ static size_t intel_pt_info_priv_size(struct auxtrace_record *itr __maybe_unused
261 return INTEL_PT_AUXTRACE_PRIV_SIZE; 262 return INTEL_PT_AUXTRACE_PRIV_SIZE;
262} 263}
263 264
265static void intel_pt_tsc_ctc_ratio(u32 *n, u32 *d)
266{
267 unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
268
269 __get_cpuid(0x15, &eax, &ebx, &ecx, &edx);
270 *n = ebx;
271 *d = eax;
272}
273
264static int intel_pt_info_fill(struct auxtrace_record *itr, 274static int intel_pt_info_fill(struct auxtrace_record *itr,
265 struct perf_session *session, 275 struct perf_session *session,
266 struct auxtrace_info_event *auxtrace_info, 276 struct auxtrace_info_event *auxtrace_info,
@@ -272,7 +282,8 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
272 struct perf_event_mmap_page *pc; 282 struct perf_event_mmap_page *pc;
273 struct perf_tsc_conversion tc = { .time_mult = 0, }; 283 struct perf_tsc_conversion tc = { .time_mult = 0, };
274 bool cap_user_time_zero = false, per_cpu_mmaps; 284 bool cap_user_time_zero = false, per_cpu_mmaps;
275 u64 tsc_bit, noretcomp_bit; 285 u64 tsc_bit, mtc_bit, mtc_freq_bits, cyc_bit, noretcomp_bit;
286 u32 tsc_ctc_ratio_n, tsc_ctc_ratio_d;
276 int err; 287 int err;
277 288
278 if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE) 289 if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE)
@@ -281,6 +292,12 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
281 intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &tsc_bit); 292 intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &tsc_bit);
282 intel_pt_parse_terms(&intel_pt_pmu->format, "noretcomp", 293 intel_pt_parse_terms(&intel_pt_pmu->format, "noretcomp",
283 &noretcomp_bit); 294 &noretcomp_bit);
295 intel_pt_parse_terms(&intel_pt_pmu->format, "mtc", &mtc_bit);
296 mtc_freq_bits = perf_pmu__format_bits(&intel_pt_pmu->format,
297 "mtc_period");
298 intel_pt_parse_terms(&intel_pt_pmu->format, "cyc", &cyc_bit);
299
300 intel_pt_tsc_ctc_ratio(&tsc_ctc_ratio_n, &tsc_ctc_ratio_d);
284 301
285 if (!session->evlist->nr_mmaps) 302 if (!session->evlist->nr_mmaps)
286 return -EINVAL; 303 return -EINVAL;
@@ -311,6 +328,11 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
311 auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH] = ptr->have_sched_switch; 328 auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH] = ptr->have_sched_switch;
312 auxtrace_info->priv[INTEL_PT_SNAPSHOT_MODE] = ptr->snapshot_mode; 329 auxtrace_info->priv[INTEL_PT_SNAPSHOT_MODE] = ptr->snapshot_mode;
313 auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS] = per_cpu_mmaps; 330 auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS] = per_cpu_mmaps;
331 auxtrace_info->priv[INTEL_PT_MTC_BIT] = mtc_bit;
332 auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS] = mtc_freq_bits;
333 auxtrace_info->priv[INTEL_PT_TSC_CTC_N] = tsc_ctc_ratio_n;
334 auxtrace_info->priv[INTEL_PT_TSC_CTC_D] = tsc_ctc_ratio_d;
335 auxtrace_info->priv[INTEL_PT_CYC_BIT] = cyc_bit;
314 336
315 return 0; 337 return 0;
316} 338}