public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] perf intel-pt: Fix TSC slip
Date: Mon, 25 Mar 2019 11:50:19 -0300	[thread overview]
Message-ID: <20190325145019.GC6231@kernel.org> (raw)
In-Reply-To: <20190325135135.18348-1-adrian.hunter@intel.com>

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

  reply	other threads:[~2019-03-25 14:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25 13:51 [RESEND PATCH] perf intel-pt: Fix TSC slip Adrian Hunter
2019-03-25 14:50 ` Arnaldo Carvalho de Melo [this message]
2019-03-29 20:35 ` [tip:perf/urgent] " tip-bot for Adrian Hunter

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=20190325145019.GC6231@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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