Re: [PATCH] tty: add lockdep annotations
From: Linus Torvalds
Date: Sat Jun 02 2012 - 21:38:49 EST
On Sat, Jun 2, 2012 at 3:25 PM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hmm. Ok. Looking at it, the ".shutdown" and ".remove" functions are
> all very limited, so I suspect we could just make the rule be that the
> install/lookup functions are serialized against each other by the
> pty_mutex (true today), and then we just add a small spinlock for the
> actual driver array insert/lookup.
Actually, I think we could probably make it really trivial by forcing
the free'ing of the tty itself to be RCU-delayed.
Then shutdown/remove would remove the entry with no locking
what-so-ever (which is really nice if you're in an interrupt - because
now *other* users don't need to use those annoying irq-safe versions),
and simply just clear the ttys[] array index.
The lookup side would need to just do a RCU read lock, read the
->ttys[index] thing using ACCESS_ONCE, and then just do the
atomic_inc_not_zero() dance I already did to validate that the thing
is still alive.
Voila - very cheap locking, and the part that could possibly happen
from interrupts (shutdown/remove) needs no locking at all.
Making the tty freeing be rcu-delayed sounds pretty dang simple too.
What do you think?
Anyway, I'm closing the merge window now (doing the tagging, booting
and checking that allmodconfig/allyesconfig/allnoconfigs all compile
fine) so it's 3.6 material, but it doesn't sound bad.
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/