On Fri, 7 Jul 2017 09:54:13 +0200 Paolo Bonzini <pbonzini@xxxxxxxxxx> 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