Re: [PATCH] dax/bus.c: replace WARN_ON_ONCE() with lockdep asserts

From: Verma, Vishal L
Date: Thu Apr 04 2024 - 17:33:15 EST


On Thu, 2024-04-04 at 14:23 -0700, Andrew Morton wrote:
> On Tue, 02 Apr 2024 00:24:28 -0600 Vishal Verma <vishal.l.verma@xxxxxxxxx> wrote:
>
> > In [1], Dan points out that all of the WARN_ON_ONCE() usage in the
> > referenced patch should be replaced with lockdep_assert_held(_write)().
> >
> > Replace those, and additionally, replace a couple of other
> > WARN_ON_ONCE() introduced in the same patch for actual failure
> > cases (i.e. when acquiring a semaphore fails in a remove / unregister
> > path) with dev_WARN_ONCE() as is the precedent here.
> >
> > Recall that previously, unregistration paths was implicitly protected by
> > overloading the device lock, which the patch in [1] sought to remove.
> > This meant adding a semaphore acquisition in these unregistration paths.
> > Since that can fail, and it doesn't make sense to return errors from
> > these paths, retain the two instances of (now) dev_WARN_ONCE().
> >
> > ...
> >
> > @@ -471,6 +471,7 @@ static void __unregister_dev_dax(void *dev)
> >  
> >   dev_dbg(dev, "%s\n", __func__);
> >  
> > + lockdep_assert_held_write(&dax_region_rwsem);
> >   kill_dev_dax(dev_dax);
> >   device_del(dev);
> >   free_dev_dax_ranges(dev_dax);
>
> This is new and unchangelogged?
>
> I'm taking Dan's reply to your patch as Not-A-Nack ;)
>
True, but with Dan's new feedback, that results in a bit more rework,
this will likely turn into 2-3 patches. Working on it now, will be out
shortly!