Messages in this thread | | | Date | Thu, 7 Sep 2000 18:46:29 +0200 | From | Jamie Lokier <> | Subject | Re: spin_lock forgets to clobber memory and other smp fixes [was Re: [patch] waitqueue optimization, 2.4.0-test7] |
| |
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 majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
| |