Skip to content

x86/tsc: Utilize TSC_ADJUST MSR

Thomas Gleixner lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8x86/tsc: Use X86_FEATURE_TSC_ADJUST in detect_art()arch/x86/kernel/tsc.c+8 -60 replies
2/8x86/tsc: Detect random warpsarch/x86/kernel/tsc_sync.c+12 -10 replies
3/8x86/tsc: Store and check TSC ADJUST MSRarch/x86/include/asm/tsc.h arch/x86/kernel/Makefile arch/x86/kernel/tsc.c +1 more+97 -15 replies
4/8x86/tsc: Verify TSC_ADJUST from idlearch/x86/include/asm/tsc.h arch/x86/kernel/process.c arch/x86/kernel/tsc_sync.c+22 -16 replies
5/8x86/tsc: Sync test only for the first cpu in a packagearch/x86/include/asm/tsc.h arch/x86/kernel/tsc_sync.c+30 -110 replies
6/8x86/tsc: Move sync cleanup to a safe placearch/x86/kernel/tsc_sync.c+5 -50 replies
7/8x86/tsc: Prepare warp test for TSC adjustmentarch/x86/kernel/tsc_sync.c+4 -20 replies
8/8x86/tsc: Try to adjust TSC if sync test failsarch/x86/kernel/tsc_sync.c+78 -50 replies

Reviews trailers per patch

1 of 8 patches has a Reviewed-by or Acked-by.

PatchIngo Molnar
1/8
2/8
3/8
4/8R-b
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [patch 0/8] x86/tsc: Utilize TSC_ADJUST MSR

The TSC_ADJUST MSR shows whether the TSC has been modified. This is helpful in two aspects:

1) It allows to detect BIOS wreckage, where SMM code tries to 'hide' the cycles spent by storing the TSC value at SMM entry and restoring it at SMM exit. On affected machines the TSCs run slowly out of sync up to the point where the clocksource watchdog (if available) detects it.

The TSC_ADJUST MSR allows to detect the TSC modification before that and eventually restore it. This is also important for SoCs which have no watchdog clocksource and therefore TSC wreckage cannot be detected and acted upon.

2) All threads in a package are required to have the same TSC_ADJUST value. Broken BIOSes break that and as a result the TSC synchronization check fails.

The TSC_ADJUST MSR allows to detect the deviation when a CPU comes online. If detected set it to the value of an already online CPU in the same package. This also allows to reduce the number of sync tests because with that in place the test is only required for the first CPU in a package.

In principle all CPUs in a system should have the same TSC_ADJUST value even across packages, but with physical CPU hotplug this assumption is not true because the TSC starts with power on, so physical hotplug has to do some trickery to bring the TSC into sync with already running packages, which requires to use an TSC_ADJUST value different from CPUs which got powered earlier.

A final enhancement is the opportunity to compensate for unsynced TSCs accross nodes at boot time and make the TSC usable that way. It won't help for TSCs which run apart due to frequency skew between packages, but this gets detected by the clocksource watchdog later.

This patch series implements all of the avove.

Thanks,

tglx

---
 include/asm/tsc.h |    8 +
 kernel/Makefile   |    2 
 kernel/process.c  |    1 
 kernel/tsc.c      |   16 ++-
 kernel/tsc_sync.c |  237 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 244 insertions(+), 20 deletions(-)