Re: [GIT PATCH] TTY patches for 2.6.33-git

From: Linus Torvalds
Date: Sat Dec 12 2009 - 20:15:49 EST




On Sat, 12 Dec 2009, Linus Torvalds wrote:
> >
> > I'm surprised that lockdep didn't notice that ab/ba I thought I saw.
> > Maybe the do_tty_hangup()->tty_fasync() never happens.
>
> The kernel lock cannot have any ABBA deadlocks.
>
> If somebody blocks on another lock (after getting the kernel lock), the
> kernel lock will be dropped. So no ABBA.

Oh, but it turns out that while there cannot be any ABBA deadlocks with
sleeping locks, what the tty code does is invalid for _another_ reason:
file_list_lock() is a spinlock. And that's a no-no.

You cannot take the kernel lock inside a spinlock. Ordering doesn't
matter, there's no ABBA issues - it's simply invalid _regardless_ of any
other use of that lock.

I think we could possibly add a "__might_sleep()" to _lock_kernel(). It
doesn't really sleep, but it's invalid to take the kernel lock in an
atomic region, so __might_sleep() might be the right thing anyway.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/