public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Lei Chen <lei.chen@smartx.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] x86/tsc: print some log if calibrated tsc freq deviates from original too much
Date: Tue, 9 Apr 2024 10:05:46 +0200	[thread overview]
Message-ID: <ZhT22tl/Iho5M+1x@gmail.com> (raw)
In-Reply-To: <20240408100607.1732600-1-lei.chen@smartx.com>


* Lei Chen <lei.chen@smartx.com> wrote:

> In most cases, tsc_khz is refined by hpet on boot. But in a few
> production-level nodes, the refinement fails because calibrated
> freq diviates from origin tsc freq more than 1%. Printing some
> logs will help get this info.
> 
> Signed-off-by: Lei Chen <lei.chen@smartx.com>
> ---
>  arch/x86/kernel/tsc.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 15f97c0abc9d..a68b16e72df1 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -1435,8 +1435,15 @@ static void tsc_refine_calibration_work(struct work_struct *work)
>  	}
>  
>  	/* Make sure we're within 1% */
> -	if (abs(tsc_khz - freq) > tsc_khz/100)
> +	if (abs(tsc_khz - freq) > tsc_khz/100) {
> +		pr_warn("Warning: TSC freq calibrated by [%s]: %lu.%03lu MHz deviates too much from original freq: %lu.%03lu MHz\n",

Yeah, so it wouldn't cost us anything to more precisely define 'too much':

 s/deviates too much from
  /deviates by more than 1% from

Right?

> +			hpet ? "HPET" : "PM_TIMER",
> +			(unsigned long)freq / 1000,
> +			(unsigned long)freq % 1000,
> +			(unsigned long)tsc_khz / 1000,
> +			(unsigned long)tsc_khz % 1000);
>  		goto out;
> +	}

The warning makes sense I suppose, if it's one per system and once per 
bootup [right?], but I think pr_info() would be plenty enough priority for 
this condition - especially as we didn't have the warning before and don't 
know how frequent it is?

Thanks,

	Ingo

  reply	other threads:[~2024-04-09  8:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 10:06 [PATCH RESEND] x86/tsc: print some log if calibrated tsc freq deviates from original too much Lei Chen
2024-04-09  8:05 ` Ingo Molnar [this message]
2024-04-10  4:52   ` Lei Chen

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=ZhT22tl/Iho5M+1x@gmail.com \
    --to=mingo@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=lei.chen@smartx.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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