From: Peter Zijlstra <peterz@infradead.org>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Waiman Long <waiman.long@hp.com>,
linux-arch@vger.kernel.org, riel@redhat.com, kvm@vger.kernel.org,
gleb@redhat.com, boris.ostrovsky@oracle.com,
linux-kernel@vger.kernel.org, raghavendra.kt@linux.vnet.ibm.com,
paolo.bonzini@gmail.com, oleg@redhat.com,
virtualization@lists.linux-foundation.org,
torvalds@linux-foundation.org, david.vrabel@citrix.com,
scott.norton@hp.com, xen-devel@lists.xenproject.org,
tglx@linutronix.de, paulmck@linux.vnet.ibm.com,
chegu_vinod@hp.com, mingo@kernel.org
Subject: Re: [PATCH 03/11] qspinlock: Add pending bit
Date: Tue, 24 Jun 2014 10:46:19 +0200 [thread overview]
Message-ID: <20140624084619.GN13930@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <201406172323.s5HNNveT018439@userz7022.oracle.com>
On Tue, Jun 17, 2014 at 07:23:44PM -0400, Konrad Rzeszutek Wilk wrote:
> > Actually in my v11 patch, I subdivided the slowpath into a slowpath for
> > the pending code and slowerpath for actual queuing. Perhaps, we could
> > use quickpath and slowpath instead. Anyway, it is a minor detail that we
> > can discuss after the core code get merged.
> Why not do it the right way the first time around?
Because I told him to not do this. There's the fast path; the inline
single trylock cmpxchg, and the slow path; the out-of-line thing doing
the rest.
Note that pretty much all other locking primitives are implemented
similarly, with fast and slow paths.
I find that having the entire state machine in a single function is
easier.
> That aside - these optimization - seem to make the code harder to
> read. And they do remind me of the scheduler code in 2.6.x which was
> based on heuristics - and eventually ripped out.
Well, it increases the states and thereby the complexity, nothing to be
done about that. Also, its not a random heuristic in the sense that it
has odd behaviour. Its behaviour is very well controlled.
Furthermore, without this the qspinlock performance is too far off the
ticket lock performance to be a possible replacement.
> So are these optimizations based on turning off certain hardware
> features? Say hardware prefetching?
We can try of course, but that doesn't help the code -- in fact, adding
the switch to turn if off _adds_ code on top.
> What I am getting at - can the hardware do this at some point (or
> perhaps already does on IvyBridge-EX?) - that is prefetch the per-cpu
> areas so they are always hot? And rendering this optimization not
> needed?
Got a ref to documentation on this new fancy stuff? I might have an
IVB-EX, but I've not tried it yet.
That said, memory fetches are 100s of cycles, and while prefetch can
hide some of that, I'm not sure we can hide all of it, there's not
_that_ much we do.
If we observe the pending and locked bit set, we immediately drop to the
queueing code and touch it. So there's only a few useful instructions to
do.
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Waiman Long <waiman.long@hp.com>,
raghavendra.kt@linux.vnet.ibm.com, mingo@kernel.org,
riel@redhat.com, oleg@redhat.com, gleb@redhat.com,
virtualization@lists.linux-foundation.org, tglx@linutronix.de,
chegu_vinod@hp.com, boris.ostrovsky@oracle.com,
david.vrabel@citrix.com, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org, paolo.bonzini@gmail.com,
scott.norton@hp.com, torvalds@linux-foundation.org,
kvm@vger.kernel.org, paulmck@linux.vnet.ibm.com,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH 03/11] qspinlock: Add pending bit
Date: Tue, 24 Jun 2014 10:46:19 +0200 [thread overview]
Message-ID: <20140624084619.GN13930@laptop.programming.kicks-ass.net> (raw)
Message-ID: <20140624084619.cOTKvTh2gpJjF26kfS74CoVWwIUeHdEB9WbMO5ZZqVM@z> (raw)
In-Reply-To: <201406172323.s5HNNveT018439@userz7022.oracle.com>
On Tue, Jun 17, 2014 at 07:23:44PM -0400, Konrad Rzeszutek Wilk wrote:
> > Actually in my v11 patch, I subdivided the slowpath into a slowpath for
> > the pending code and slowerpath for actual queuing. Perhaps, we could
> > use quickpath and slowpath instead. Anyway, it is a minor detail that we
> > can discuss after the core code get merged.
> Why not do it the right way the first time around?
Because I told him to not do this. There's the fast path; the inline
single trylock cmpxchg, and the slow path; the out-of-line thing doing
the rest.
Note that pretty much all other locking primitives are implemented
similarly, with fast and slow paths.
I find that having the entire state machine in a single function is
easier.
> That aside - these optimization - seem to make the code harder to
> read. And they do remind me of the scheduler code in 2.6.x which was
> based on heuristics - and eventually ripped out.
Well, it increases the states and thereby the complexity, nothing to be
done about that. Also, its not a random heuristic in the sense that it
has odd behaviour. Its behaviour is very well controlled.
Furthermore, without this the qspinlock performance is too far off the
ticket lock performance to be a possible replacement.
> So are these optimizations based on turning off certain hardware
> features? Say hardware prefetching?
We can try of course, but that doesn't help the code -- in fact, adding
the switch to turn if off _adds_ code on top.
> What I am getting at - can the hardware do this at some point (or
> perhaps already does on IvyBridge-EX?) - that is prefetch the per-cpu
> areas so they are always hot? And rendering this optimization not
> needed?
Got a ref to documentation on this new fancy stuff? I might have an
IVB-EX, but I've not tried it yet.
That said, memory fetches are 100s of cycles, and while prefetch can
hide some of that, I'm not sure we can hide all of it, there's not
_that_ much we do.
If we observe the pending and locked bit set, we immediately drop to the
queueing code and touch it. So there's only a few useful instructions to
do.
next prev parent reply other threads:[~2014-06-24 8:46 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-17 23:23 [PATCH 03/11] qspinlock: Add pending bit Konrad Rzeszutek Wilk
2014-06-17 23:23 ` Konrad Rzeszutek Wilk
2014-06-17 23:23 ` Konrad Rzeszutek Wilk
2014-06-24 8:46 ` Peter Zijlstra
2014-06-24 8:46 ` Peter Zijlstra [this message]
2014-06-24 8:46 ` Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2014-06-17 23:23 Konrad Rzeszutek Wilk
2014-06-15 12:46 [PATCH 00/11] qspinlock with paravirt support Peter Zijlstra
2014-06-15 12:47 ` [PATCH 03/11] qspinlock: Add pending bit Peter Zijlstra
2014-06-15 12:47 ` Peter Zijlstra
2014-06-15 12:47 ` Peter Zijlstra
2014-06-17 20:36 ` Konrad Rzeszutek Wilk
2014-06-17 20:36 ` Konrad Rzeszutek Wilk
2014-06-17 20:51 ` Waiman Long
2014-06-17 20:51 ` Waiman Long
2014-06-17 20:51 ` Waiman Long
2014-06-17 21:07 ` Konrad Rzeszutek Wilk
2014-06-17 21:07 ` Konrad Rzeszutek Wilk
2014-06-17 21:07 ` Konrad Rzeszutek Wilk
2014-06-17 21:10 ` Konrad Rzeszutek Wilk
2014-06-17 21:10 ` Konrad Rzeszutek Wilk
2014-06-17 22:25 ` Waiman Long
2014-06-17 22:25 ` Waiman Long
2014-06-17 22:25 ` Waiman Long
2014-06-17 21:10 ` Konrad Rzeszutek Wilk
2014-06-24 8:24 ` Peter Zijlstra
2014-06-24 8:24 ` Peter Zijlstra
2014-06-24 8:24 ` Peter Zijlstra
2014-06-18 11:29 ` Paolo Bonzini
2014-06-18 11:29 ` Paolo Bonzini
2014-06-18 13:36 ` Konrad Rzeszutek Wilk
2014-06-18 13:36 ` Konrad Rzeszutek Wilk
2014-06-18 13:36 ` Konrad Rzeszutek Wilk
2014-06-18 11:29 ` Paolo Bonzini
2014-06-23 16:35 ` Peter Zijlstra
2014-06-23 16:35 ` Peter Zijlstra
2014-06-23 16:35 ` Peter Zijlstra
2014-06-17 20:36 ` Konrad Rzeszutek Wilk
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=20140624084619.GN13930@laptop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=boris.ostrovsky@oracle.com \
--cc=chegu_vinod@hp.com \
--cc=david.vrabel@citrix.com \
--cc=gleb@redhat.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paolo.bonzini@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=raghavendra.kt@linux.vnet.ibm.com \
--cc=riel@redhat.com \
--cc=scott.norton@hp.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=waiman.long@hp.com \
--cc=xen-devel@lists.xenproject.org \
/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.