Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-04-01 Thread Peter Zijlstra
On Mon, Apr 01, 2019 at 08:44:14AM -0700, Paul E. McKenney wrote: > On Mon, Apr 01, 2019 at 12:53:48PM +0200, Peter Zijlstra wrote: > > On Fri, Mar 29, 2019 at 03:05:54PM -0700, Paul E. McKenney wrote: > > > From Documentation/core-api/atomic_ops.rst: > > > > We should delete that file. > >

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-04-01 Thread Paul E. McKenney
On Mon, Apr 01, 2019 at 12:53:48PM +0200, Peter Zijlstra wrote: > On Fri, Mar 29, 2019 at 03:05:54PM -0700, Paul E. McKenney wrote: > > On Fri, Mar 29, 2019 at 02:51:26PM -0700, H. Peter Anvin wrote: > > > On 3/29/19 2:09 PM, Paul E. McKenney wrote: > > > >> > > > >> Note: the atomic versions of

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-04-01 Thread Alexander Potapenko
On Fri, Mar 29, 2019 at 9:52 PM H. Peter Anvin wrote: > > On 3/29/19 8:54 AM, Alexander Potapenko wrote: > > > >> Of course, this would force the compiler to actually compute the > >> offset, which would slow things down. I have no idea whether this > >> would be better or worse than just using

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-04-01 Thread Peter Zijlstra
On Fri, Mar 29, 2019 at 03:05:54PM -0700, Paul E. McKenney wrote: > On Fri, Mar 29, 2019 at 02:51:26PM -0700, H. Peter Anvin wrote: > > On 3/29/19 2:09 PM, Paul E. McKenney wrote: > > >> > > >> Note: the atomic versions of these functions obviously need to have > > >> "volatile" and the clobber

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-03-29 Thread hpa
On March 29, 2019 3:05:54 PM PDT, "Paul E. McKenney" wrote: >On Fri, Mar 29, 2019 at 02:51:26PM -0700, H. Peter Anvin wrote: >> On 3/29/19 2:09 PM, Paul E. McKenney wrote: >> >> >> >> Note: the atomic versions of these functions obviously need to >have >> >> "volatile" and the clobber anyway, as

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-03-29 Thread Paul E. McKenney
On Fri, Mar 29, 2019 at 02:51:26PM -0700, H. Peter Anvin wrote: > On 3/29/19 2:09 PM, Paul E. McKenney wrote: > >> > >> Note: the atomic versions of these functions obviously need to have > >> "volatile" and the clobber anyway, as they are by definition barriers > >> and moving memory operations

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-03-29 Thread H. Peter Anvin
On 3/29/19 2:09 PM, Paul E. McKenney wrote: >> >> Note: the atomic versions of these functions obviously need to have >> "volatile" and the clobber anyway, as they are by definition barriers >> and moving memory operations around them would be a very serious error. > > The atomic functions that

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-03-29 Thread Paul E. McKenney
On Fri, Mar 29, 2019 at 01:52:33PM -0700, H. Peter Anvin wrote: > On 3/29/19 8:54 AM, Alexander Potapenko wrote: > > > >> Of course, this would force the compiler to actually compute the > >> offset, which would slow things down. I have no idea whether this > >> would be better or worse than

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-03-29 Thread H. Peter Anvin
On 3/29/19 8:54 AM, Alexander Potapenko wrote: > >> Of course, this would force the compiler to actually compute the >> offset, which would slow things down. I have no idea whether this >> would be better or worse than just using the "memory" clobber. > Just adding the "memory" clobber to

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-03-29 Thread Alexander Potapenko
On Thu, Mar 28, 2019 at 5:22 PM Paul E. McKenney wrote: > > On Thu, Mar 28, 2019 at 03:14:12PM +0100, Alexander Potapenko wrote: > > Hello, > > > > arch/x86/include/asm/bitops.h defines clear_bit(nr, addr) for > > non-constant |nr| values as follows: > > > > void clear_bit(long nr, volatile

Re: Potentially missing "memory" clobbers in bitops.h for x86

2019-03-28 Thread Paul E. McKenney
On Thu, Mar 28, 2019 at 03:14:12PM +0100, Alexander Potapenko wrote: > Hello, > > arch/x86/include/asm/bitops.h defines clear_bit(nr, addr) for > non-constant |nr| values as follows: > > void clear_bit(long nr, volatile unsigned long *addr) { > asm volatile("lock; btr %1,%0" > :

Potentially missing "memory" clobbers in bitops.h for x86

2019-03-28 Thread Alexander Potapenko
Hello, arch/x86/include/asm/bitops.h defines clear_bit(nr, addr) for non-constant |nr| values as follows: void clear_bit(long nr, volatile unsigned long *addr) { asm volatile("lock; btr %1,%0" : "+m"(*(volatile long *)addr) : "Ir" (nr)); }