Hmmm... Maybe we therefore need to add a mode to each bit operation in the kernel?
With that we can also get rid of the __* version of bitops.
Possible modes are
NON_ATOMIC Do not perform any atomic ops at all.
ATOMIC Atomic but unordered
ACQUIRE Atomic with acquire semantics (or lock semantics)
RELEASE Atomic with release semantics (or unlock semantics)
FENCE Atomic with full fence.
This would require another bitops overhaul.
Maybe we can preserve the existing code with bitops like __* mapped to *(..., NON_ATOMIC) and * mapped to *(..., FENCE) and the gradually fix the rest of the kernel.
+ switch (mode) {
+ case MODE_NONE :
+ case MODE_ACQUIRE :
+ return cmpxchg_acq(m, old, new);
+ case MODE_FENCE :
+ smp_mb();
+ /* Fall through */
+ case MODE_RELEASE :
+ return cmpxchg_rel(m, old, new);
+ if (mode == ORDER_NON_ATOMIC) {
+ *m |= bit;
+ return;
+ }