]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/spinlock: Unserialize spin_is_locked
authorDavidlohr Bueso <dave@stgolabs.net>
Tue, 9 Mar 2021 01:59:49 +0000 (17:59 -0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 26 Mar 2021 12:19:43 +0000 (23:19 +1100)
commite581972eb0da2443b257f902f1505aa9625a3b5f
treee5d9e3abaa84b75a49555ab45ee6a20ccf889fe6
parent523a863f46d50a96ff5f2122d59b998ecf33f33e
powerpc/spinlock: Unserialize spin_is_locked

574390b66a57 (locking/spinlocks/arm64: Remove smp_mb() from
arch_spin_is_locked()) made it pretty official that the call
semantics do not imply any sort of barriers, and any user that
gets creative must explicitly do any serialization.

This creativity, however, is nowadays pretty limited:

1. spin_unlock_wait() has been removed from the kernel in favor
of a lock/unlock combo. Furthermore, queued spinlocks have now
for a number of years no longer relied on _Q_LOCKED_VAL for the
call, but any non-zero value to indicate a locked state. There
were cases where the delayed locked store could lead to breaking
mutual exclusion with crossed locking; such as with sysv ipc and
netfilter being the most extreme.

2. The auditing Andrea did in verified that remaining spin_is_locked()
no longer rely on such semantics. Most callers just use it to assert
a lock is taken, in a debug nature. The only user that gets cute is
NOLOCK qdisc, as of:

   4e589b84eac8 (sched: replace __QDISC_STATE_RUNNING bit with a spin lock)

... which ironically went in the next day after 574390b66a57. This
change replaces test_bit() with spin_is_locked() to know whether
to take the busylock heuristic to reduce contention on the main
qdisc lock. So any races against spin_is_locked() for archs that
use LL/SC for spin_lock() will be benign and not break any mutual
exclusion; furthermore, both the seqlock and busylock have the same
scope.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210309015950.27688-3-dave@stgolabs.net
arch/powerpc/include/asm/qspinlock.h
arch/powerpc/include/asm/simple_spinlock.h