linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
	manfred@colorfullife.com, dave@stgolabs.net,
	paulmck@linux.vnet.ibm.com, will.deacon@arm.com,
	boqun.feng@gmail.com, Waiman.Long@hpe.com, tj@kernel.org,
	pablo@netfilter.org, kaber@trash.net, davem@davemloft.net,
	oleg@redhat.com, netfilter-devel@vger.kernel.org,
	sasha.levin@oracle.com, hofrat@osadl.org, rth@twiddle.net,
	vgupta@synopsys.com, linux@armlinux.org.uk, realmz6@gmail.com,
	rkuo@codeaurora.org, tony.luck@intel.com, james.hogan@imgtec.com,
	ralf@linux-mips.org, dhowells@redhat.com, jejb@parisc-linux.org,
	mpe@ellerman.id.au, ysato@users.sourceforge.jp,
	cmetcalf@mellanox.com, chris@zankel.net,
	Heiko Carstens <heiko.carstens@de.ibm.com>
Subject: Re: [PATCH -v2 4/6] locking, arch: Update spin_unlock_wait()
Date: Fri, 27 May 2016 08:46:49 +0200	[thread overview]
Message-ID: <20160527084649.065c7609@mschwide> (raw)
In-Reply-To: <20160526142354.293350777@infradead.org>

On Thu, 26 May 2016 16:19:26 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> This patch updates/fixes all spin_unlock_wait() implementations.
> 
> The update is in semantics; where it previously was only a control
> dependency, we now upgrade to a full load-acquire to match the
> store-release from the spin_unlock() we waited on. This ensures that
> when spin_unlock_wait() returns, we're guaranteed to observe the full
> critical section we waited on.
> 
> This fixes a number of spin_unlock_wait() users that (not
> unreasonably) rely on this.

All that is missing is an smp_rmb(), no? 

> --- a/arch/s390/include/asm/spinlock.h
> +++ b/arch/s390/include/asm/spinlock.h
> @@ -95,8 +95,7 @@ static inline void arch_spin_unlock(arch
> 
>  static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
>  {
> -	while (arch_spin_is_locked(lock))
> -		arch_spin_relax(lock);
> +	smp_cond_load_acquire(&lock->lock, !VAL);
>  }
> 
>  /*

This change adds the smp_rmb() at the end of the waiting loop, but
it also replaces arch_spin_relax() alias arch_lock_relax() with a
cpu_relax(). This is not good, these two functions do *very* different
things. cpu_relax() does an undirected yield with diagnose 0x44 but
only if the system is non-SMT. arch_lock_relax() does an additional
cpu_is_preempted() to test if the target cpu is running and does a
directed yield with diagnose 0x9c. 

Why can't we just add the smp_rmb() to the arch_spin_unlock_wait()?

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

  parent reply	other threads:[~2016-05-27  8:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26 14:19 [PATCH -v2 0/6] spin_unlock_wait borkage Peter Zijlstra
2016-05-26 14:19 ` [PATCH -v2 1/6] locking: Replace smp_cond_acquire with smp_cond_load_acquire Peter Zijlstra
2016-05-26 14:19 ` [PATCH -v2 2/6] locking: Introduce cmpwait() Peter Zijlstra
2016-05-26 14:19 ` [PATCH -v2 3/6] locking: Introduce smp_acquire__after_ctrl_dep Peter Zijlstra
2016-05-26 14:19 ` [PATCH -v2 4/6] locking, arch: Update spin_unlock_wait() Peter Zijlstra
2016-05-26 21:10   ` Chris Metcalf
2016-05-27  9:05     ` Peter Zijlstra
2016-05-27 19:34       ` Chris Metcalf
2016-05-30  9:25         ` Peter Zijlstra
2016-05-27  6:46   ` Martin Schwidefsky [this message]
2016-05-27  9:02     ` Peter Zijlstra
2016-05-26 14:19 ` [PATCH -v2 5/6] locking: Update spin_unlock_wait users Peter Zijlstra
2016-05-26 14:19 ` [PATCH -v2 6/6] locking,netfilter: Fix nf_conntrack_lock() Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160527084649.065c7609@mschwide \
    --to=schwidefsky@de.ibm.com \
    --cc=Waiman.Long@hpe.com \
    --cc=boqun.feng@gmail.com \
    --cc=chris@zankel.net \
    --cc=cmetcalf@mellanox.com \
    --cc=dave@stgolabs.net \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hofrat@osadl.org \
    --cc=james.hogan@imgtec.com \
    --cc=jejb@parisc-linux.org \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=manfred@colorfullife.com \
    --cc=mpe@ellerman.id.au \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=ralf@linux-mips.org \
    --cc=realmz6@gmail.com \
    --cc=rkuo@codeaurora.org \
    --cc=rth@twiddle.net \
    --cc=sasha.levin@oracle.com \
    --cc=tj@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vgupta@synopsys.com \
    --cc=will.deacon@arm.com \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).