mbox series

[SRU,J/L,0/1] Xen timekeeping performance improvement

Message ID cover.1693009521.git.ubuntu@ip-172-31-11-177.us-west-2.compute.internal
Headers show
Series Xen timekeeping performance improvement | expand

Message

Krister Johansen Aug. 26, 2023, 12:57 a.m. UTC
Dear Ubuntu Kernel Team:

This patch modifies which default clocksource is selected on Xen.
Users, especially those on EC2, are encouraged to select tsc as their
default clocksource.  However, this requires manual tuning of the
operating system.  Kvm can determine if it safe to use the tsc, and will
default to that instead of its pvclock when appropriate.  This patch
does the same for Xen instances.

If appropriate, it's fine if this is applied to only the linux-aws
branches.

Not all Xen EC2 instances advertise explicit nomigrate support, however,
on those that do we'll select tsc by default.  On the subset of hosts
where this is advertised, users will safely default to the more
performant clocksource.

[Impact]
Xen instances default to the xen clocksource which has been documented
to be slower.  This is required for instances where the tsc is not safe
to use, or the guest is subject to migration.  On some platforms the
performance impact can be high, and users are encouraged to select the
tsc when appropriate.  Instead of leaving up to users to figure this out
by reading a variety of different documents, pick the fast clocksource
when it can be determined to be safe to do so.

[Backport]
Clean cherry pick.  No conflicts applying to 5.15 or 6.2.

[Test]
Booted EC2 xen instances with and without this patch and validated that
on those that properly advertised the required criteria via cpuid, that
the clocksource defaulted to tsc instead of xen.

[Potential Regression]
Potential is low, since only absurd configurations could lead to a
problem.  If this is considered risky, it can be applied to only
linux-aws where the documented guidance is for users to enable tsc as
the clocksource on Xen.

Krister Johansen (1):
  x86/xen/time: prefer tsc as clocksource when it is invariant

 arch/x86/xen/time.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

Comments

Stefan Bader Aug. 28, 2023, 9:57 a.m. UTC | #1
On 26.08.23 02:57, Krister Johansen wrote:
> Dear Ubuntu Kernel Team:
> 
> This patch modifies which default clocksource is selected on Xen.
> Users, especially those on EC2, are encouraged to select tsc as their
> default clocksource.  However, this requires manual tuning of the
> operating system.  Kvm can determine if it safe to use the tsc, and will
> default to that instead of its pvclock when appropriate.  This patch
> does the same for Xen instances.
> 
> If appropriate, it's fine if this is applied to only the linux-aws
> branches.
> 
> Not all Xen EC2 instances advertise explicit nomigrate support, however,
> on those that do we'll select tsc by default.  On the subset of hosts
> where this is advertised, users will safely default to the more
> performant clocksource.
> 
> [Impact]
> Xen instances default to the xen clocksource which has been documented
> to be slower.  This is required for instances where the tsc is not safe
> to use, or the guest is subject to migration.  On some platforms the
> performance impact can be high, and users are encouraged to select the
> tsc when appropriate.  Instead of leaving up to users to figure this out
> by reading a variety of different documents, pick the fast clocksource
> when it can be determined to be safe to do so.
> 
> [Backport]
> Clean cherry pick.  No conflicts applying to 5.15 or 6.2.
> 
> [Test]
> Booted EC2 xen instances with and without this patch and validated that
> on those that properly advertised the required criteria via cpuid, that
> the clocksource defaulted to tsc instead of xen.
> 
> [Potential Regression]
> Potential is low, since only absurd configurations could lead to a
> problem.  If this is considered risky, it can be applied to only
> linux-aws where the documented guidance is for users to enable tsc as
> the clocksource on Xen.
> 
> Krister Johansen (1):
>    x86/xen/time: prefer tsc as clocksource when it is invariant
> 
>   arch/x86/xen/time.c | 38 +++++++++++++++++++++++++++++++++++++-
>   1 file changed, 37 insertions(+), 1 deletion(-)
> 
The change is limited to the Xen environment, looks straight forward 
enough, is upstream (as of v6.3), and can be validated (also fixes an 
issue). So it sounds reasonable to put it into the general distro kernel.

Acked-by: Stefan Bader <stefan.bader@canonical.com>
Roxana Nicolescu Sept. 1, 2023, 9:25 a.m. UTC | #2
On 26/08/2023 02:57, Krister Johansen wrote:
> Dear Ubuntu Kernel Team:
>
> This patch modifies which default clocksource is selected on Xen.
> Users, especially those on EC2, are encouraged to select tsc as their
> default clocksource.  However, this requires manual tuning of the
> operating system.  Kvm can determine if it safe to use the tsc, and will
> default to that instead of its pvclock when appropriate.  This patch
> does the same for Xen instances.
>
> If appropriate, it's fine if this is applied to only the linux-aws
> branches.
>
> Not all Xen EC2 instances advertise explicit nomigrate support, however,
> on those that do we'll select tsc by default.  On the subset of hosts
> where this is advertised, users will safely default to the more
> performant clocksource.
>
> [Impact]
> Xen instances default to the xen clocksource which has been documented
> to be slower.  This is required for instances where the tsc is not safe
> to use, or the guest is subject to migration.  On some platforms the
> performance impact can be high, and users are encouraged to select the
> tsc when appropriate.  Instead of leaving up to users to figure this out
> by reading a variety of different documents, pick the fast clocksource
> when it can be determined to be safe to do so.
>
> [Backport]
> Clean cherry pick.  No conflicts applying to 5.15 or 6.2.
>
> [Test]
> Booted EC2 xen instances with and without this patch and validated that
> on those that properly advertised the required criteria via cpuid, that
> the clocksource defaulted to tsc instead of xen.
>
> [Potential Regression]
> Potential is low, since only absurd configurations could lead to a
> problem.  If this is considered risky, it can be applied to only
> linux-aws where the documented guidance is for users to enable tsc as
> the clocksource on Xen.
>
> Krister Johansen (1):
>    x86/xen/time: prefer tsc as clocksource when it is invariant
>
>   arch/x86/xen/time.c | 38 +++++++++++++++++++++++++++++++++++++-
>   1 file changed, 37 insertions(+), 1 deletion(-)
>
Applied to jammy,lunar:master-next with the proper commit sha. Thanks!

Roxana