[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>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Tue, 8 Jul 2025 19:53:02 +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=eVfrjj51kzoFCKFr0dUpXaVy/wgbKEn9Bgu7PzAwDOQ=; b=bIk0O3KNacL0RE5s6Tkhxt6tTaEH+HAFzGJegQ8Bl4j97EOvpS5t9MrvOsA/C+83ArXYHhBzzauCEx9/SH9Ap8ueRl3hvjGf8jhHJM6EVAtCakXKsaE9rGESX3QekOP+uDs2d3wGy2vYgMfIt0YPnlhMe/aKKq2kLEk6fzCX8SoNqujtCeI9atTbP28Ip0YkDGqRbESlA4wlk298wKBlVSpIq1lSFrr1PO6B+5f4kRB52leJgLyTKHs1Rny/a0fZ+YZEzVnrdSJaPoRu5Eml8ajkNmzl3FStpQfNaGIVnasyTmMr9h0DuF7xQpAgkw8I9fg09dbjQSjwQRKRS0taww==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Do9wTAAhRvq9HFzl58S6xZZ6Anbg9m0LVRJ/VprPgOD2+Mg7xQHzKS+cjjRJ825Omspp5a+NkrrkAkBLQ5vdX54iSK+r81imBVkcuKvcdog4uD16YWTaUQCMvG70zBiflh+/E/HE8Iy9zEyXNXPJgm/5eNRkdfm3EMgU4V2Y2G9qPQzm7Mzoys57t5OcjPFfeaLeOAZvPzfXZoaDNMEqaIrsZDDYilnPvwAjFDyYrOeFqV9b1V3gWw2lJoD9z9cnm6VGS7aiRdoxFEDy18Fx2i3D6OEQKye4kvSf5sOSyvRPHzIwsjAT0F7kX3OgwxxxwQ0ML092A9g+ena9qBp7Ag==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <jbeulich@xxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <roger.pau@xxxxxxxxxx>, <Xenia.Ragiadakou@xxxxxxx>, <Jason.Andryuk@xxxxxxx>
  • Delivery-date: Tue, 08 Jul 2025 17:53:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue Jul 8, 2025 at 7:40 PM CEST, Stefano Stabellini wrote:
> On Tue, 8 Jul 2025, Alejandro Vallejo wrote:
>> 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).
>
> I can move it inside the previous if
>
>
>> 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?
>
> I'll drop it.
>
> Is this what you had in mind?
>
>
> diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
> index 59129f419d..d72e640f72 100644
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -2297,11 +2297,7 @@ static void cf_check time_calibration(void *unused)
>      };
>  
>      if ( clocksource_is_tsc() )
> -    {
> -        local_irq_disable();
> -        r.master_stime = read_platform_stime(&r.master_tsc_stamp);
> -        local_irq_enable();
> -    }
> +        return;
>  
>      cpumask_copy(&r.cpu_calibration_map, &cpu_online_map);
>  

Yes, I think that would do.

Cheers,
Alejandro



 


Rackspace

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