public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: "Jan H. Schönherr" <jan@schnhrr.de>
Cc: Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, Paul Menzel <pmenzel@molgen.mpg.de>,
	Thomas Lendacky <Thomas.Lendacky@amd.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] x86/tsc: Allow quick PIT calibration despite interruptions
Date: Fri, 15 Feb 2019 11:36:37 +0100	[thread overview]
Message-ID: <20190215103637.GA55294@gmail.com> (raw)
In-Reply-To: <20190214214608.8672-1-jan@schnhrr.de>


* Jan H. Schönherr <jan@schnhrr.de> wrote:

> Some systems experience regular interruptions (60 Hz SMI?), that prevent
> the quick PIT calibration from succeeding: individual interruptions can be
> so long, that the PIT MSB is observed to decrement by 2 or 3 instead of 1.
> The existing code cannot recover from this.
> 
> The system in question is an AMD Ryzen Threadripper 2950X, microcode
> 0x800820b, on an ASRock Fatal1ty X399 Professional Gaming, BIOS P3.30.
> 
> Change the code to handle (almost) arbitrary interruptions, as long
> as they happen only once in a while and they do not take too long.
> Specifically, also cover an interruption during the very first reads.
> 
> Signed-off-by: Jan H. Schönherr <jan@schnhrr.de>
> ---
> 
> v2:
> - Dropped the other hacky patch for the time being.
> - Fixed the early exit check.
> - Hopefully fixed all inaccurate math in v1.
> - Extended comments.
> 
>  arch/x86/kernel/tsc.c | 91 +++++++++++++++++++++++++++----------------
>  1 file changed, 57 insertions(+), 34 deletions(-)

BTW., I tried this on my Ryzen system, and it appears to be working well:

old (without patch):

  [    0.000000] tsc: Fast TSC calibration failed
  [    0.032000] tsc: PIT calibration matches HPET. 2 loops
  [    0.032000] tsc: Detected 3599.655 MHz processor
  [    0.000014] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x33e30d9825f, max_idle_ns: 440795248078 ns
  [    0.160104] clocksource: Switched to clocksource tsc-early
  [    1.468132] tsc: Refined TSC clocksource calibration: 3599.927 MHz
  [    1.478418] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x33e40e9d0e7, max_idle_ns: 440795301696 ns
  [    1.483197] clocksource: Switched to clocksource tsc

new (with patch):

  [    0.000000] tsc: Fast TSC calibration using PIT
  [    0.000000] tsc: Detected 3599.857 MHz processor
  [    0.736649] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x33e3cc37f8b, max_idle_ns: 440795303609 ns
  [    0.896736] clocksource: Switched to clocksource tsc-early
  [    2.212732] tsc: Refined TSC clocksource calibration: 3599.931 MHz
  [    2.218368] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x33e4128ece2, max_idle_ns: 440795387864 ns
  [    2.261799] clocksource: Switched to clocksource tsc

Tested-by: Ingo Molnar <mingo@kernel.org>

(Note that in the old log the printk timestamps start later so they are 
no basis for boot time comparison.)

Thanks,

	Ingo

  parent reply	other threads:[~2019-02-15 10:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 21:46 [PATCH v2] x86/tsc: Allow quick PIT calibration despite interruptions Jan H. Schönherr
2019-02-14 22:23 ` Jan H. Schönherr
2019-02-14 22:24 ` Thomas Gleixner
2019-04-04 22:06   ` Thomas Gleixner
2019-02-15  9:36 ` Ingo Molnar
2019-02-15 10:36 ` Ingo Molnar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-05-28 14:20 Guilherme G. Piccoli

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=20190215103637.GA55294@gmail.com \
    --to=mingo@kernel.org \
    --cc=Thomas.Lendacky@amd.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jan@schnhrr.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pmenzel@molgen.mpg.de \
    --cc=tglx@linutronix.de \
    --cc=x86@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