Re: [RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-27 Thread Peter Zijlstra
On Tue, Feb 26, 2019 at 11:02:50AM -0800, Linus Torvalds wrote: > On Tue, Feb 26, 2019 at 10:33 AM Peter Zijlstra wrote: > > > > Arguably we could fix that for __this_cpu_xchg(), which isn't IRQ-safe. > > Yeah, I guess x86 _should_ really do __this_cpu_xchg() as just a > read-write pair. See

Re: [RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-26 Thread Linus Torvalds
On Tue, Feb 26, 2019 at 10:33 AM Peter Zijlstra wrote: > > Arguably we could fix that for __this_cpu_xchg(), which isn't IRQ-safe. Yeah, I guess x86 _should_ really do __this_cpu_xchg() as just a read-write pair. In general, a read-write pair is probably always the right thing to do, and the

Re: [RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-26 Thread Peter Zijlstra
On Tue, Feb 26, 2019 at 06:26:24PM +, Will Deacon wrote: > On Fri, Feb 22, 2019 at 01:49:32PM -0800, Linus Torvalds wrote: > So I *am* using __this_cpu_xchg() here, which means the architecture can > get away with plain old loads and stores (which is what RISC-V does, for > example), but I see

Re: [RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-26 Thread Will Deacon
Hi Linus, Thanks for having a look. On Fri, Feb 22, 2019 at 01:49:32PM -0800, Linus Torvalds wrote: > On Fri, Feb 22, 2019 at 10:50 AM Will Deacon wrote: > > > > +#ifndef mmiowb_set_pending > > +static inline void mmiowb_set_pending(void) > > +{ > > +

Re: [RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-26 Thread Will Deacon
On Fri, Feb 22, 2019 at 01:55:20PM -0800, Linus Torvalds wrote: > On Fri, Feb 22, 2019 at 1:49 PM Linus Torvalds > wrote: > > > > The case we want to go fast is the spin-lock and unlock case, not the > > "set pending" case. > > > > And the way you implemented this, it's exactly the wrong way

Re: [RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-22 Thread Linus Torvalds
On Fri, Feb 22, 2019 at 1:49 PM Linus Torvalds wrote: > > The case we want to go fast is the spin-lock and unlock case, not the > "set pending" case. > > And the way you implemented this, it's exactly the wrong way around. Oh, one more comment: couldn't we make that mmiowb flag be right next to

Re: [RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-22 Thread Linus Torvalds
I love removing mmiowb(), but.. On Fri, Feb 22, 2019 at 10:50 AM Will Deacon wrote: > > +#ifndef mmiowb_set_pending > +static inline void mmiowb_set_pending(void) > +{ > + __this_cpu_write(__mmiowb_state.mmiowb_pending, 1); > +} > +#endif > + > +#ifndef mmiowb_spin_lock > +static inline

[RFC PATCH 01/20] asm-generic/mmiowb: Add generic implementation of mmiowb() tracking

2019-02-22 Thread Will Deacon
In preparation for removing all explicit mmiowb() calls from driver code, implement a tracking system in asm-generic based on the PowerPC implementation. This allows architectures with a non-empty mmiowb() definition to automatically have the barrier inserted in spin_unlock() following a critical