Re: [PATCH] WorkStruct: Implement generic UP cmpxchg() where an
From: David Howells
Date: Tue Dec 12 2006 - 05:38:09 EST
linux@xxxxxxxxxxx wrote:
> do {
> oldvalue = ll(addr)
> newvalue = ... oldvalue ...
> } while (!sc(addr, oldvalue, newvalue))
>
> Where sc() could be a cmpxchg. But, more importantly, if the
> architecture did implement LL/SC, it could be a "try plain SC; if
> that fails try CMPXCHG built out of LL/SC; if that fails, loop"
If sc() is implemented with cmpxchg(), then this is a very silly piece of
code. cmpxchg() returns the current value if it fails, rendering a repetition
of ll() pointless. In some circumstances, you should really do it by putting
the cmpxchg() up front with what you expect the most likely substitution to
be, and that then doesn't require the initial load.
David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/