From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: possible recursive locking issue Date: Fri, 7 Jul 2017 09:50:44 -0600 Message-ID: <20170707095044.25dd239a@w520.home> References: <17296D9F8FF2234F831FC3DF505A87A9632A2EC7@SHSMSX103.ccr.corp.intel.com> <20170706151005.41085524@w520.home> <02294617-08c8-5a32-8fb1-9a8ef95ea2c3@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "Dong, Chuanxiao" , "kwankhede@nvidia.com" , "kvm@vger.kernel.org" , 'Zhenyu Wang' To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51726 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751828AbdGGPuu (ORCPT ); Fri, 7 Jul 2017 11:50:50 -0400 In-Reply-To: <02294617-08c8-5a32-8fb1-9a8ef95ea2c3@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 7 Jul 2017 09:54:13 +0200 Paolo Bonzini wrote: > On 06/07/2017 23:10, Alex Williamson wrote: > > vfio_unpin_pages() also takes a read-lock on > > the same. Why is this a problem? We should be able to nest > > read-locks. > > rwsem is fair in that it blocks out new readers if a writer is waiting. > In this case nesting causes a deadlock, because the outer read-lock will > never be released. Ok, that certainly explains the potential deadlock. The _nested variants Chuanxiao suggests only seems to potentially silence lockdep, they don't change the non-debug versions afaict. An ideal solution would be to determine that we don't really need that lock in the unpin path, otherwise an ugly (but straight forward) solution might be to make unlocked variants of those call. More investigation of exactly what we're locking and why is required. Thanks, Alex