Re: Is gcc thread-unsafe?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andi Kleen <ak@...>
Cc: Linux Kernel Mailing List <linux-kernel@...>, Linus Torvalds <torvalds@...>
Date: Thursday, October 25, 2007 - 7:43 pm

On Friday 26 October 2007 09:09, Andi Kleen wrote:


But we have to mark all memory access inside the critical section
as volatile, even after the CPU synchronisation, and often the
common case where there is no contention or cacheline bouncing.

Sure, real code is dominated by cache misses anyway, etc etc.
However volatile prevents a lot of real optimisations that we'd
actually want to do, and increases icache size etc.



sbb as well.



It might just depend on the instruction costs that gcc knows about.
For example, if ld/st is expensive, they might hoist them out of
loops etc. You don't even need to have one of these predicate or
pseudo predicate instructions.



But we don't actually know what it is, and it could change with
different architectures or versions of gcc. I think the sanest thing
is for gcc to help us out here, seeing as there is this very well
defined requirement that we want.

If you really still want the optimisation to occur, I don't think it
is too much to use a local variable for the accumulator (eg. in the
simple example case).
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Is gcc thread-unsafe?, Nick Piggin, (Wed Oct 24, 11:24 pm)
Re: Is gcc thread-unsafe?, Phillip Susi, (Wed Oct 31, 6:10 pm)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Thu Oct 25, 10:55 am)
Re: Is gcc thread-unsafe?, Ismail , (Thu Oct 25, 6:26 pm)
Re: Is gcc thread-unsafe?, Jeff Garzik, (Thu Oct 25, 6:56 pm)
Re: Is gcc thread-unsafe?, Jeff Garzik, (Thu Oct 25, 7:04 pm)
RE: Is gcc thread-unsafe?, David Schwartz, (Thu Oct 25, 5:42 pm)
Re: Is gcc thread-unsafe?, Nick Piggin, (Thu Oct 25, 7:22 pm)
Re: Is gcc thread-unsafe?, Andrew Haley, (Fri Oct 26, 7:59 am)
Re: Is gcc thread-unsafe?, Andrew Haley, (Fri Oct 26, 7:59 am)
Re: Is gcc thread-unsafe?, Chris Friesen, (Fri Oct 26, 1:39 pm)
Re: Is gcc thread-unsafe?, Pekka Enberg, (Thu Oct 25, 11:12 am)
Re: Is gcc thread-unsafe?, Andi Kleen, (Thu Oct 25, 3:15 am)
Re: Is gcc thread-unsafe?, Nick Piggin, (Thu Oct 25, 6:49 pm)
Re: Is gcc thread-unsafe?, Andi Kleen, (Thu Oct 25, 7:09 pm)
Re: Is gcc thread-unsafe?, Nick Piggin, (Thu Oct 25, 7:43 pm)
Re: Is gcc thread-unsafe?, Andi Kleen, (Thu Oct 25, 7:55 pm)
Re: Is gcc thread-unsafe?, Nick Piggin, (Thu Oct 25, 7:57 pm)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Thu Oct 25, 7:14 pm)
Re: Is gcc thread-unsafe?, Andi Kleen, (Thu Oct 25, 7:16 pm)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Thu Oct 25, 7:32 pm)
Re: Is gcc thread-unsafe?, Andi Kleen, (Thu Oct 25, 7:42 pm)
Re: Is gcc thread-unsafe?, Willy Tarreau, (Fri Oct 26, 12:57 am)
Re: Is gcc thread-unsafe?, Linus Torvalds, (Thu Oct 25, 7:57 pm)
Re: Is gcc thread-unsafe?, Zachary Amsden, (Thu Oct 25, 9:15 pm)
Re: Is gcc thread-unsafe?, linux-os (Dick Johnson), (Thu Oct 25, 7:58 am)
Re: Is gcc thread-unsafe?, Andi Kleen, (Thu Oct 25, 8:16 am)
Re: Is gcc thread-unsafe?, Arjan van de Ven, (Wed Oct 24, 11:46 pm)
Re: Is gcc thread-unsafe?, Nick Piggin, (Wed Oct 24, 11:58 pm)
RE: Is gcc thread-unsafe?, David Schwartz, (Thu Oct 25, 12:29 am)
Re: Is gcc thread-unsafe?, Nick Piggin, (Thu Oct 25, 12:47 am)
Re: Is gcc thread-unsafe?, Samuel Tardieu, (Thu Oct 25, 5:44 am)
Re: Is gcc thread-unsafe?, Andi Kleen, (Thu Oct 25, 5:55 am)
Re: Is gcc thread-unsafe?, Arjan van de Ven, (Thu Oct 25, 12:35 am)