CAS implementation may be broken
Catalin Marinas
catalin.marinas at arm.com
Mon Nov 23 10:34:39 EST 2009
On Sat, 2009-11-21 at 15:21 +0000, Toby Douglass wrote:
> Load-linked/conditional-store architectures solve ABA by having the
> store fail if the destination has been touched since the load was performed.
So, for your problem, CAS wouldn't solve it on any architecture, not
just ARM if it is implemented with LL/SC.
Something like below may work (untested and haven't put much thought
into it). Basically you need atomicity between the moment you first get
the head pointer and the moment you update it. CAS doesn't ensure this
since the first load of the [head] pointer would be standard LDR (even
if it is LDREX, you get another LDREX which resets the link with the
STREX):
1: LDREX orig_head, [head]
LDR orig_next, [orig_head, #next]
STREX res, orig_next, [head]
cmp res, #0
bne 1b
--
Catalin
More information about the linux-arm-kernel
mailing list