From: Michael Ellerman <mpe@ellerman.id.au>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linuxppc-dev@lists.ozlabs.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Will Deacon <will.deacon@arm.com>,
Boqun Feng <boqun.feng@gmail.com>
Subject: Re: [PATCH v3] powerpc: spinlock: Fix spin_unlock_wait()
Date: Mon, 06 Jun 2016 22:17:25 +1000 [thread overview]
Message-ID: <1465215445.2658.4.camel@ellerman.id.au> (raw)
In-Reply-To: <20160606115655.GD30909@twins.programming.kicks-ass.net>
On Mon, 2016-06-06 at 13:56 +0200, Peter Zijlstra wrote:
> On Mon, Jun 06, 2016 at 09:42:20PM +1000, Michael Ellerman wrote:
> > +static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
> > +{
> > + arch_spinlock_t lock_val;
> > +
> > + smp_mb();
> > +
> > + /*
> > + * Atomically load and store back the lock value (unchanged). This
> > + * ensures that our observation of the lock value is ordered with
> > + * respect to other lock operations.
> > + */
> > + __asm__ __volatile__(
> > +"1: " PPC_LWARX(%0, 0, %2, 0) "\n"
> > +" stwcx. %0, 0, %2\n"
> > +" bne- 1b\n"
> > + : "=&r" (lock_val), "+m" (*lock)
> > + : "r" (lock)
> > + : "cr0", "xer");
> > +
> > + if (arch_spin_value_unlocked(lock_val))
> > + goto out;
> > +
> > + while (!arch_spin_value_unlocked(*lock)) {
> > + HMT_low();
> > + if (SHARED_PROCESSOR)
> > + __spin_yield(lock);
> > + }
> > + HMT_medium();
> > +
> > +out:
> > + smp_mb();
> > +}
>
> Why the move to in-line this implementation? It looks like a fairly big
> function.
I agree it's not pretty.
I just didn't think having it out-of-line made it easier to understand. The
previous version had:
static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
{
...
if (!arch_spin_is_locked_sync(lock))
goto out;
Then elsewhere:
static inline bool arch_spin_is_locked_sync(arch_spinlock_t *lock)
{
...
return !arch_spin_value_unlocked(tmp);
}
So two negations and one routine called "locked" and one "unlocked", which just
didn't read well IMHO.
Another minor concern was that someone might be "clever" and call the _sync()
version manually (though hopefully we'd catch that in review).
I'm not beholden to v3 though if you hate it.
cheers
next prev parent reply other threads:[~2016-06-06 12:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 11:42 [PATCH v3] powerpc: spinlock: Fix spin_unlock_wait() Michael Ellerman
2016-06-06 11:56 ` Peter Zijlstra
2016-06-06 12:17 ` Michael Ellerman [this message]
2016-06-06 14:46 ` Peter Zijlstra
2016-06-08 11:20 ` Michael Ellerman
2016-06-08 12:35 ` Peter Zijlstra
2016-06-08 13:49 ` Michael Ellerman
2016-06-08 13:59 ` Peter Zijlstra
2016-06-09 12:23 ` Michael Ellerman
2016-06-09 17:25 ` Boqun Feng
2016-06-10 3:06 ` Boqun Feng
2016-06-09 17:50 ` Peter Zijlstra
2016-06-10 0:57 ` Michael Ellerman
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=1465215445.2658.4.camel@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=benh@kernel.crashing.org \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=will.deacon@arm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.