From: "Jan Beulich" Subject: Re: [RFC PATCH 2/2] gnttab: refactor locking for better scalability Date: Tue, 12 Nov 2013 09:18:35 +0000 Message-ID: <5282007B02000078001023D6@nat28.tlf.novell.com> References: <20131112071857.GA11872@u109add4315675089e695.ant.amazon.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VgA7N-0002V8-Ib for xen-devel@lists.xenproject.org; Tue, 12 Nov 2013 09:18:41 +0000 In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Keir Fraser , 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.13 at 09:07, Keir Fraser wrote: > On 12/11/2013 07:18, "Matt Wilson" wrote: > >>> Is there any concern about writer starvation here? I know our spinlocks >>> aren't 'fair' but our rwlocks are guaranteed to starve out writers if there >>> is a steady continuous stream of readers. Perhaps we should write-bias our >>> rwlock, or at least make that an option. We could get fancier but would >>> probably hurt performance. >> >> Yes, I'm a little concerned about writer starvation. But so far even >> in the presence of very frequent readers it seems like the infrequent >> writers are able to get the lock when they need to. However, I've not >> tested the iommu=strict path yet. I'm thinking that in that case >> there's just going to be frequent writers, so there's less risk of >> readers starving writers. For what it's worth, when mapcount() gets in >> the picture with persistent grants, I'd expect to see some pretty >> significant performance degradation for map/unmap operations. This was >> also observed in [1] under different circumstances. > > The average case isn't the only concern here, but also the worst case, which > could maybe tie up a CPU for unbounded time. Could a malicious guest set up > such a workload? I'm just thinking we don't want to end up with a DoS XSA on > this down the line. :) 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. But of course, fairness for writers means that performance may drop again on the read paths, unless the write lock use is strictly limited to code paths not (normally) involved in I/O. Jan