Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1679161

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

From "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic definitions
Date 2017-07-01 00:20 +0200
Message-ID <tYcqB-2Lm-5@gated-at.bofh.it> (permalink)
References <tXRvP-663-1@gated-at.bofh.it> <tXRFw-6oX-3@gated-at.bofh.it> <tY0fL-3yd-15@gated-at.bofh.it> <tY3x0-5xi-25@gated-at.bofh.it> <tY402-5YH-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jun 30, 2017 at 02:13:39PM +0100, Will Deacon wrote:
> On Fri, Jun 30, 2017 at 05:38:15AM -0700, Paul E. McKenney wrote:
> > On Fri, Jun 30, 2017 at 10:19:29AM +0100, Will Deacon wrote:
> > > On Thu, Jun 29, 2017 at 05:01:16PM -0700, Paul E. McKenney wrote:
> > > > There is no agreed-upon definition of spin_unlock_wait()'s semantics,
> > > > and it appears that all callers could do just as well with a lock/unlock
> > > > pair.  This commit therefore removes spin_unlock_wait() and related
> > > > definitions from core code.
> > > > 
> > > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > > > Cc: Arnd Bergmann <arnd@arndb.de>
> > > > Cc: Ingo Molnar <mingo@redhat.com>
> > > > Cc: Will Deacon <will.deacon@arm.com>
> > > > Cc: Peter Zijlstra <peterz@infradead.org>
> > > > Cc: Alan Stern <stern@rowland.harvard.edu>
> > > > Cc: Andrea Parri <parri.andrea@gmail.com>
> > > > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > > > ---
> > > >  include/asm-generic/qspinlock.h |  14 -----
> > > >  include/linux/spinlock.h        |  31 -----------
> > > >  include/linux/spinlock_up.h     |   6 ---
> > > >  kernel/locking/qspinlock.c      | 117 ----------------------------------------
> > > >  4 files changed, 168 deletions(-)
> > > 
> > > [...]
> > > 
> > > > diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
> > > > index b2caec7315af..64a9051e4c2c 100644
> > > > --- a/kernel/locking/qspinlock.c
> > > > +++ b/kernel/locking/qspinlock.c
> > > > @@ -267,123 +267,6 @@ static __always_inline u32  __pv_wait_head_or_lock(struct qspinlock *lock,
> > > >  #define queued_spin_lock_slowpath	native_queued_spin_lock_slowpath
> > > >  #endif
> > > >  
> > > > -/*
> > > > - * Various notes on spin_is_locked() and spin_unlock_wait(), which are
> > > > - * 'interesting' functions:
> > > > - *
> > > > - * PROBLEM: some architectures have an interesting issue with atomic ACQUIRE
> > > > - * operations in that the ACQUIRE applies to the LOAD _not_ the STORE (ARM64,
> > > > - * PPC). Also qspinlock has a similar issue per construction, the setting of
> > > > - * the locked byte can be unordered acquiring the lock proper.
> > > > - *
> > > > - * This gets to be 'interesting' in the following cases, where the /should/s
> > > > - * end up false because of this issue.
> > > > - *
> > > > - *
> > > > - * CASE 1:
> > > > - *
> > > > - * So the spin_is_locked() correctness issue comes from something like:
> > > > - *
> > > > - *   CPU0				CPU1
> > > > - *
> > > > - *   global_lock();			local_lock(i)
> > > > - *     spin_lock(&G)			  spin_lock(&L[i])
> > > > - *     for (i)				  if (!spin_is_locked(&G)) {
> > > > - *       spin_unlock_wait(&L[i]);	    smp_acquire__after_ctrl_dep();
> > > > - *					    return;
> > > > - *					  }
> > > > - *					  // deal with fail
> > > > - *
> > > > - * Where it is important CPU1 sees G locked or CPU0 sees L[i] locked such
> > > > - * that there is exclusion between the two critical sections.
> > > > - *
> > > > - * The load from spin_is_locked(&G) /should/ be constrained by the ACQUIRE from
> > > > - * spin_lock(&L[i]), and similarly the load(s) from spin_unlock_wait(&L[i])
> > > > - * /should/ be constrained by the ACQUIRE from spin_lock(&G).
> > > > - *
> > > > - * Similarly, later stuff is constrained by the ACQUIRE from CTRL+RMB.
> > > 
> > > Might be worth keeping this comment about spin_is_locked, since we're not
> > > removing that guy just yet!
> > 
> > Ah, all the examples had spin_unlock_wait() in them.  So what I need to
> > do is to create a spin_unlock_wait()-free example to illustrate the
> > text starting with "The load from spin_is_locked(", correct?
> 
> Yeah, I think so.
> 
> > I also need to check all uses of spin_is_locked().  There might no
> > longer be any that rely on any particular ordering...
> 
> Right. I think we're looking for the "insane case" as per 38b850a73034
> (which was apparently used by ipc/sem.c at the time, but no longer).
> 
> There's a usage in kernel/debug/debug_core.c, but it doesn't fill me with
> joy.

That is indeed an interesting one...  But my first round will be what
semantics the implementations seem to provide:

Acquire courtesy of TSO: s390, sparc, x86.
Acquire: ia64 (in reality fully ordered).
Control dependency: alpha, arc, arm, blackfin, hexagon, m32r, mn10300, tile,
	xtensa.
Control dependency plus leading full barrier: arm64, powerpc.
UP-only: c6x, cris, frv, h8300, m68k, microblaze nios2, openrisc, um, unicore32.

Special cases:
	metag: Acquire if !CONFIG_METAG_SMP_WRITE_REORDERING.
	       Otherwise control dependency?
	mips: Control dependency, acquire if CONFIG_CPU_CAVIUM_OCTEON.
	parisc: Acquire courtesy of TSO, but why barrier in smp_load_acquire?
	sh: Acquire if one of SH4A, SH5, or J2, otherwise acquire?  UP-only?

Are these correct, or am I missing something with any of them?

							Thanx, Paul

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC 0/26] Remove spin_unlock_wait() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:00 +0200
  [PATCH RFC 13/26] blackfin: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
    Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic  definitions Will Deacon <will.deacon@arm.com> - 2017-06-30 11:20 +0200
      Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic  definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 14:50 +0200
        Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic  definitions Will Deacon <will.deacon@arm.com> - 2017-06-30 15:20 +0200
          Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic  definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-07-01 00:20 +0200
            Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic  definitions Will Deacon <will.deacon@arm.com> - 2017-07-03 15:20 +0200
  [PATCH RFC 23/26] sh: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 16/26] m32r: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 21/26] powerpc: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
    Re: [PATCH RFC 21/26] powerpc: Remove spin_unlock_wait()  arch-specific definitions Boqun Feng <boqun.feng@gmail.com> - 2017-07-02 06:00 +0200
  [PATCH RFC 25/26] tile: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
    Re: [PATCH RFC 25/26] tile: Remove spin_unlock_wait() arch-specific definitions Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-30 02:10 +0200
      Re: [PATCH RFC 25/26] tile: Remove spin_unlock_wait() arch-specific definitions Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-30 02:20 +0200
        Re: [PATCH RFC 25/26] tile: Remove spin_unlock_wait() arch-specific  definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:30 +0200
      Re: [PATCH RFC 25/26] tile: Remove spin_unlock_wait() arch-specific  definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:20 +0200
      Re: [PATCH RFC 25/26] tile: Remove spin_unlock_wait() arch-specific  definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:20 +0200
  [PATCH RFC 18/26] mips: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 19/26] mn10300: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 20/26] parisc: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 15/26] ia64: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 11/26] arm: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 22/26] s390: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 01/26] netfilter: Replace spin_unlock_wait() with lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
    Re: [PATCH RFC 01/26] netfilter: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-07-02 04:10 +0200
  [PATCH RFC 04/26] completion: Replace spin_unlock_wait() with lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 07/26] drivers/ata: Replace spin_unlock_wait() with lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 14/26] hexagon: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 09/26] alpha: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 24/26] sparc: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 26/26] xtensa: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:10 +0200
  [PATCH RFC 03/26] sched: Replace spin_unlock_wait() with lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:20 +0200
    Re: [PATCH RFC 03/26] sched: Replace spin_unlock_wait() with  lock/unlock pair Arnd Bergmann <arnd@arndb.de> - 2017-06-30 12:40 +0200
      Re: [PATCH RFC 03/26] sched: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 14:40 +0200
  [PATCH RFC 05/26] exit: Replace spin_unlock_wait() with lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:20 +0200
  [PATCH RFC 12/26] arm64: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:20 +0200
    Re: [PATCH RFC 12/26] arm64: Remove spin_unlock_wait() arch-specific  definitions Will Deacon <will.deacon@arm.com> - 2017-06-30 11:30 +0200
      Re: [PATCH RFC 12/26] arm64: Remove spin_unlock_wait() arch-specific  definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 19:40 +0200
  [PATCH RFC 10/26] arc: Remove spin_unlock_wait() arch-specific definitions "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:20 +0200
  [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 02:20 +0200
    Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair Oleg Nesterov <oleg@redhat.com> - 2017-06-30 13:10 +0200
      Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 15:00 +0200
        Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair Oleg Nesterov <oleg@redhat.com> - 2017-06-30 17:30 +0200
          Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 18:20 +0200
            Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 19:30 +0200
            Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair Oleg Nesterov <oleg@redhat.com> - 2017-06-30 21:30 +0200
              Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair Alan Stern <stern@rowland.harvard.edu> - 2017-06-30 22:00 +0200
                Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 22:10 +0200
              Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 22:10 +0200
                Re: [PATCH RFC 02/26] task_work: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-06-30 22:20 +0200
  Re: [PATCH RFC 06/26] ipc: Replace spin_unlock_wait() with  lock/unlock pair Manfred Spraul <manfred@colorfullife.com> - 2017-07-01 21:30 +0200
    Re: [PATCH RFC 06/26] ipc: Replace spin_unlock_wait() with  lock/unlock pair "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-07-02 05:20 +0200

csiph-web