2021-01-20 12:57:54

by Wei Liu

[permalink] [raw]
Subject: [PATCH v5 05/16] clocksource/hyperv: use MSR-based access if running as root

When Linux runs as the root partition, the setup required for TSC page
is different. Luckily Linux also has access to the MSR based
clocksource. We can just disable the TSC page clocksource if Linux is
the root partition.

Signed-off-by: Wei Liu <[email protected]>
Acked-by: Daniel Lezcano <[email protected]>
---
drivers/clocksource/hyperv_timer.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index ba04cb381cd3..269a691bd2c4 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -426,6 +426,9 @@ static bool __init hv_init_tsc_clocksource(void)
if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
return false;

+ if (hv_root_partition)
+ return false;
+
hv_read_reference_counter = read_hv_clock_tsc;
phys_addr = virt_to_phys(hv_get_tsc_page());

--
2.20.1


2021-01-20 16:21:16

by Pasha Tatashin

[permalink] [raw]
Subject: Re: [PATCH v5 05/16] clocksource/hyperv: use MSR-based access if running as root

On Wed, Jan 20, 2021 at 7:01 AM Wei Liu <[email protected]> wrote:
>
> When Linux runs as the root partition, the setup required for TSC page
> is different.

Why would we need a TSC page as a clock source for root partition at
all? I think the above can be removed.

Luckily Linux also has access to the MSR based
> clocksource. We can just disable the TSC page clocksource if Linux is
> the root partition.
>
> Signed-off-by: Wei Liu <[email protected]>
> Acked-by: Daniel Lezcano <[email protected]>
> ---
> drivers/clocksource/hyperv_timer.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index ba04cb381cd3..269a691bd2c4 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -426,6 +426,9 @@ static bool __init hv_init_tsc_clocksource(void)
> if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
> return false;
>
> + if (hv_root_partition)
> + return false;
> +

Reviewed-by: Pavel Tatashin <[email protected]>

2021-01-26 10:41:59

by Michael Kelley (LINUX)

[permalink] [raw]
Subject: RE: [PATCH v5 05/16] clocksource/hyperv: use MSR-based access if running as root

From: Wei Liu <[email protected]> Sent: Wednesday, January 20, 2021 4:01 AM
>
> When Linux runs as the root partition, the setup required for TSC page
> is different. Luckily Linux also has access to the MSR based
> clocksource. We can just disable the TSC page clocksource if Linux is
> the root partition.
>
> Signed-off-by: Wei Liu <[email protected]>
> Acked-by: Daniel Lezcano <[email protected]>
> ---
> drivers/clocksource/hyperv_timer.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index ba04cb381cd3..269a691bd2c4 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -426,6 +426,9 @@ static bool __init hv_init_tsc_clocksource(void)
> if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
> return false;
>
> + if (hv_root_partition)
> + return false;
> +
> hv_read_reference_counter = read_hv_clock_tsc;
> phys_addr = virt_to_phys(hv_get_tsc_page());
>
> --
> 2.20.1

Reviewed-by: Michael Kelley <[email protected]>

2021-01-26 15:22:40

by Wei Liu

[permalink] [raw]
Subject: Re: [PATCH v5 05/16] clocksource/hyperv: use MSR-based access if running as root

On Wed, Jan 20, 2021 at 11:13:28AM -0500, Pavel Tatashin wrote:
> On Wed, Jan 20, 2021 at 7:01 AM Wei Liu <[email protected]> wrote:
> >
> > When Linux runs as the root partition, the setup required for TSC page
> > is different.
>
> Why would we need a TSC page as a clock source for root partition at
> all? I think the above can be removed.
>

The TSC page is considered superior to MSR-based clock. In the future we
may want to switch back to that TSC page instead.

I think it provides more context than without.

Wei.

> Luckily Linux also has access to the MSR based
> > clocksource. We can just disable the TSC page clocksource if Linux is
> > the root partition.
> >