From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeremy Fitzhardinge Subject: Re: [PATCH] gntdev: switch back to rwlocks Date: Fri, 09 Jul 2010 10:57:17 -0700 Message-ID: <4C3762FD.8050108@goop.org> References: <4C375376020000780000A827@vpn.id2.novell.com> <4C3762C4020000780000A8A1@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4C3762C4020000780000A8A1@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: "xen-devel@lists.xensource.com" , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On 07/09/2010 08:56 AM, Jan Beulich wrote: >>> Shouldn't this be solved in a way not depending on an implementation >>> detail (rw-locks being unfair in that readers can lock out writers >>> indefinitely)? Is it even certain that all arch-es implement rw-locks >>> in a manner compatible with this? >>> >> any rwlock implementations that allow multiple readers will do: both >> mn_invl_range_start and gntdev_mmap only require a read lock. >> > No - if an implementation forces further readers to spin once a > writer started its attempt to acquire a lock, the code after your > change still has the potential to deadlock afaict. > Yes, relying on this kind of behaviour from rwlocks doesn't pass the smell test. rwlocks are just a performance optimisation for particular locking patterns; it should always be safe to implement them as plain spinlocks (or convert them into spinlocks). I think removing the notifier calls from apply_to_page_range fixes the root of the problem. J