From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbbH1GiM (ORCPT ); Fri, 28 Aug 2015 02:38:12 -0400 Received: from terminus.zytor.com ([198.137.202.10]:54636 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751969AbbH1GiJ (ORCPT ); Fri, 28 Aug 2015 02:38:09 -0400 Date: Thu, 27 Aug 2015 23:37:49 -0700 From: tip-bot for Adrian Hunter Message-ID: Cc: acme@redhat.com, jolsa@redhat.com, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org Reply-To: acme@redhat.com, mingo@kernel.org, jolsa@redhat.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com In-Reply-To: <1437150840-31811-14-git-send-email-adrian.hunter@intel.com> References: <1437150840-31811-14-git-send-email-adrian.hunter@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Fix Intel PT 'instructions' sample period Git-Commit-ID: 2a21d03686881331b0af0471588674e7e896eeb2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2a21d03686881331b0af0471588674e7e896eeb2 Gitweb: http://git.kernel.org/tip/2a21d03686881331b0af0471588674e7e896eeb2 Author: Adrian Hunter AuthorDate: Fri, 17 Jul 2015 19:33:48 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 24 Aug 2015 17:42:26 -0300 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 Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1437150840-31811-14-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 3 +++ tools/perf/util/intel-pt-decoder/intel-pt-decoder.h | 1 + tools/perf/util/intel-pt.c | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) 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 f8ac462..56790ea 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 { uint64_t sign_bits; uint64_t period; enum intel_pt_period_type period_type; + uint64_t tot_insn_cnt; uint64_t period_insn_cnt; uint64_t period_mask; uint64_t period_ticks; @@ -559,6 +560,7 @@ static int intel_pt_walk_insn(struct intel_pt_decoder *decoder, err = decoder->walk_insn(intel_pt_insn, &insn_cnt, &decoder->ip, ip, max_insn_cnt, decoder->data); + decoder->tot_insn_cnt += insn_cnt; decoder->timestamp_insn_cnt += insn_cnt; decoder->period_insn_cnt += insn_cnt; @@ -1529,6 +1531,7 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder) decoder->state.timestamp = decoder->timestamp; decoder->state.est_timestamp = intel_pt_est_timestamp(decoder); decoder->state.cr3 = decoder->cr3; + decoder->state.tot_insn_cnt = decoder->tot_insn_cnt; if (err) 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 4c48802..cbf5704 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 { uint64_t from_ip; uint64_t to_ip; uint64_t cr3; + uint64_t tot_insn_cnt; uint64_t timestamp; uint64_t est_timestamp; uint64_t trace_nr; diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index a5acd2f..3b34a64 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -126,6 +126,7 @@ struct intel_pt_queue { u64 timestamp; u32 flags; u16 insn_len; + u64 last_insn_cnt; }; static 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) sample.addr = ptq->state->to_ip; sample.id = ptq->pt->instructions_id; sample.stream_id = ptq->pt->instructions_id; - sample.period = ptq->pt->instructions_sample_period; + sample.period = ptq->state->tot_insn_cnt - ptq->last_insn_cnt; sample.cpu = ptq->cpu; sample.flags = ptq->flags; sample.insn_len = ptq->insn_len; + ptq->last_insn_cnt = ptq->state->tot_insn_cnt; + if (pt->synth_opts.callchain) { thread_stack__sample(ptq->thread, ptq->chain, pt->synth_opts.callchain_sz, sample.ip);