[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH RFC] x86/time: set AP's TSC scale estimate earlier


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 6 May 2026 12:33:16 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Aauq/28BmsF4PgEyHkAvwW5K33x2c52QNy3ei5L+bnk=; b=IYeWCf2XFKn2dhgua/3NDxsZCE10LF/QFdKEzx9Xf148WhXQg78BVM/D+EAxe3Vv57Y3O5uchgruOd5zqaFCYCu38nyQ9rV1OB8kHCebBdR4a0YWz6nBmGGxiRTChp0UWvgb4qIAA5VXjU9/ZVFzHdiuD56AfkPUNpbDq1i++e5za+eA1jzOByT5cGVTPgm/fp6OHgbXxhEHWdGcaNyHw5NhKJJNfJ7gbPb+4WZBNEvfq4GnvhLmXbvl/I21LyUO5JGJnF8A8FlrLfhOPv7qDwDoUuc0wBqSqz3aUkcCHe9wi3todT74xqmSaeqUvDBNECau+4w7Nx8JThf82+yMLQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aMucWpZiEosGp7OAfNL124K+qn1ZIC7eZOC+wWXTOX2ttgnbjpKtHEFZG1JMIo5v5mI0lQN4WgKukUvKAzmbnQWgSD8YzikUGeNp58NnSEf7wZTbHQedrvu+qcUK1I3D6OZoVq7bIltMPhHT1nSAy6P9q66gTvYbUHvn0QKJIg7ZS2f6vaMDaZuYOYV6zd9Xzw/MH/XSDT07veJ+JWCuoe/ZN20kkoFL0/jfeU71KFvPIdtCcIY7wwPJW5wRmmDthMjWUvhUr4dBwKi0ZwyBSiKIJIybV6a7McYYEmDGM2ZgbBSGryEQKxSPwd+0Rpj8TAcLZA5dO20XcFACKcF2Og==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Wed, 06 May 2026 10:33:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>
> ---
> 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.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.