On Fri, Nov 29, 2019 at 8:33 AM Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> wrote: > > On Fri, 29 Nov 2019 14:24:48 +0000 > Steven Price <steven.price@xxxxxxx> wrote: > > > On 29/11/2019 13:59, Boris Brezillon wrote: > > > If 2 threads change the MADVISE property of the same BO in parallel we > > > might end up with an shmem->madv value that's inconsistent with the > > > presence of the BO in the shrinker list. > > > > I'm a bit worried from the point of view of user space sanity that you > > observed this - but clearly the kernel should be robust! > > It's not something I observed, just found the race by inspecting the > code, and I thought it was worth fixing it. I'm not so sure there's a race. If there is, we still check madv value when purging, so it would be harmless even if the state is inconsistent. > > > The easiest solution to fix that is to protect the > > > drm_gem_shmem_madvise() call with the shrinker lock. > > > > > > Fixes: 013b65101315 ("drm/panfrost: Add madvise and shrinker support") > > > Cc: <stable@xxxxxxxxxxxxxxx> > > > Signed-off-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> > > > > Reviewed-by: Steven Price <steven.price@xxxxxxx> > > Thanks. > > > > > > --- > > > drivers/gpu/drm/panfrost/panfrost_drv.c | 9 ++++----- > > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c > > > index f21bc8a7ee3a..efc0a24d1f4c 100644 > > > --- a/drivers/gpu/drm/panfrost/panfrost_drv.c > > > +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c > > > @@ -347,20 +347,19 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data, > > > return -ENOENT; > > > } > > > > > > + mutex_lock(&pfdev->shrinker_lock); > > > args->retained = drm_gem_shmem_madvise(gem_obj, args->madv); This means we now hold the shrinker_lock while we take the pages_lock. Is lockdep happy with this change? I suspect not given all the fun I had getting lockdep happy. Rob _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel