Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1583607
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support |
| Date | 2017-02-17 18:10 +0100 |
| Message-ID | <tbUcG-76j-25@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <taNGi-3IN-13@gated-at.bofh.it> <taPf4-4KR-33@gated-at.bofh.it> <tb8ro-107-21@gated-at.bofh.it> <tbyvx-1iO-49@gated-at.bofh.it> <tbNNU-30z-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Feb 17, 2017 at 2:14 AM, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> Thomas Gleixner <tglx@linutronix.de> writes:
>
>> On Wed, 15 Feb 2017, Vitaly Kuznetsov wrote:
>>> Actually, we already have an implementation of TSC page update in KVM
>>> (see arch/x86/kvm/hyperv.c, kvm_hv_setup_tsc_page()) and the update does
>>> the following:
>>>
>>> 0) stash seq into seq_prev
>>> 1) seq = 0 making all reads from the page invalid
>>> 2) smp_wmb()
>>> 3) update tsc_scale, tsc_offset
>>> 4) smp_wmb()
>>> 5) set seq = seq_prev + 1
>>
>> I hope they handle the case where seq_prev overflows and becomes 0 :)
>>
>>> As far as I understand this helps with situations you described above as
>>> guest will notice either invalid value of 0 or seq change. In case the
>>> implementation in real Hyper-V is the same we're safe with compile
>>> barriers only.
>>
>> On x86 that's correct. smp_rmb() resolves to barrier(), but you certainly
>> need the smp_wmb() on the writer side.
>>
>> Now looking at the above your reader side code is bogus:
>>
>> + while (1) {
>> + sequence = tsc_pg->tsc_sequence;
>> + if (!sequence)
>> + break;
>>
>> Why would you break out of the loop when seq is 0? The 0 is just telling
>> you that there is an update in progress.
>
> Not only. As far as I understand (and I *think* K. Y. pointed this out)
> when VM is migrating to another host TSC page clocksource is disabled for
> extended period of time so we're better off reading from MSR than
> looping here. With regards to VDSO this means reverting to doing normal
> syscall.
That's a crappy design. The guest really ought to be able to
distinguish "busy, try again" from "bail and use MSR".
Thomas, I can see valid reasons why the hypervisor might want to
temporarily disable shared page-based timing, but I think it's silly
that it's conflated with indicating "retry".
But if this is indeed the ABI, we're stuck with it.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-14 13:50 +0100
[PATCH v2 1/3] x86/hyperv: implement hv_get_tsc_page() Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-14 13:50 +0100
[PATCH v2 2/3] x86/hyperv: move TSC reading method to asm/mshyperv.h Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-14 13:50 +0100
[PATCH v2 3/3] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-14 13:50 +0100
RE: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support KY Srinivasan <kys@microsoft.com> - 2017-02-14 15:50 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Thomas Gleixner <tglx@linutronix.de> - 2017-02-14 16:00 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-14 17:00 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Andy Lutomirski <luto@amacapital.net> - 2017-02-14 18:40 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-15 15:10 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Thomas Gleixner <tglx@linutronix.de> - 2017-02-16 19:00 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-17 11:20 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Thomas Gleixner <tglx@linutronix.de> - 2017-02-17 11:40 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Andy Lutomirski <luto@amacapital.net> - 2017-02-17 18:10 +0100
Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support Thomas Gleixner <tglx@linutronix.de> - 2017-02-17 19:00 +0100
csiph-web