aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-07-17 12:33:48 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-24 16:42:26 -0400
commit2a21d03686881331b0af0471588674e7e896eeb2 (patch)
tree91789a1db7da2ce70b141ba62b40ae880136629a /tools/perf
parent5c9ce1e644c1919ac4bff4394a4c372f47a89b4e (diff)
perf tools: Fix Intel PT 'instructions' sample period
The period on synthesized 'instructions' samples was being set to a fixed value, whereas the correct value is the number of instructions since the last sample, which is a value that the decoder can provide. So do it that way. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1437150840-31811-14-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.c3
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.h1
-rw-r--r--tools/perf/util/intel-pt.c5
3 files changed, 8 insertions, 1 deletions
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index f8ac462fec1a..56790ea1e88e 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -108,6 +108,7 @@ struct intel_pt_decoder {
108 uint64_t sign_bits; 108 uint64_t sign_bits;
109 uint64_t period; 109 uint64_t period;
110 enum intel_pt_period_type period_type; 110 enum intel_pt_period_type period_type;
111 uint64_t tot_insn_cnt;
111 uint64_t period_insn_cnt; 112 uint64_t period_insn_cnt;
112 uint64_t period_mask; 113 uint64_t period_mask;
113 uint64_t period_ticks; 114 uint64_t period_ticks;
@@ -559,6 +560,7 @@ static int intel_pt_walk_insn(struct intel_pt_decoder *decoder,
559 err = decoder->walk_insn(intel_pt_insn, &insn_cnt, &decoder->ip, ip, 560 err = decoder->walk_insn(intel_pt_insn, &insn_cnt, &decoder->ip, ip,
560 max_insn_cnt, decoder->data); 561 max_insn_cnt, decoder->data);
561 562
563 decoder->tot_insn_cnt += insn_cnt;
562 decoder->timestamp_insn_cnt += insn_cnt; 564 decoder->timestamp_insn_cnt += insn_cnt;
563 decoder->period_insn_cnt += insn_cnt; 565 decoder->period_insn_cnt += insn_cnt;
564 566
@@ -1529,6 +1531,7 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder)
1529 decoder->state.timestamp = decoder->timestamp; 1531 decoder->state.timestamp = decoder->timestamp;
1530 decoder->state.est_timestamp = intel_pt_est_timestamp(decoder); 1532 decoder->state.est_timestamp = intel_pt_est_timestamp(decoder);
1531 decoder->state.cr3 = decoder->cr3; 1533 decoder->state.cr3 = decoder->cr3;
1534 decoder->state.tot_insn_cnt = decoder->tot_insn_cnt;
1532 1535
1533 if (err) 1536 if (err)
1534 decoder->state.from_ip = decoder->ip; 1537 decoder->state.from_ip = decoder->ip;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
index 4c4880230cc9..cbf57044c385 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
@@ -58,6 +58,7 @@ struct intel_pt_state {
58 uint64_t from_ip; 58 uint64_t from_ip;
59 uint64_t to_ip; 59 uint64_t to_ip;
60 uint64_t cr3; 60 uint64_t cr3;
61 uint64_t tot_insn_cnt;
61 uint64_t timestamp; 62 uint64_t timestamp;
62 uint64_t est_timestamp; 63 uint64_t est_timestamp;
63 uint64_t trace_nr; 64 uint64_t trace_nr;
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index a5acd2fe2447..3b34a64195ea 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -126,6 +126,7 @@ struct intel_pt_queue {
126 u64 timestamp; 126 u64 timestamp;
127 u32 flags; 127 u32 flags;
128 u16 insn_len; 128 u16 insn_len;
129 u64 last_insn_cnt;
129}; 130};
130 131
131static void intel_pt_dump(struct intel_pt *pt __maybe_unused, 132static void intel_pt_dump(struct intel_pt *pt __maybe_unused,
@@ -920,11 +921,13 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq)
920 sample.addr = ptq->state->to_ip; 921 sample.addr = ptq->state->to_ip;
921 sample.id = ptq->pt->instructions_id; 922 sample.id = ptq->pt->instructions_id;
922 sample.stream_id = ptq->pt->instructions_id; 923 sample.stream_id = ptq->pt->instructions_id;
923 sample.period = ptq->pt->instructions_sample_period; 924 sample.period = ptq->state->tot_insn_cnt - ptq->last_insn_cnt;
924 sample.cpu = ptq->cpu; 925 sample.cpu = ptq->cpu;
925 sample.flags = ptq->flags; 926 sample.flags = ptq->flags;
926 sample.insn_len = ptq->insn_len; 927 sample.insn_len = ptq->insn_len;
927 928
929 ptq->last_insn_cnt = ptq->state->tot_insn_cnt;
930
928 if (pt->synth_opts.callchain) { 931 if (pt->synth_opts.callchain) {
929 thread_stack__sample(ptq->thread, ptq->chain, 932 thread_stack__sample(ptq->thread, ptq->chain,
930 pt->synth_opts.callchain_sz, sample.ip); 933 pt->synth_opts.callchain_sz, sample.ip);