xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] gnttab: refactor locking for better scalability
@ 2013-11-12  2:03 Matt Wilson
  2013-11-12  2:03 ` [RFC PATCH 1/2] gnttab: lock the local grant table earlier in __gnttab_unmap_common() Matt Wilson
  2013-11-12  2:03 ` [RFC PATCH 2/2] gnttab: refactor locking for better scalability Matt Wilson
  0 siblings, 2 replies; 22+ messages in thread
From: Matt Wilson @ 2013-11-12  2:03 UTC (permalink / raw)
  To: xen-devel
  Cc: Felipe Franciosi, Anthony Liguori, Andrew Cooper, David Vrabel,
	Jan Beulich, Keir Fraser, Matt Wilson, Roger Pau Monné

From: Matt Wilson <msw@amazon.com>

As discussed in the Xen Developer Summit Storage Performance BoF,
there is a lot of room for improvement in grant table locking. Anthony
and I have been working on refactoring the locking over the past few
weeks. The performance improvement is considerable and I'd like to
hear from others if this approach is fundamentally wrong for some
reason.

The previous single spinlock per grant table is split into multiple
locks. The heavily modified components of the grant table (the
maptrack state and the active entries) are now protected by their own
spinlocks. The remaining elements of the grant table are read-mostly,
so I modified the main grant table lock to be a rwlock to improve
concurrency.

On the performance improvement: Without persistent grants, a domU with
24 VBDs plummbed to local HDDs in a streaming 2M write workload
achieved 1,400 MB/sec before this change. Performance more than
doubles with this patch, reaching 3,000 MB/sec before tuning and 3,600
MB/sec after adjusting event channel vCPU bindings.

I included the previously posted patch to __gnttab_unmap_common() in
the series since it makes a bit more sense in this context, and the
follow on refactor patch is on top of it.

DISCLAIMER: I ported this patch from a different Xen version earlier
today, and I've only compile tested so far. In the original state
we've pushed a lot of concurrent I/O through dom0 and haven't seen any
stability issues.

Matt Wilson (2):
  gnttab: lock the local grant table earlier in __gnttab_unmap_common()
  gnttab: refactor locking for better scalability

 docs/misc/grant-tables.txt    |   56 +++++++-
 xen/arch/x86/mm.c             |    4 +-
 xen/common/grant_table.c      |  308 ++++++++++++++++++++++++++---------------
 xen/include/xen/grant_table.h |    9 +-
 4 files changed, 261 insertions(+), 116 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: [RFC PATCH 2/2] gnttab: refactor locking for better scalability
@ 2014-06-21  0:13 Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 22+ messages in thread
From: Konrad Rzeszutek Wilk @ 2014-06-21  0:13 UTC (permalink / raw)
  To: Matt Wilson
  Cc: Felipe Franciosi, Matt Wilson, andrew.cooper3, Jan Beulich,
	Keir Fraser, David Vrabel, Anthony Liguori, Konrad Rzeszutek Wilk,
	xen-devel, roger.pau


On Jun 20, 2014 5:18 PM, Matt Wilson <msw@linux.com> wrote:
>
> On Fri, Jun 20, 2014 at 04:54:15PM -0400, Konrad Rzeszutek Wilk wrote: 
> > On Tue, Nov 12, 2013 at 02:24:50PM +0000, Keir Fraser wrote: 
> > > On 12/11/2013 14:11, "Jan Beulich" <JBeulich@suse.com> wrote: 
> > > 
> > > >>>> On 12.11.13 at 14:58, Keir Fraser <keir.xen@gmail.com> wrote: 
> > > >> On 12/11/2013 13:42, "Keir Fraser" <keir.xen@gmail.com> wrote: 
> > > >> 
> > > >>>> And indeed I think we should be making our rwlocks fair for writers 
> > > >>>> before pushing in the change here; I've been meaning to get to this 
> > > >>>> for a while, but other stuff continues to require attention. I'm also 
> > > >>>> of the opinion that we should switch to ticket spinlocks. 
> > > >>> 
> > > >>> Would queuing spinlocks (e.g. MCS locks) be even more preferable? Two atomic 
> > > >>> ops (cmpxchg) per critical region in the uncontended case. Each CPU spins on 
> > > >>> its own location so there's no cacheline carnage in the highly contended 
> > > >>> case (a problem with simple ticket spinlocks). And it builds on cmpxchg so 
> > > >>> the spinlock implementation has no arch-specific component (apart from 
> > > >>> cmpxchg, which we already have). 
> > > >>> 
> > > >>> I have a queue-based rwlock design too, does require a spinlock lock/unlock 
> > > >>> per rwlock op though (i.e., 4 atomic ops per critical region in the 
> > > >>> uncontended case). 
> > > >> 
> > > >> Actually MCS has a multi-reader extension we could use, or there is another 
> > > >> alternative by Krieger et al. My own design was intended to build on pthread 
> > > >> primitives and wouldn't be as good as the existing solutions in the 
> > > >> literature for purely spinning waiters. 
> > > > 
> > > > Sounds nice - are you going to spend time on implementing this then? 
> > > 
> > > Yes I'll look into it. Amazon's benchmarking of grant-table throughput will 
> > > be a good testbed for performance of a different lock implementation. 
> > 
> > ping? 
>
> Ooph. Sorry, I've not had any time to work on this since posting last 
> year. Has there been any other discussion about a new locking 
> primitive? 
>

My recollection from this thread is that we are waiting for Keir for MCS + multireader extension patches.

Especially as I was reviewing the proposed qspinlocks (MCS variant for Linux) and everything is fresh in my mind.

> Konrad, are you looking for someone to rebase and break up the 
> proposed patch as is? 
>
> --msw 
>
> _______________________________________________ 
> Xen-devel mailing list 
> Xen-devel@lists.xen.org 
> http://lists.xen.org/xen-devel 

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-06-21  0:14 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-12  2:03 [RFC PATCH 0/2] gnttab: refactor locking for better scalability Matt Wilson
2013-11-12  2:03 ` [RFC PATCH 1/2] gnttab: lock the local grant table earlier in __gnttab_unmap_common() Matt Wilson
2013-11-12  2:03 ` [RFC PATCH 2/2] gnttab: refactor locking for better scalability Matt Wilson
2013-11-12  5:37   ` Keir Fraser
2013-11-12  7:18     ` Matt Wilson
2013-11-12  8:07       ` Keir Fraser
2013-11-12  9:18         ` Jan Beulich
2013-11-12 13:42           ` Keir Fraser
2013-11-12 13:58             ` Keir Fraser
2013-11-12 14:11               ` Jan Beulich
2013-11-12 14:24                 ` Keir Fraser
2013-11-12 15:09                   ` Felipe Franciosi
2014-06-20 20:54                   ` Konrad Rzeszutek Wilk
2014-06-20 21:18                     ` Matt Wilson
2013-11-12 19:06         ` Matt Wilson
2013-11-12 14:52       ` Konrad Rzeszutek Wilk
2013-11-12 15:04         ` David Vrabel
2013-11-12 16:53           ` Anthony Liguori
2013-11-12  9:26   ` Jan Beulich
2013-11-12 17:58     ` Matt Wilson
2013-11-13  7:39       ` Jan Beulich
  -- strict thread matches above, loose matches on Subject: below --
2014-06-21  0:13 Konrad Rzeszutek Wilk

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).