All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] perf intel-pt: Fix TSC slip
@ 2019-03-25 13:51 Adrian Hunter
  2019-03-25 14:50 ` Arnaldo Carvalho de Melo
  2019-03-29 20:35 ` [tip:perf/urgent] " tip-bot for Adrian Hunter
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian Hunter @ 2019-03-25 13:51 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

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>
Fixes: 79b58424b821c ("perf tools: Add Intel PT support for decoding MTC packets")
Cc: stable@vger.kernel.org
---
 .../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.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] perf intel-pt: Fix TSC slip
  2019-03-25 13:51 [RESEND PATCH] perf intel-pt: Fix TSC slip Adrian Hunter
@ 2019-03-25 14:50 ` Arnaldo Carvalho de Melo
  2019-03-29 20:35 ` [tip:perf/urgent] " tip-bot for Adrian Hunter
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-03-25 14:50 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel

Em Mon, Mar 25, 2019 at 03:51:35PM +0200, Adrian Hunter escreveu:
> 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.

thanks, applied to perf/urgent.

- Arnaldo
 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> Fixes: 79b58424b821c ("perf tools: Add Intel PT support for decoding MTC packets")
> Cc: stable@vger.kernel.org
> ---
>  .../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.17.1

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/urgent] perf intel-pt: Fix TSC slip
  2019-03-25 13:51 [RESEND PATCH] perf intel-pt: Fix TSC slip Adrian Hunter
  2019-03-25 14:50 ` Arnaldo Carvalho de Melo
@ 2019-03-29 20:35 ` tip-bot for Adrian Hunter
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-03-29 20:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, adrian.hunter, mingo, jolsa, acme, linux-kernel

Commit-ID:  f3b4e06b3bda759afd042d3d5fa86bea8f1fe278
Gitweb:     https://git.kernel.org/tip/f3b4e06b3bda759afd042d3d5fa86bea8f1fe278
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Mon, 25 Mar 2019 15:51:35 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 28 Mar 2019 14:31:55 -0300

perf intel-pt: Fix TSC slip

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>
---
 tools/perf/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);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-29 20:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 13:51 [RESEND PATCH] perf intel-pt: Fix TSC slip Adrian Hunter
2019-03-25 14:50 ` Arnaldo Carvalho de Melo
2019-03-29 20:35 ` [tip:perf/urgent] " tip-bot for Adrian Hunter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.