Date: Wed, 4 Mar 2015 13:24:52 -0500 From: Ryan Stone <rysto32@gmail.com> To: Bryan Venteicher <bryanv@freebsd.org> Cc: "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org> Subject: Re: svn commit: r278183 - in head/sys: amd64/include conf dev/xen/timer i386/include i386/xen x86/include x86/x86 Message-ID: <CAFMmRNxSJ554uyjzc5-NW%2Bjw_MpH_w_Rvt7x9i6zkFLBxenevw@mail.gmail.com> In-Reply-To: <201502040826.t148Qi8W096721@svn.freebsd.org> References: <201502040826.t148Qi8W096721@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 4, 2015 at 3:26 AM, Bryan Venteicher <bryanv@freebsd.org> wrote: > +static void > +pvclock_read_time_info(struct pvclock_vcpu_time_info *ti, > + uint64_t *cycles, uint8_t *flags) > +{ > + uint32_t version; > + > + do { > + version = ti->version; > + rmb(); > + *cycles = ti->system_time + pvclock_get_nsec_offset(ti); > + *flags = ti->flags; > + rmb(); > + } while ((ti->version & 1) != 0 || ti->version != version); > +} The Linux implementation of this does a "rdtsc_barrier();" in place of the rmb(), and in some situations that appears to result in a full mfence, not just an lfence (the code is macro soup so it's difficult to understand what's happening). Are you sure that the rmb() is enough? I believe that the concern is whether the rdtsc() itself is allowed to be re-ordered around an lfence. This stack overflow answer seems to indicate the a full mfence is necessary on AMD processors: http://stackoverflow.com/questions/12631856/difference-between-rdtscp-rdtsc-memory-and-cpuid-rdtsc
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNxSJ554uyjzc5-NW%2Bjw_MpH_w_Rvt7x9i6zkFLBxenevw>