aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2016-09-23 10:38:42 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-09-29 10:17:03 -0400
commitfa8025c37454501a2df4a90ae84ff01f4aff8ba8 (patch)
treeab928e5393f0da60cefc36d1901c2e16defdfc10
parent810c398bc09b2f2dfde52a7d2483a710612c5fb8 (diff)
perf intel-pt: Add support for recording the max non-turbo ratio
Previously the maximum non-turbo ratio was calculated from TSC assuming a 100 MHz multiplier which is correct for current hardware supporting Intel PT. However more recent kernels also now export the value, so use that in preference to the calculated value. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Link: http://lkml.kernel.org/r/1474641528-18776-11-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/arch/x86/util/intel-pt.c6
-rw-r--r--tools/perf/util/intel-pt.c14
-rw-r--r--tools/perf/util/intel-pt.h1
3 files changed, 20 insertions, 1 deletions
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index a2412e9d883b..18b21514c153 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -302,6 +302,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
302 bool cap_user_time_zero = false, per_cpu_mmaps; 302 bool cap_user_time_zero = false, per_cpu_mmaps;
303 u64 tsc_bit, mtc_bit, mtc_freq_bits, cyc_bit, noretcomp_bit; 303 u64 tsc_bit, mtc_bit, mtc_freq_bits, cyc_bit, noretcomp_bit;
304 u32 tsc_ctc_ratio_n, tsc_ctc_ratio_d; 304 u32 tsc_ctc_ratio_n, tsc_ctc_ratio_d;
305 unsigned long max_non_turbo_ratio;
305 int err; 306 int err;
306 307
307 if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE) 308 if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE)
@@ -317,6 +318,10 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
317 318
318 intel_pt_tsc_ctc_ratio(&tsc_ctc_ratio_n, &tsc_ctc_ratio_d); 319 intel_pt_tsc_ctc_ratio(&tsc_ctc_ratio_n, &tsc_ctc_ratio_d);
319 320
321 if (perf_pmu__scan_file(intel_pt_pmu, "max_nonturbo_ratio",
322 "%lu", &max_non_turbo_ratio) != 1)
323 max_non_turbo_ratio = 0;
324
320 if (!session->evlist->nr_mmaps) 325 if (!session->evlist->nr_mmaps)
321 return -EINVAL; 326 return -EINVAL;
322 327
@@ -351,6 +356,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
351 auxtrace_info->priv[INTEL_PT_TSC_CTC_N] = tsc_ctc_ratio_n; 356 auxtrace_info->priv[INTEL_PT_TSC_CTC_N] = tsc_ctc_ratio_n;
352 auxtrace_info->priv[INTEL_PT_TSC_CTC_D] = tsc_ctc_ratio_d; 357 auxtrace_info->priv[INTEL_PT_TSC_CTC_D] = tsc_ctc_ratio_d;
353 auxtrace_info->priv[INTEL_PT_CYC_BIT] = cyc_bit; 358 auxtrace_info->priv[INTEL_PT_CYC_BIT] = cyc_bit;
359 auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO] = max_non_turbo_ratio;
354 360
355 return 0; 361 return 0;
356} 362}
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index b744ea812a2e..77fbf02c8e41 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -2023,6 +2023,7 @@ static const char * const intel_pt_info_fmts[] = {
2023 [INTEL_PT_TSC_CTC_N] = " TSC:CTC numerator %"PRIu64"\n", 2023 [INTEL_PT_TSC_CTC_N] = " TSC:CTC numerator %"PRIu64"\n",
2024 [INTEL_PT_TSC_CTC_D] = " TSC:CTC denominator %"PRIu64"\n", 2024 [INTEL_PT_TSC_CTC_D] = " TSC:CTC denominator %"PRIu64"\n",
2025 [INTEL_PT_CYC_BIT] = " CYC bit %#"PRIx64"\n", 2025 [INTEL_PT_CYC_BIT] = " CYC bit %#"PRIx64"\n",
2026 [INTEL_PT_MAX_NONTURBO_RATIO] = " Max non-turbo ratio %"PRIu64"\n",
2026}; 2027};
2027 2028
2028static void intel_pt_print_info(u64 *arr, int start, int finish) 2029static void intel_pt_print_info(u64 *arr, int start, int finish)
@@ -2087,6 +2088,15 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
2087 INTEL_PT_CYC_BIT); 2088 INTEL_PT_CYC_BIT);
2088 } 2089 }
2089 2090
2091 if (auxtrace_info->header.size >= sizeof(struct auxtrace_info_event) +
2092 (sizeof(u64) * INTEL_PT_MAX_NONTURBO_RATIO)) {
2093 pt->max_non_turbo_ratio =
2094 auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO];
2095 intel_pt_print_info(&auxtrace_info->priv[0],
2096 INTEL_PT_MAX_NONTURBO_RATIO,
2097 INTEL_PT_MAX_NONTURBO_RATIO);
2098 }
2099
2090 pt->timeless_decoding = intel_pt_timeless_decoding(pt); 2100 pt->timeless_decoding = intel_pt_timeless_decoding(pt);
2091 pt->have_tsc = intel_pt_have_tsc(pt); 2101 pt->have_tsc = intel_pt_have_tsc(pt);
2092 pt->sampling_mode = false; 2102 pt->sampling_mode = false;
@@ -2156,7 +2166,9 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
2156 if (pt->tc.time_mult) { 2166 if (pt->tc.time_mult) {
2157 u64 tsc_freq = intel_pt_ns_to_ticks(pt, 1000000000); 2167 u64 tsc_freq = intel_pt_ns_to_ticks(pt, 1000000000);
2158 2168
2159 pt->max_non_turbo_ratio = (tsc_freq + 50000000) / 100000000; 2169 if (!pt->max_non_turbo_ratio)
2170 pt->max_non_turbo_ratio =
2171 (tsc_freq + 50000000) / 100000000;
2160 intel_pt_log("TSC frequency %"PRIu64"\n", tsc_freq); 2172 intel_pt_log("TSC frequency %"PRIu64"\n", tsc_freq);
2161 intel_pt_log("Maximum non-turbo ratio %u\n", 2173 intel_pt_log("Maximum non-turbo ratio %u\n",
2162 pt->max_non_turbo_ratio); 2174 pt->max_non_turbo_ratio);
diff --git a/tools/perf/util/intel-pt.h b/tools/perf/util/intel-pt.h
index 0065949df693..8b8356233e6a 100644
--- a/tools/perf/util/intel-pt.h
+++ b/tools/perf/util/intel-pt.h
@@ -34,6 +34,7 @@ enum {
34 INTEL_PT_TSC_CTC_N, 34 INTEL_PT_TSC_CTC_N,
35 INTEL_PT_TSC_CTC_D, 35 INTEL_PT_TSC_CTC_D,
36 INTEL_PT_CYC_BIT, 36 INTEL_PT_CYC_BIT,
37 INTEL_PT_MAX_NONTURBO_RATIO,
37 INTEL_PT_AUXTRACE_PRIV_MAX, 38 INTEL_PT_AUXTRACE_PRIV_MAX,
38}; 39};
39 40