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 05:37:08 +0000 Message-ID: References: <1384221792-3456-3-git-send-email-msw@linux.com> 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 1Vg6f9-0005jb-My for xen-devel@lists.xenproject.org; Tue, 12 Nov 2013 05:37:19 +0000 Received: by mail-we0-f172.google.com with SMTP id q58so5581812wes.3 for ; Mon, 11 Nov 2013 21:37:17 -0800 (PST) In-Reply-To: <1384221792-3456-3-git-send-email-msw@linux.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Matt Wilson , xen-devel@lists.xenproject.org Cc: Felipe Franciosi , Anthony Liguori , Andrew Cooper , David Vrabel , Jan Beulich , Matt Wilson , Roger Pau =?ISO-8859-1?B?TW9ubuk=?= List-Id: xen-devel@lists.xenproject.org On 12/11/2013 02:03, "Matt Wilson" wrote: > + Locking > + ~~~~~~~ > + Xen uses several locks to serialize access to the internal grant table > state. > + > + grant_table->lock : rwlock used to prevent readers from accessing > + inconsistent grant table state such as current > + version, partially initialized active table > pages, > + etc. > + grant_table->maptrack_lock : spinlock used to protect the maptrack state > + active_grant_entry->lock : spinlock used to serialize modifications to > + active entries > + > + The primary lock for the grant table is a read/write spinlock. All > + functions that access members of struct grant_table must acquire a > + read lock around critical sections. Any modification to the members > + of struct grant_table (e.g., nr_status_frames, nr_grant_frames, > + active frames, etc.) must only be made if the write lock is > + held. These elements are read-mostly, and read critical sections can > + be large, which makes a rwlock a good choice. 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. Looks like great work however! -- Keir