linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Jiri Olsa <jolsa@redhat.com>,
	stable@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 02/13] perf intel-pt: Fix TSC slip
Date: Fri, 29 Mar 2019 10:37:50 -0300	[thread overview]
Message-ID: <20190329133801.21004-3-acme@kernel.org> (raw)
In-Reply-To: <20190329133801.21004-1-acme@kernel.org>

From: Adrian Hunter <adrian.hunter@intel.com>

A TSC packet can slip past MTC packets so that the timestamp appears to
go backwards. One estimate is that can be up to about 40 CPU cycles,
which is certainly less than 0x1000 TSC ticks, but accept slippage an
order of magnitude more to be on the safe side.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org
Fixes: 79b58424b821c ("perf tools: Add Intel PT support for decoding MTC packets")
Link: http://lkml.kernel.org/r/20190325135135.18348-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 .../util/intel-pt-decoder/intel-pt-decoder.c  | 20 ++++++++-----------
 1 file changed, 8 insertions(+), 12 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 6e03db142091..872fab163585 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -251,19 +251,15 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
 		if (!(decoder->tsc_ctc_ratio_n % decoder->tsc_ctc_ratio_d))
 			decoder->tsc_ctc_mult = decoder->tsc_ctc_ratio_n /
 						decoder->tsc_ctc_ratio_d;
-
-		/*
-		 * Allow for timestamps appearing to backwards because a TSC
-		 * packet has slipped past a MTC packet, so allow 2 MTC ticks
-		 * or ...
-		 */
-		decoder->tsc_slip = multdiv(2 << decoder->mtc_shift,
-					decoder->tsc_ctc_ratio_n,
-					decoder->tsc_ctc_ratio_d);
 	}
-	/* ... or 0x100 paranoia */
-	if (decoder->tsc_slip < 0x100)
-		decoder->tsc_slip = 0x100;
+
+	/*
+	 * A TSC packet can slip past MTC packets so that the timestamp appears
+	 * to go backwards. One estimate is that can be up to about 40 CPU
+	 * cycles, which is certainly less than 0x1000 TSC ticks, but accept
+	 * slippage an order of magnitude more to be on the safe side.
+	 */
+	decoder->tsc_slip = 0x10000;
 
 	intel_pt_log("timestamp: mtc_shift %u\n", decoder->mtc_shift);
 	intel_pt_log("timestamp: tsc_ctc_ratio_n %u\n", decoder->tsc_ctc_ratio_n);
-- 
2.20.1


  parent reply	other threads:[~2019-03-29 13:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 13:37 [GIT PULL 00/13] perf/urgent fixes Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 01/13] perf cs-etm: Add missing case value Arnaldo Carvalho de Melo
2019-03-29 13:37 ` Arnaldo Carvalho de Melo [this message]
2019-03-29 13:37 ` [PATCH 03/13] perf evsel: Fix max perf_event_attr.precise_ip detection Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 04/13] tools headers uapi: Sync asm-generic/mman-common.h and linux/mman.h Arnaldo Carvalho de Melo
2019-03-29 14:20   ` Michael S. Tsirkin
2019-03-29 18:49     ` Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 05/13] tools headers uapi: Sync linux/fcntl.h to get the F_SEAL_FUTURE_WRITE addition Arnaldo Carvalho de Melo
2019-03-29 14:24   ` Joel Fernandes
2019-03-29 13:37 ` [PATCH 06/13] tools arch x86: Sync asm/cpufeatures.h with the kernel sources Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 07/13] tools headers uapi: Update drm/i915_drm.h Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 08/13] tools headers: Update x86's syscall_64.tbl and uapi/asm-generic/unistd Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 09/13] tools headers uapi: Sync powerpc's asm/kvm.h copy with the kernel sources Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 10/13] perf machine: Update kernel map address and re-order properly Arnaldo Carvalho de Melo
2019-03-29 13:37 ` [PATCH 11/13] perf scripts python: exported-sql-viewer.py: Fix never-ending loop Arnaldo Carvalho de Melo
2019-03-29 13:38 ` [PATCH 12/13] perf scripts python: exported-sql-viewer.py: Fix python3 support Arnaldo Carvalho de Melo
2019-03-29 13:38 ` [PATCH 13/13] perf pmu: Fix parser error for uncore event alias Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190329133801.21004-3-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).