x86/hyperv: fix for unwanted manipulation of sched_clock when TSC marked unstable
authorAni Sinha <ani@anisinha.ca>
Tue, 13 Jul 2021 03:05:21 +0000 (08:35 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:40:17 +0000 (13:40 +0200)
commit871abd1e6185fa0e066ced9ef8b7a517388f18e8
treefe3b623b555a6bf6a7c5dd51cbb600eb45666a35
parentc327b69e96b0d17b56ebf15ebdf3262148f7e7af
x86/hyperv: fix for unwanted manipulation of sched_clock when TSC marked unstable

[ Upstream commit c445535c3efbfb8cb42d098e624d46ab149664b7 ]

Marking TSC as unstable has a side effect of marking sched_clock as
unstable when TSC is still being used as the sched_clock. This is not
desirable. Hyper-V ultimately uses a paravirtualized clock source that
provides a stable scheduler clock even on systems without TscInvariant
CPU capability. Hence, mark_tsc_unstable() call should be called _after_
scheduler clock has been changed to the paravirtualized clocksource. This
will prevent any unwanted manipulation of the sched_clock. Only TSC will
be correctly marked as unstable.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20210713030522.1714803-1-ani@anisinha.ca
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/cpu/mshyperv.c