• Madhavan Srinivasan's avatar
    powerpc/64s: Implement local_t using irq soft masking · 6cd74d2b
    Madhavan Srinivasan authored
    local_t is used for atomic modifications for per-CPU data, versus
    re-entrant modifications via interrupts.
    
    local_t read-modify-write atomic operations are currently implemented
    with hardware atomics (larx/stcx), which are quite slow. This patch
    implements them by masking all types of interrupts that may do local_t
    operations ("standard" and perf interrupts).
    
    Rusty's benchmark (https://lkml.org/lkml/2008/12/16/450) gives the
    following timings for the local_t test, in nanoseconds per iteration:
    
                 larx/stcx   irq+pmu disable
    _inc                38                10
    _add                38                10
    _read                4                 4
    _add_return         38                10
    
    There are still some interrupt types (system reset, machine check, and
    watchdog), which can not safely use local_t operations, because they
    are not masked.
    
    An alternative approach was proposed, using a CR bit to mark a critical
    section, which is tested in the interrupt return path, and would then
    branch to a fixup handler (similar to exception fixups), which re-starts
    the operation. The problem with this was the complexity of the fixup
    handler and the latency of the slow path.
    
    https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-November/123024.htmlSigned-off-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    6cd74d2b
local.h 3.18 KB