Shared memory consistency in Linux

"Andrew Perepechko" <[email protected]> Mon, 22 Nov 2004 21:05:37 +0300 (MSK)
Newsgroups org.kernel.vger.linux-smp
Message-ID <[email protected]>
Is there some simple rule that can help in exploring if some kernel routine provides read or write barrier (or both)?

I can see in the kernel source that it is correct to omit explicit memory barrier in the following example:

code A:

event = 1;
mb(); // Unnecessary
wake_up(wq);

code B:

wait_event(&wq, event == 1);


This feature (write barrier presence in wake_up) is not documented in the kernel code, can it get changed in the future? 

Which kernel routines (except this one) provide memory barriers (and will provide in the future), especially locking routines? 

I've read "Unreliable Guide to Locking" by R.Russell, but i'd like some reliable (and more complete) guide.