Re: lfence for rdtsc

2020-06-21 Thread Theo de Raadt
Mark Kettenis wrote: > But maybe the default rdtsc() should include the lfence. And then we > could have rdtsc_unordered() for this cases that don't care about > ordering. Right. But I don't like the word 'order', because it is too vague. There are layers of ordering, speculation,

Re: lfence for rdtsc

2020-06-21 Thread Mark Kettenis
> Date: Sun, 21 Jun 2020 16:55:56 +0100 > From: Stuart Henderson > > On 2020/06/21 18:46, Paul Irofti wrote: > > > > > > În 21 iunie 2020 16:30:43 EEST, Theo de Raadt a scris: > > >Paul Irofti wrote: > > > > > >> If you change the name to rdtsc_ordered(), OK. > > > > > >That is a weaker

Re: lfence for rdtsc

2020-06-21 Thread Paul Irofti
On Sun, Jun 21, 2020 at 04:55:56PM +0100, Stuart Henderson wrote: > On 2020/06/21 18:46, Paul Irofti wrote: > > > > > > În 21 iunie 2020 16:30:43 EEST, Theo de Raadt a scris: > > >Paul Irofti wrote: > > > > > >> If you change the name to rdtsc_ordered(), OK. > > > > > >That is a weaker name. >

Re: lfence for rdtsc

2020-06-21 Thread Mark Kettenis
> From: "Theo de Raadt" > Date: Sun, 21 Jun 2020 07:30:43 -0600 > > Paul Irofti wrote: > > > If you change the name to rdtsc_ordered(), OK. > > That is a weaker name. > > Ordered in what way, at what level; ordered against what? > > This is using a specific pipeline ordering known as

Re: lfence for rdtsc

2020-06-21 Thread Stuart Henderson
On 2020/06/21 18:46, Paul Irofti wrote: > > > În 21 iunie 2020 16:30:43 EEST, Theo de Raadt a scris: > >Paul Irofti wrote: > > > >> If you change the name to rdtsc_ordered(), OK. > > > >That is a weaker name. > > > >Ordered in what way, at what level; ordered against what? > > > >This is using

Re: lfence for rdtsc

2020-06-21 Thread Paul Irofti
În 21 iunie 2020 16:30:43 EEST, Theo de Raadt a scris: >Paul Irofti wrote: > >> If you change the name to rdtsc_ordered(), OK. > >That is a weaker name. > >Ordered in what way, at what level; ordered against what? > >This is using a specific pipeline ordering known as lfence. >So it might as

Re: lfence for rdtsc

2020-06-21 Thread Theo de Raadt
Paul Irofti wrote: > If you change the name to rdtsc_ordered(), OK. That is a weaker name. Ordered in what way, at what level; ordered against what? This is using a specific pipeline ordering known as lfence. So it might as well say lfence. That is the technical name for that type of

Re: lfence for rdtsc

2020-06-21 Thread Robert Nagy
it definitely got better: cpu0: TSC skew=0 observed drift=0 cpu0: TSC skew=0 observed drift=0 cpu1: TSC skew=51 observed drift=0 cpu2: TSC skew=68 observed drift=0 cpu3: TSC skew=68 observed drift=0 cpu4: TSC skew=0 observed drift=0 cpu5: TSC skew=0 observed drift=0 cpu6: TSC skew=85 observed

Re: lfence for rdtsc

2020-06-21 Thread Paul Irofti
== > RCS file: /cvs/src/sys/arch/amd64/include/cpufunc.h,v > retrieving revision 1.34 > diff -u -p -r1.34 cpufunc.h > --- arch/amd64/include/cpufunc.h 28 Jun 2019 21:54:05 - 1.34 > +++ arch/amd64/include/cpufunc.h 20 Jun 2020 20:01:46 - > @@ -292,6 +292,15 @@ rdtsc(void) > } > > static __inline u_int64_t > +rdtsc_lfence(void) > +{ > + uint32_t hi, lo; > + > + __asm volatile("lfence; rdtsc" : "=d" (hi), "=a" (lo)); > + return (((uint64_t)hi << 32) | (uint64_t) lo); > +} > + > +static __inline u_int64_t > rdpmc(u_int pmc) > { > uint32_t hi, lo;

lfence for rdtsc

2020-06-20 Thread Mark Kettenis
,v retrieving revision 1.34 diff -u -p -r1.34 cpufunc.h --- arch/amd64/include/cpufunc.h28 Jun 2019 21:54:05 - 1.34 +++ arch/amd64/include/cpufunc.h20 Jun 2020 20:01:46 - @@ -292,6 +292,15 @@ rdtsc(void) } static __inline u_int64_t +rdtsc_lfence(void) +{ + uint3