From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keir Fraser Subject: Re: [RFC PATCH 2/2] gnttab: refactor locking for better scalability Date: Tue, 12 Nov 2013 13:58:24 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VgEUF-0003MY-HJ for xen-devel@lists.xenproject.org; Tue, 12 Nov 2013 13:58:35 +0000 Received: by mail-wi0-f177.google.com with SMTP id hq4so3319794wib.16 for ; Tue, 12 Nov 2013 05:58:33 -0800 (PST) In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , Matt Wilson Cc: Felipe Franciosi , Anthony Liguori , Andrew Cooper , David Vrabel , Matt Wilson , xen-devel@lists.xenproject.org, roger.pau@citrix.com List-Id: xen-devel@lists.xenproject.org On 12/11/2013 13:42, "Keir Fraser" 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. -- Keir