Stephen Hemminger
2017-Feb-10 16:31 UTC
[PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method
Since sequence count algorithm is done by hypervisor, better to not reuse seqcount. Still concerned that the code is racy. -----Original Message----- From: Thomas Gleixner [mailto:tglx at linutronix.de] Sent: Friday, February 10, 2017 4:28 AM To: Vitaly Kuznetsov <vkuznets at redhat.com> Cc: Stephen Hemminger <sthemmin at microsoft.com>; x86 at kernel.org; Andy Lutomirski <luto at amacapital.net>; Ingo Molnar <mingo at redhat.com>; H. Peter Anvin <hpa at zytor.com>; KY Srinivasan <kys at microsoft.com>; Haiyang Zhang <haiyangz at microsoft.com>; Dexuan Cui <decui at microsoft.com>; linux-kernel at vger.kernel.org; devel at linuxdriverproject.org; virtualization at lists.linux-foundation.org Subject: Re: [PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method On Fri, 10 Feb 2017, Vitaly Kuznetsov wrote:> Stephen Hemminger <sthemmin at microsoft.com> writes: > > > Why not use existing seqlock's? > > > > To be honest I don't quite understand how we could use it -- the > sequence locking here is done against the page updated by the > hypersior, we're not creating new structures (so I don't understand > how we could use struct seqcount which we don't have) but I may be > misunderstanding something.You can't use seqlock, but you might be able to use seqcount. Though I doubt it given the 0 check .... Thanks, tglx
Thomas Gleixner
2017-Feb-10 18:01 UTC
[PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method
On Fri, 10 Feb 2017, Stephen Hemminger wrote:> Since sequence count algorithm is done by hypervisor, better to not reuse seqcount. > Still concerned that the code is racy.That's a different question and can only be answered by the hypervisor folks. Dunno, whether they have barrier requirements. The seqcount stuff relies on: do { seq = READ_ONCE(s->sequence); smp_rmb(); sample_data(); smp_rmb(); } while (s->sequence != seq); which pairs with the writer side: s->sequence++; smp_wmb(); update_data(); smp_wmb(); s->sequence++; That's important if the stuff happens cross CPU. If the update happens on the same CPU then this is a different story and as there are VMexits involved they might provide the required ordering already. But I can't tell as I have no idea how that host side thing is done. Thanks, tglx
Dexuan Cui
2017-Feb-13 07:49 UTC
[PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method
> From: Thomas Gleixner [mailto:tglx at linutronix.de] > Sent: Saturday, February 11, 2017 02:02 > ... > That's important if the stuff happens cross CPU. If the update happens on > the same CPU then this is a different story and as there are VMexits > involved they might provide the required ordering already. But I can't tell > as I have no idea how that host side thing is done. > > tglxIMO Hyper-V TSC page clocksource here seems pretty similar to KVM's pvclock, So I would guess "the structure is only updated just before reentering the guest after some VM event" (https://rwmj.wordpress.com/2010/10/15/kvm-pvclock/), that is, the update should happen on the same CPU, I guess. Thanks, -- Dexuan
Maybe Matching Threads
- [PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method
- [PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method
- [PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method
- [PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method
- [PATCH 2/2] x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method