Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
Date: 2007-08-17 11:09:18
Also in:
linux-arch, lkml
Nick Piggin wrote:
Satyam Sharma wrote:quoted
And we have driver / subsystem maintainers such as Stefan coming up and admitting that often a lot of code that's written to use atomic_read() does assume the read will not be elided by the compiler.So these are broken on i386 and x86-64?
The ieee1394 and firewire subsystems have open, undiagnosed bugs, also on i386 and x86-64. But whether there is any bug because of wrong assumptions about atomic_read among them, I don't know. I don't know which assumptions the authors made, I only know that I wasn't aware of all the properties of atomic_read until now.
Are they definitely safe on SMP and weakly ordered machines with just a simple compiler barrier there? Because I would not be surprised if there are a lot of developers who don't really know what to assume when it comes to memory ordering issues. This is not a dig at driver writers: we still have memory ordering problems in the VM too (and probably most of the subtle bugs in lockless VM code are memory ordering ones). Let's not make up a false sense of security and hope that sprinkling volatile around will allow people to write bug-free lockless code. If a writer can't be bothered reading API documentation
...or, if there is none, the implementation specification (as in case of the atomic ops), or, if there is none, the implementation (as in case of a some infrastructure code here and there)...
and learning the Linux memory model, they can still be productive writing safely locked code.
Provided they are aware that they might not have the full picture of the lockless primitives. :-) -- Stefan Richter -=====-=-=== =--- =---= http://arcgraph.de/sr/