lkml.org 
[lkml]   [2006]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] WorkStruct: Implement generic UP cmpxchg() where an arch doesn't support it
    On Wed, Dec 06, 2006 at 07:58:20PM +0000, Russell King wrote:
    > No. If you read what I said, you'll see that you can _cheaply_ use
    > cmpxchg in a ll/sc based implementation. Take an atomic increment
    > operation.
    >
    > do {
    > old = load_locked(addr);
    > } while (store_exclusive(old, old + 1, addr);

    [...]

    > Implementing ll/sc based accessor macros allows both ll/sc _and_ cmpxchg
    > architectures to produce optimal code.
    >
    > Implementing an cmpxchg based accessor macro allows cmpxchg architectures
    > to produce optimal code and ll/sc non-optimal code.

    And for those of us with only load-and-zero, that's simply:

    #define load_locked(addr) spin_lock(hash(addr)), *addr
    #define store_exclusive(addr, old, new) \
    *addr = new, spin_unlock(hash(addr)), 0

    which is also optimal for us.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-12-06 22:39    [W:8.452 / U:0.124 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site