On Tue, 26 May 2020 12:53:31 -0300 Jason Gunthorpe <jgg@xxxxxxxx> wrote: > On Tue, May 26, 2020 at 08:32:18AM -0600, Alex Williamson wrote: > > > > Certainly there is no reason to optimize the fringe case of vfio > > > > sleeping if there is and incorrect concurrnent attempt to disable the > > > > a BAR. > > > > > > If fixup_user_fault() (which is always with ALLOW_RETRY && !RETRY_NOWAIT) is > > > the only path for the new fault(), then current way seems ok. Not sure whether > > > this would worth a WARN_ON_ONCE(RETRY_NOWAIT) in the fault() to be clear of > > > that fact. > > > > Thanks for the discussion over the weekend folks. Peter, I take it > > you'd be satisfied if this patch were updated as: > > > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > > index aabba6439a5b..35bd7cd4e268 100644 > > +++ b/drivers/vfio/pci/vfio_pci.c > > @@ -1528,6 +1528,13 @@ static vm_fault_t vfio_pci_mmap_fault(struct vm_fault *vmf) > > struct vfio_pci_device *vdev = vma->vm_private_data; > > vm_fault_t ret = VM_FAULT_NOPAGE; > > > > + /* > > + * We don't expect to be called with NOWAIT and there are conflicting > > + * opinions on whether NOWAIT suggests we shouldn't wait for locks or > > + * just shouldn't wait for I/O. > > + */ > > + WARN_ON_ONCE(vmf->flags & FAULT_FLAG_RETRY_NOWAIT); > > I don't think this is right, this implies there is some reason this > code fails with FAULT_FLAG_RETRY_NOWAIT - but it is fine as written, > AFAICT Ok, Peter said he's fine either way, I'll use the patch as originally posted and include Peter's R-b. Thanks, Alex