Re: possible deadlock in mon_bin_vma_fault

From: Alan Stern
Date: Wed Nov 20 2019 - 13:18:10 EST


On Wed, 20 Nov 2019, Pete Zaitcev wrote:

> On Wed, 20 Nov 2019 11:14:05 -0500 (EST)
> Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>
> > As it happens, I spent a little time investigating this bug report just
> > yesterday. It seems to me that the easiest fix would be to disallow
> > resizing the buffer while it is mapped by any users. (Besides,
> > allowing that seems like a bad idea in any case.)
> >
> > Pete, does that seem reasonable to you?
>
> Actually, please hold on a little, I think to think more about this.
> The deadlock is between mon_bin_read and mon_bin_vma_fault.
> To disallow resizing isn't going to fix _that_.

As I understand it (and my understanding is pretty limited, since I
only started to look seriously at the code one day ago), the reason why
mon_bin_vma_fault acquires fetch_lock is to prevent a resize from
happening while the fault is being handled. Is there another reason?

If you disallow resizing while the buffer is mapped then
mon_bin_vma_fault won't need to hold fetch_lock at all. That would fix
the deadlock, right?

Alan Stern