• Guo Ren's avatar
    csky: atomic: Add conditional atomic operations' optimization · c5acdf12
    Guo Ren authored
    Add conditional atomic operations' optimization:
     - arch_atomic_fetch_add_unless
     - arch_atomic_inc_unless_negative
     - arch_atomic_dec_unless_positive
     - arch_atomic_dec_if_positive
    
    Comments by Boqun:
    
    FWIW, you probably need to make sure that a barrier instruction inside
    an lr/sc loop is a good thing. IIUC, the execution time of a barrier
    instruction is determined by the status of store buffers and invalidate
    queues (and probably other stuffs), so it may increase the execution
    time of the lr/sc loop, and make it unlikely to succeed. But this really
    depends on how the arch executes these instructions.
    Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
    Signed-off-by: default avatarGuo Ren <guoren@kernel.org>
    Cc: Boqun Feng <boqun.feng@gmail.com>
    c5acdf12
atomic.h 5.24 KB