Thread (116 messages) 116 messages, 11 authors, 2017-07-10

Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic definitions

From: Paul E. McKenney <hidden>
Date: 2017-07-03 21:10:49
Also in: linux-arch, lkml, netfilter-devel

On Mon, Jul 03, 2017 at 09:40:22AM -0700, Linus Torvalds wrote:
On Mon, Jul 3, 2017 at 9:18 AM, Paul E. McKenney
[off-list ref] wrote:
quoted
Agreed, and my next step is to look at spin_lock() followed by
spin_is_locked(), not necessarily the same lock.
Hmm. Most (all?) "spin_is_locked()" really should be about the same
thread that took the lock (ie it's about asserts and lock debugging).
Good to know, that does make things easier.  ;-)

I am not certain that it is feasible to automatically recognize
non-assert/non-debugging use cases of spin_is_locked(), but there is
aways manual inspection.
The optimistic ABBA avoidance pattern for spinlocks *should* be

    spin_lock(inner)
    ...
    if (!try_lock(outer)) {
           spin_unlock(inner);
           .. do them in the right order ..

so I don't think spin_is_locked() should have any memory barriers.

In fact, the core function for spin_is_locked() is arguably
arch_spin_value_unlocked() which doesn't even do the access itself.
OK, so we should rework any cases where people are relying on acquisition
of one spin_lock() being ordered with a later spin_is_locked() on some
other lock by that same thread.

							Thanx, Paul
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help