From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Teddy Astie <teddy.astie@vates.tech>
Subject: Re: [PATCH RFC] x86/time: set AP's TSC scale estimate earlier
Date: Wed, 6 May 2026 12:33:16 +0200 [thread overview]
Message-ID: <afsY7KqNIyrhW0s4@macbook.local> (raw)
In-Reply-To: <1e23dd78-b246-4fc7-9e18-de8b0cd57721@suse.com>
On Wed, May 06, 2026 at 11:39:14AM +0200, Jan Beulich wrote:
> NOW() (in particular) can be used ahead of init_percpu_time(). As the
> initial scale value set is merely the BSP's, we can as well set it before
> actually launching the AP. Don't introduce yet another notifier function
> though; do this from smpboot.c's.
>
> Setting the scale alone, however, doesn't work, so the entire struct
> cpu_time is copied.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> RFC: Copying the entire struct won't work very well when tsc_adjust[] is
> in use (and values there differ between sockets).
>
> This in particular eliminates an anomaly with log messages issued early
> while APs are coming up, when "boot" console timestamps are in use.
Could we consider moving init_percpu_time() earlier in
start_secondary()? I think it's main dependency is on
set_cpu_sibling_map(), which we could also move earlier?
Looking further, seems like it depends on smp_callin() having parsed
the CPUID features, plus the socket_cpumask[] also being set.
> --- a/xen/arch/x86/include/asm/time.h
> +++ b/xen/arch/x86/include/asm/time.h
> @@ -21,6 +21,7 @@ mktime (unsigned int year, unsigned int
> int time_suspend(void);
> int time_resume(void);
>
> +void preinit_percpu_time(unsigned int cpu);
> void init_percpu_time(void);
> void time_latch_stamps(void);
>
> --- a/xen/arch/x86/smpboot.c
> +++ b/xen/arch/x86/smpboot.c
> @@ -1139,6 +1139,7 @@ static int cf_check cpu_smpboot_callback
> {
> case CPU_UP_PREPARE:
> rc = cpu_smpboot_alloc(cpu);
> + preinit_percpu_time(cpu);
> break;
> case CPU_UP_CANCELED:
> case CPU_DEAD:
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -2346,6 +2346,12 @@ void time_latch_stamps(void)
> ap_bringup_ref.local_stime = get_s_time_fixed(ap_bringup_ref.local_tsc);
> }
>
> +void preinit_percpu_time(unsigned int cpu)
> +{
> + /* Initial estimate for TSC rate etc. */
> + per_cpu(cpu_time, cpu) = this_cpu(cpu_time);
> +}
> +
> void init_percpu_time(void)
> {
> struct cpu_time *t = &this_cpu(cpu_time);
> @@ -2353,9 +2359,6 @@ void init_percpu_time(void)
> u64 tsc;
> s_time_t now;
>
> - /* Initial estimate for TSC rate. */
> - t->tsc_scale = per_cpu(cpu_time, 0).tsc_scale;
Wouldn't it be simpler to pull this out of init_percpu_time() and do
it at the start of start_secondary()?
Thanks, Roger.
next prev parent reply other threads:[~2026-05-06 10:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 9:39 [PATCH RFC] x86/time: set AP's TSC scale estimate earlier Jan Beulich
2026-05-06 10:33 ` Roger Pau Monné [this message]
2026-05-06 10:46 ` Jan Beulich
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=afsY7KqNIyrhW0s4@macbook.local \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.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 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.