Skip to content

x86/vdso: Add Hyper-V TSC page clocksource support

Vitaly Kuznetsov lkml virtualization 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 3 repliesIn review
  2. v23 patches 13 repliesSuperseded
  3. v12 patches 25 repliesSuperseded

Changes in v3 from the cover letter

- Add explicit READ_ONCE() to not rely on 'volatile' [Andy Lutomirski]
- rdtsc() -> rdtsc_ordered() [Andy Lutomirski]
- virt_rmb() -> smp_rmb() [Thomas Gleixner, Andy Lutomirski]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3x86/hyperv: implement hv_get_tsc_page()arch/x86/hyperv/hv_init.c arch/x86/include/asm/mshyperv.h drivers/hv/Kconfig+18 -20 replies
1/3x86/hyperv: implement hv_get_tsc_page()arch/x86/hyperv/hv_init.c arch/x86/include/asm/mshyperv.h drivers/hv/Kconfig+18 -20 replies
2/3x86/hyperv: move TSC reading method to asm/mshyperv.harch/x86/hyperv/hv_init.c arch/x86/include/asm/mshyperv.h+54 -320 replies
2/3x86/hyperv: move TSC reading method to asm/mshyperv.harch/x86/hyperv/hv_init.c arch/x86/include/asm/mshyperv.h+54 -323 replies
3/3x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read methodarch/x86/entry/vdso/vclock_gettime.c arch/x86/entry/vdso/vdso-layout.lds.S arch/x86/entry/vdso/vdso2c.c +4 more+42 -20 replies
3/3x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read methodarch/x86/entry/vdso/vclock_gettime.c arch/x86/entry/vdso/vdso-layout.lds.S arch/x86/entry/vdso/vdso2c.c +4 more+42 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/3] x86/vdso: Add Hyper-V TSC page clocksource support

Hi,

merge window is about to close so I hope it's OK to make another try here.

Changes since v2:
- Add explicit READ_ONCE() to not rely on 'volatile' [Andy Lutomirski]
- rdtsc() -> rdtsc_ordered() [Andy Lutomirski]
- virt_rmb() -> smp_rmb() [Thomas Gleixner, Andy Lutomirski]

Thomas, Andy, it seems the only blocker for the series was the ambiguity with TSC page read algorithm. I contacted Microsoft (through K. Y.) and asked what we should do when we see 'seq=0'. The answer is:

"I have confirmed that the only invalid value is 0 (notwithstanding what the spec says). I have asked the Spec to be updated and the current code we have is correct - it treats 0 as the only invalid value. The invalid value indicates that the TSC page cannot be used as a time source and a different source is to be used and this state is going to persist and so looping is not an option."

I agree it would be wiser to have two invalid values - one for 'try again' and another for permanent failure in case it is needed. But this is not the case.

So I keep my algorithm untouched.

I can see two more reasons for us to keep it:
1) It is what we already have in kernel.
2) It is what Windows does (see the disassembly in c35b82ef0294.

Original description:

Hyper-V TSC page clocksource is suitable for vDSO, however, the protocol defined by the hypervisor is different from VCLOCK_PVCLOCK. Implemented the required support. Simple sysbench test shows the following results:

Before:

# time sysbench --test=memory --max-requests=500000 run
...
real    1m22.618s
user    0m50.193s
sys     0m32.268s

After:

# time sysbench --test=memory --max-requests=500000 run
...
real	0m47.241s
user	0m47.117s
sys	0m0.008s

Vitaly Kuznetsov (3):
x86/hyperv: implement hv_get_tsc_page() x86/hyperv: move TSC reading method to asm/mshyperv.h x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method

 arch/x86/entry/vdso/vclock_gettime.c  | 24 +++++++++++++++
 arch/x86/entry/vdso/vdso-layout.lds.S |  3 +-
 arch/x86/entry/vdso/vdso2c.c          |  3 ++
 arch/x86/entry/vdso/vma.c             |  7 +++++
 arch/x86/hyperv/hv_init.c             | 48 +++++++++--------------------
 arch/x86/include/asm/clocksource.h    |  3 +-
 arch/x86/include/asm/mshyperv.h       | 58 +++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/vdso.h           |  1 +
 drivers/hv/Kconfig                    |  3 ++
 9 files changed, 114 insertions(+), 36 deletions(-)
Signature · 1 line
2.9.3