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

Re: [PATCH 1/2] xen/x86: don't send IPI to sync TSC when it is reliable


  • To: Stefano Stabellini <stefano.stabellini@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Tue, 8 Jul 2025 11:54:32 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=Nnkr2XUcJy0cU69vf0NDpq+bxw60h+0QWEzvKe0tSlQ=; b=cAskq2VG8g4ragqiuMMVlE6DbA0SP9PoKFxlgTs8gV1Q3bV6oUv4YbJDB3nwfB4lYPRoXzOWgRqFJDqFE4i/2PgdiMLviZ2FUKCh70SK3UiUUiPdXvmSlmqsvW052rRHZLobB2e3B5IAambKkdlPHmbOKWKD9/veLw69H8t3G6Rj/hNZYWNQtMBwLne28mbwoYl9MHiNMmwO8/wFh1jKsXWGFgRHBQNoZ0abc+5SuxkBN/9n3mA5bfoKerdeb1gUETJoYa6/EqbfspZ5WG5GocXgipvLUxFEgBuACbOr4UawAryY77Fmwuq7leOq8VDiISooJxiWxLoG6cis9lI7vA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xETmoImyzk3dXttP51/7GiKjkAJzIsmECRv3xsC8IEJmqmTlB7u30mBjn1gfj0Pu5qB/JxuOrtBnJ5sqjd8rf3ZS56LrDc5dGiq7pkLwerEHROSy3Hyy4aAP+t0SNWLC+YyfJTDP8KudMmbiHYdzP7ZYWJ8U8/nj/d/2syiRcI/vI2a8NMkkX2Brqe4AoaxxsE3OwtFbFgFWKItBclfc3w5RPVTOKNEMwAIQvgYmJjhMSOFkSSQkVzjn5XFL3xea2VrQyQrafJ0g+NHNknfXCLFVapWSfkPlPUrv4rhjSI8VDjCZ7e5dXNOhC5PBOhVo+YduIe5PmfxpPeRedVUmMg==
  • Cc: <jbeulich@xxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <roger.pau@xxxxxxxxxx>, <Xenia.Ragiadakou@xxxxxxx>, <Jason.Andryuk@xxxxxxx>
  • Delivery-date: Tue, 08 Jul 2025 09:54:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue Jul 8, 2025 at 2:07 AM CEST, Stefano Stabellini wrote:
> On real time configuration with the null scheduler, we shouldn't
> interrupt the guest execution unless strictly necessary: the guest could
> be a real time guest (e.g. FreeRTOS) and interrupting its execution
> could lead to a missed deadline.
>
> The principal source of interruptions is IPIs. Remove the unnecessary
> IPI on all physical CPUs to sync the TSC when the TSC is known to be
> reliable.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
> ---
>  xen/arch/x86/time.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
> index 59129f419d..bfd022174a 100644
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -2303,6 +2303,10 @@ static void cf_check time_calibration(void *unused)
>          local_irq_enable();
>      }
>  
> +    if ( boot_cpu_has(X86_FEATURE_CONSTANT_TSC) &&
> +         boot_cpu_has(X86_FEATURE_TSC_RELIABLE) )
> +        return;
> +

This should check "(tsc_flags & TSC_RELIABLE_SOCKET)" as well. The TSCs might
still be unsynchronized across sockets.

I'm still quite confused as to how Xen (mis)handles time, but wouldn't this need
to go inside the branch above? If the clocksource is not the TSC as well the TSC
can still drift with respect to the actual clocksource (PIT, HPET or ACPI 
timer).

If so, we could probably do an early return in the branch above ignoring the
conditions (they are required for picking the TSC clocksource already, including
synchronization across sockets).

Another matter is whether we could drop the "master_stime" write. Would we
care about it at all?

>      cpumask_copy(&r.cpu_calibration_map, &cpu_online_map);
>  
>      /* @wait=1 because we must wait for all cpus before freeing @r. */

Cheers,
Aljeandro



 


Rackspace

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