OSDN Git Service

clocksource/drivers/hyper-v: Rework clocksource and sched clock setup
authorMichael Kelley <mikelley@microsoft.com>
Mon, 19 Jun 2023 19:02:40 +0000 (12:02 -0700)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Fri, 23 Jun 2023 07:33:43 +0000 (09:33 +0200)
commite5313f1c540434b18ea57927633b1584c534b14a
tree3398795c8fdb3361188de37174717ba21ee326ba
parent038d454ad996a5e275d46188d65d890d2a243f36
clocksource/drivers/hyper-v: Rework clocksource and sched clock setup

Current code assigns either the Hyper-V TSC page or MSR-based ref counter
as the sched clock. This may be sub-optimal in two cases. First, if there
is hardware support to ensure consistent TSC frequency across live
migrations and Hyper-V is using that support, the raw TSC is a faster
source of time than the Hyper-V TSC page.  Second, the MSR-based ref
counter is relatively slow because reads require a trap to the hypervisor.
As such, it should never be used as the sched clock. The native sched
clock based on the raw TSC or jiffies is much better.

Rework the sched clock setup so it is set to the TSC page only if
Hyper-V indicates that the TSC may have inconsistent frequency across
live migrations. Also, remove the code that sets the sched clock to
the MSR-based ref counter. In the cases where it is not set, the sched
clock will then be the native sched clock.

As part of the rework, always enable both the TSC page clocksource and
the MSR-based ref counter clocksource. Set the ratings so the TSC page
clocksource is preferred. While the MSR-based ref counter clocksource
is unlikely to ever be the default, having it available for manual
selection is convenient for development purposes.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1687201360-16003-1-git-send-email-mikelley@microsoft.com
drivers/clocksource/hyperv_timer.c