• Will Deacon's avatar
    locking/core: Remove break_lock field when CONFIG_GENERIC_LOCKBREAK=y · d89c7035
    Will Deacon authored
    When CONFIG_GENERIC_LOCKBEAK=y, locking structures grow an extra int ->break_lock
    field which is used to implement raw_spin_is_contended() by setting the field
    to 1 when waiting on a lock and clearing it to zero when holding a lock.
    However, there are a few problems with this approach:
      - There is a write-write race between a CPU successfully taking the lock
        (and subsequently writing break_lock = 0) and a waiter waiting on
        the lock (and subsequently writing break_lock = 1). This could result
        in a contended lock being reported as uncontended and vice-versa.
      - On machines with store buffers, nothing guarantees that the writes
        to break_lock are visible to other CPUs at any particular time.
      - READ_ONCE/WRITE_ONCE are not used, so the field is potentially
        susceptible to harmful compiler optimisations,
    Consequently, the usefulness of this field is unclear and we'd be better off
    removing it and allowing architectures to implement raw_spin_is_contended() by
    providing a definition of arch_spin_is_contended(), as they can when
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
    Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/1511894539-7988-3-git-send-email-will.deacon@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
rwlock_types.h 1.12 KB