Re: [lockdep] b09be676e0 BUG: unable to handle kernel NULL pointer dereference at 000001f2

From: Byungchul Park
Date: Tue Oct 10 2017 - 22:36:43 EST


On Tue, Oct 10, 2017 at 09:56:26AM -0700, Linus Torvalds wrote:
> On Tue, Oct 10, 2017 at 9:22 AM, Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > I really would like to see the sites that do cross-thread lock/unlock
> > pairs themselves be annotated.
> >
> > So when you lock in one thread, and then unlock in another, I'd
> > actually prefer to see something like
> >
> > - T1:
> > lock_mutex_cross();
> >
> > - T2:
> > unlock_mutex_cross();
> >
> > to make it very explicit that *these* particular lock/unlock
> > operations are the fancy ones.
>
> Actually, let's make it even *more* obvious, and even easier for
> lockdep (and for humans) to see what's going on.
>
> So I think the best model would be something like this:
>
> - T1:
> mutex_lock(&lock)
> ...
> mutex_transfer(&lock)
>
> - T2:
> mutex_receive(&lock);
> ...
> mutex_unlock(&lock);

In addition, if we really need to use mutex locks in this way, I also
think it should work with the explicit primitives as you said.