Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Valdis . Kletnieks
On Sat, 11 Aug 2007 02:38:40 +0200, Segher Boessenkool said: > >> That means GCC cannot compile Linux; it already optimises > >> some accesses to scalars to smaller accesses when it knows > >> it is allowed to. Not often though, since it hardly ever > >> helps in the cost model it employs. > > > >

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Segher Boessenkool
That means GCC cannot compile Linux; it already optimises some accesses to scalars to smaller accesses when it knows it is allowed to. Not often though, since it hardly ever helps in the cost model it employs. Please give an example code snippet + gcc version + arch to back this up. u

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Herbert Xu
On Sat, Aug 11, 2007 at 02:38:40AM +0200, Segher Boessenkool wrote: > >>That means GCC cannot compile Linux; it already optimises > >>some accesses to scalars to smaller accesses when it knows > >>it is allowed to. Not often though, since it hardly ever > >>helps in the cost model it employs. > >

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Segher Boessenkool
That means GCC cannot compile Linux; it already optimises some accesses to scalars to smaller accesses when it knows it is allowed to. Not often though, since it hardly ever helps in the cost model it employs. Please give an example code snippet + gcc version + arch to back this up. u

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Herbert Xu
On Fri, Aug 10, 2007 at 10:07:27PM +0200, Segher Boessenkool wrote: > > That means GCC cannot compile Linux; it already optimises > some accesses to scalars to smaller accesses when it knows > it is allowed to. Not often though, since it hardly ever > helps in the cost model it employs. Please g

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Paul E. McKenney
On Fri, Aug 10, 2007 at 03:49:03PM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >On Thu, Aug 09, 2007 at 03:24:40PM -0400, Chris Snook wrote: > >>Paul E. McKenney wrote: > >>>On Thu, Aug 09, 2007 at 02:13:52PM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >On Thu, Aug 09, 2

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Segher Boessenkool
The compiler is within its rights to read a 32-bit quantity 16 bits at at time, even on a 32-bit machine. I would be glad to help pummel any compiler writer that pulls such a dirty trick, but the C standard really does permit this. Code all over the kernel assumes that 32-bit reads/writes are

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Chris Snook
Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 03:24:40PM -0400, Chris Snook wrote: Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 02:13:52PM -0400, Chris Snook wrote: Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 01:14:35PM -0400, Chris Snook wrote: If you'r

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Paul E. McKenney
On Fri, Aug 10, 2007 at 11:08:20AM +0200, Andi Kleen wrote: > On Friday 10 August 2007 10:21:46 Herbert Xu wrote: > > Paul E. McKenney <[EMAIL PROTECTED]> wrote: > > > > > > The compiler is within its rights to read a 32-bit quantity 16 bits at > > > at time, even on a 32-bit machine. I would be g

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Andi Kleen
On Friday 10 August 2007 10:21:46 Herbert Xu wrote: > Paul E. McKenney <[EMAIL PROTECTED]> wrote: > > > > The compiler is within its rights to read a 32-bit quantity 16 bits at > > at time, even on a 32-bit machine. I would be glad to help pummel any > > compiler writer that pulls such a dirty tri

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-10 Thread Herbert Xu
Paul E. McKenney <[EMAIL PROTECTED]> wrote: > > The compiler is within its rights to read a 32-bit quantity 16 bits at > at time, even on a 32-bit machine. I would be glad to help pummel any > compiler writer that pulls such a dirty trick, but the C standard really > does permit this. Code all ov

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Paul E. McKenney
On Thu, Aug 09, 2007 at 03:24:40PM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >On Thu, Aug 09, 2007 at 02:13:52PM -0400, Chris Snook wrote: > >>Paul E. McKenney wrote: > >>>On Thu, Aug 09, 2007 at 01:14:35PM -0400, Chris Snook wrote: > If you're dependi

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Geert Uytterhoeven
On Thu, 9 Aug 2007, Chris Snook wrote: > Segher Boessenkool wrote: > > > > The only safe way to get atomic accesses is to write > > > > assembler code. Are there any downsides to that? I don't > > > > see any. > > > > > > The assumption that aligned word reads and writes are atomic, and that > >

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Segher Boessenkool
So, why not use the well-defined alternative? Because we don't need to, and it hurts performance. It hurts performance by implementing 32-bit atomic reads in assembler? No, I misunderstood the question. Implementing 32-bit atomic reads in assembler is redundant, because any sane compiler, *p

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Geert Uytterhoeven wrote: On Thu, 9 Aug 2007, Chris Snook wrote: Segher Boessenkool wrote: The only safe way to get atomic accesses is to write assembler code. Are there any downsides to that? I don't see any. The assumption that aligned word reads and writes are atomic, and that words are a

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Segher Boessenkool wrote: The compiler is within its rights to read a 32-bit quantity 16 bits at at time, even on a 32-bit machine. I would be glad to help pummel any compiler writer that pulls such a dirty trick, but the C standard really does permit this. Yes, but we don't write code for the

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 02:13:52PM -0400, Chris Snook wrote: Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 01:14:35PM -0400, Chris Snook wrote: If you're depending on volatile writes being visible to other CPUs, you're screwed either way

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Segher Boessenkool
If you need to guarantee that the value is written to memory at a particular time in your execution sequence, you either have to read it from memory to force the compiler to store it first That isn't enough. The CPU will happily read the datum back from its own store queue before it ever hit m

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Segher Boessenkool
The only safe way to get atomic accesses is to write assembler code. Are there any downsides to that? I don't see any. The assumption that aligned word reads and writes are atomic, and that words are aligned unless explicitly packed otherwise, is endemic in the kernel. No sane compiler viol

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Segher Boessenkool wrote: The only safe way to get atomic accesses is to write assembler code. Are there any downsides to that? I don't see any. The assumption that aligned word reads and writes are atomic, and that words are aligned unless explicitly packed otherwise, is endemic in the ker

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Segher Boessenkool
The compiler is within its rights to read a 32-bit quantity 16 bits at at time, even on a 32-bit machine. I would be glad to help pummel any compiler writer that pulls such a dirty trick, but the C standard really does permit this. Yes, but we don't write code for these compilers. There are

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Paul E. McKenney
On Thu, Aug 09, 2007 at 02:13:52PM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >On Thu, Aug 09, 2007 at 01:14:35PM -0400, Chris Snook wrote: > >>If you're depending on volatile writes > >>being visible to other CPUs, you're screwed either way, because the

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Segher Boessenkool
The only safe way to get atomic accesses is to write assembler code. Are there any downsides to that? I don't see any. The assumption that aligned word reads and writes are atomic, and that words are aligned unless explicitly packed otherwise, is endemic in the kernel. No sane compiler viol

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 01:14:35PM -0400, Chris Snook wrote: If you're depending on volatile writes being visible to other CPUs, you're screwed either way, because the CPU can hold that data in cache as long as it wants before it writes it

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Paul E. McKenney
On Thu, Aug 09, 2007 at 01:14:35PM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >On Thu, Aug 09, 2007 at 12:36:17PM -0400, Chris Snook wrote: > >>Paul E. McKenney wrote: > >>>The compiler is within its rights to read a 32-bit quantity 16 bits at > >>>at time, even on a 32-bit machine. I w

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 12:36:17PM -0400, Chris Snook wrote: Paul E. McKenney wrote: The compiler is within its rights to read a 32-bit quantity 16 bits at at time, even on a 32-bit machine. I would be glad to help pummel any compiler writer that pulls such a dirty tric

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Paul E. McKenney
On Thu, Aug 09, 2007 at 12:36:17PM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >The compiler is within its rights to read a 32-bit quantity 16 bits at > >at time, even on a 32-bit machine. I would be glad to help pummel any > >compiler writer that pulls such a dirty trick, but the C stan

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Paul E. McKenney wrote: The compiler is within its rights to read a 32-bit quantity 16 bits at at time, even on a 32-bit machine. I would be glad to help pummel any compiler writer that pulls such a dirty trick, but the C standard really does permit this. Yes, but we don't write code for these

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Segher Boessenkool wrote: We can't have split stores because we don't use atomic64_t on 32-bit architectures. That's not true; the compiler is free to split all stores (and reads) from memory however it wants. It is debatable whether "volatile" would prevent this as well, certainly it is unsaf

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Paul E. McKenney
On Thu, Aug 09, 2007 at 11:24:22AM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >On Thu, Aug 09, 2007 at 10:53:14AM -0400, Chris Snook wrote: > >>Paul E. McKenney wrote: > >>>Why not the same access-once semantics for atomic_set() as > >>>for atomic_read()? As this patch stands, it might

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Segher Boessenkool
We can't have split stores because we don't use atomic64_t on 32-bit architectures. That's not true; the compiler is free to split all stores (and reads) from memory however it wants. It is debatable whether "volatile" would prevent this as well, certainly it is unsafe if you want to be portabl

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Paul E. McKenney wrote: On Thu, Aug 09, 2007 at 10:53:14AM -0400, Chris Snook wrote: Paul E. McKenney wrote: Why not the same access-once semantics for atomic_set() as for atomic_read()? As this patch stands, it might introduce architecture-specific compiler-induced bugs due to the fact that a

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Paul E. McKenney
On Thu, Aug 09, 2007 at 10:53:14AM -0400, Chris Snook wrote: > Paul E. McKenney wrote: > >Why not the same access-once semantics for atomic_set() as > >for atomic_read()? As this patch stands, it might introduce > >architecture-specific compiler-induced bugs due to the fact that > >atomic_set() us

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
Paul E. McKenney wrote: Why not the same access-once semantics for atomic_set() as for atomic_read()? As this patch stands, it might introduce architecture-specific compiler-induced bugs due to the fact that atomic_set() used to imply volatile behavior but no longer does. When we make the vola

Re: [PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Paul E. McKenney
On Thu, Aug 09, 2007 at 09:24:42AM -0400, Chris Snook wrote: > From: Chris Snook <[EMAIL PROTECTED]> > > Purify volatile use for atomic[64]_t on alpha. Why not the same access-once semantics for atomic_set() as for atomic_read()? As this patch stands, it might introduce architecture-specific com

[PATCH 1/24] make atomic_read() behave consistently on alpha

2007-08-09 Thread Chris Snook
From: Chris Snook <[EMAIL PROTECTED]> Purify volatile use for atomic[64]_t on alpha. Signed-off-by: Chris Snook <[EMAIL PROTECTED]> --- linux-2.6.23-rc2-orig/include/asm-alpha/atomic.h2007-07-08 19:32:17.0 -0400 +++ linux-2.6.23-rc2/include/asm-alpha/atomic.h 2007-08-09 09:19:00.000