• Mathieu Desnoyers's avatar
    Add cmpxchg_local to asm-generic for per cpu atomic operations · 068fbad2
    Mathieu Desnoyers authored
    
    
    Emulates the cmpxchg_local by disabling interrupts around variable modification.
    This is not reentrant wrt NMIs and MCEs. It is only protected against normal
    interrupts, but this is enough for architectures without such interrupt sources
    or if used in a context where the data is not shared with such handlers.
    
    It can be used as a fallback for architectures lacking a real cmpxchg
    instruction.
    
    For architectures that have a real cmpxchg but does not have NMIs or MCE,
    testing which of the generic vs architecture specific cmpxchg is the fastest
    should be done.
    
    asm-generic/cmpxchg.h defines a cmpxchg that uses cmpxchg_local. It is meant to
    be used as a cmpxchg fallback for architectures that do not support SMP.
    
    * Patch series comments
    
    Using cmpxchg_local shows a performance improvements of the fast path goes from
    a 66% speedup on a Pentium 4 to a 14% speedup on AMD64.
    
    In detail:
    Tested-by: default avatarMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
    Measu...
    068fbad2
cmpxchg-local.h 1.34 KB