Re: [PATCH linux-next] x86/xen/time: prefer tsc as clocksource when it is invariant

From: Krister Johansen
Date: Mon Dec 12 2022 - 11:04:42 EST


On Fri, Dec 09, 2022 at 02:32:15PM -0500, Boris Ostrovsky wrote:
>
> On 12/8/22 11:36 AM, Krister Johansen wrote:
> > + /*
> > + * As Dom0 is never moved, no penalty on using TSC there.
> > + *
> > + * If the guest has invariant tsc, then set xen_clocksource rating
> > + * below that of the tsc so that the system prefers tsc instead. This
> > + * check excludes PV domains, because PV is unable to guarantee that the
> > + * guest's cpuid call has been intercepted by the hypervisor.
> > + */
> > + if (xen_initial_domain()) {
> > xen_clocksource.rating = 275;
> > + } else if ((xen_hvm_domain() || xen_pvh_domain()) &&
> > + boot_cpu_has(X86_FEATURE_CONSTANT_TSC) &&
> > + boot_cpu_has(X86_FEATURE_NONSTOP_TSC) &&
> > + !check_tsc_unstable()) {
> > + xen_clocksource.rating = 299;
> > + }
>
>
> What if RDTSC is intercepted?

Right, thanks. I'll send out an updated patch here shortly that
attempts to address this by examining the cpuid information to determine
if the tsc is being emulated.

-K