Linus Torvalds wrote: > "volatile" should be equivalent to clobbering memory, although the gcc > manual pages are certainly not very verbose on the issue. It isn't. Try the following with/without the memory clobber: int *p; int func() { int x; x = *p; __asm__ __volatile__ ("" : : : "memory"); x = *p; return x; } With or without, the program reads *p only once. However, with the clobber it reads _after_ the asm; without, it reads _before_ the asm. It's ok for the compiler to do that (given we don't know what "volatile" means anyway :-). But it does have implications for spin_lock: spin_lock must say that it clobbers memory. spin_unlock should also say it clobbers memory but I have no test case to demonstrate the compiler moving reads down past an asm. -- Jamie - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
- Re: spin_lock forgets to clobber memory and other sm... Andrea Arcangeli
- Re: spin_lock forgets to clobber memory and othe... Jamie Lokier
- Re: spin_lock forgets to clobber memory and ... Linus Torvalds
- Re: spin_lock forgets to clobber memory ... Jamie Lokier
- Re: spin_lock forgets to clobber memory and ... Andrea Arcangeli
- Re: spin_lock forgets to clobber memory ... Jamie Lokier
- Re: spin_lock forgets to clobber memory ... Andrea Arcangeli
- Re: spin_lock forgets to clobber memory and other sm... Linus Torvalds
- Re: spin_lock forgets to clobber memory and othe... Jamie Lokier
- Re: spin_lock forgets to clobber memory and other smp fix... Linus Torvalds
- Re: spin_lock forgets to clobber memory and other sm... Jamie Lokier
- Re: spin_lock forgets to clobber memory and othe... Linus Torvalds
- Re: spin_lock forgets to clobber memory and othe... Andrea Arcangeli
- Re: spin_lock forgets to clobber memory and ... Jamie Lokier
- Re: spin_lock forgets to clobber memory ... Andrea Arcangeli
- Re: spin_lock forgets to clobber memory and ... David Woodhouse
- Re: spin_lock forgets to clobber memory ... Andrea Arcangeli
- Re: spin_lock forgets to clobber memory and other smp fix... kuznet
- Re: spin_lock forgets to clobber memory and other sm... Andrea Arcangeli
- GCC proposal for "@" asm constraint Jamie Lokier
- Re: GCC proposal for "@" asm const... Andrea Arcangeli