lkml.org 
[lkml]   [2012]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] tty: add lockdep annotations
On Sat, Jun 2, 2012 at 11:38 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> I'm pretty sure this is the bug. And there's no way we can make
> 'tty_mutex' protect every tty_kref_put(). So I think we have two
> options:
>
>  - revert all the tty locking changes
>
>  - make a new global lock that protects just driver->ops->lookup(),
> driver->ttys[idx], and driver->ops->remove()
>
> Hmm?

Ok, here's the second option. THIS PATCH IS TOTALLY UNTESTED!

Basic concepts:

- the tty driver lookup is protected with "tty_lookup_mutex",
similarly to how the "current task mutex" is protected by the signal
lock.

- At lookup, we now always increment the kref (which in the case of
tty_open_current_tty() means that we do *not* drop the kref), and in
the case of a tty driver lookup, we use "atomic_inc_not_zero()" to
make sure that we get a tty that is not on its way out.

I *think* this makes sense. But it has has had absolutely zero
testing. It compiles in my config, and the locking is at least
sensible and well-localized, but maybe I'm missing something.

Comments?

Linus
[unhandled content-type:application/octet-stream]
\
 
 \ /
  Last update: 2012-06-02 22:41    [W:0.225 / U:0.788 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site