On 07-Mar 13:26, Peter Zijlstra wrote: > On Wed, Mar 07, 2018 at 11:47:11AM +0000, Patrick Bellasi wrote: > > On 06-Mar 20:02, Peter Zijlstra wrote: > > > On Thu, Feb 22, 2018 at 05:01:50PM +0000, Patrick Bellasi wrote: > > > > +struct util_est { > > > > + unsigned int enqueued; > > > > + unsigned int ewma; > > > > +#define UTIL_EST_WEIGHT_SHIFT 2 > > > > +}; > > > > > > > + ue = READ_ONCE(p->se.avg.util_est); > > > > > > > + WRITE_ONCE(p->se.avg.util_est, ue); > > > > > > That is actually quite dodgy... and relies on the fact that we have the > > > 8 byte case in __write_once_size() and __read_once_size() > > > unconditionally. It then further relies on the compiler DTRT for 32bit > > > platforms, which is generating 2 32bit loads/stores. > > > > > > The advantage is of course that it will use single u64 loads/stores > > > where available. > > > > Yes, that's mainly an "optimization" for 64bit targets... but perhaps > > the benefits are negligible. > > > > Do you prefer to keep more "under control" the generated code by using > > two {READ,WRITE}_ONCEs?
Any specific preference on this previous point? > > IMO here we can also go with just the WRITE_ONCEs. I don't see a case > > for the compiler to mangle load/store. While the WRITE_ONCE are still > > required to sync with non rq-lock serialized code. > > But... maybe I'm missing something... ? > > I'm not sure we rely on READ/WRITE_ONCE() of 64bit variables on 32bit > targets to be sane anywhere else (we could be, I just dont know). My understating is that, since here we are in an rq-lock protected section, and only in this section we can write these vars, then the load is a dependency for the store and the compiler cannot screw up... > I suspect it all works as expected... but its a tad tricky. Then let's keep them for the time being... meanwhile I try to get some more "internal" feedback before next posting. -- #include <best/regards.h> Patrick Bellasi