Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in function pvclock_read_flags

From: Paolo Bonzini
Date: Thu Jun 09 2016 - 07:21:25 EST




On 08/06/2016 10:17, Borislav Petkov wrote:
>> > - version = __pvclock_read_cycles(src, &ret, &flags);
>> > + version = src->version;
>> > + /* Make the latest version visible */
>> > + smp_rmb();
>> > +
>> > + flags = src->flags;
>> > /* Make sure that the version double-check is last. */
> What does that comment mean over the barrier? It should be over the
> "while" line IMO.
>
>> > smp_rmb();
> Why the two barriers back-to-back? Can't have one at the end for all?
>

This is basically implementing a seqcount. It needs two barriers and,
technically, they should be virt_rmb() -- it really doesn't matter of
course because reads are never reordered on x86.

Paolo