From: Arnd Bergmann <arnd@arndb.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Eli Billauer <eli@billauer.co.il>, linux-kernel@vger.kernel.org
Subject: Re: open() on /dev/tty takes 30 seconds on 2.6.36
Date: Sat, 30 Oct 2010 22:46:56 +0200 [thread overview]
Message-ID: <201010302246.56539.arnd@arndb.de> (raw)
In-Reply-To: <20101030114634.b19c4e0c.akpm@linux-foundation.org>
On Saturday 30 October 2010, Andrew Morton wrote:
> > static int ptmx_open(struct inode *inode, struct file *filp)
> > {
> > struct tty_struct *tty;
> > int retval;
> > int index;
> >
> > nonseekable_open(inode, filp);
> >
> > /* find a device that is not in use. */
> > printk(KERN_ALERT "34: ptmx_open to lock\n");
> > tty_lock();
> > printk(KERN_ALERT "35: ptmx_open locked\n");
> >
> > [snipped here]
> >
> > And then found in my /var/log/messages (no log lines between these two):
> > Oct 29 16:14:58 ocho kernel: 34: ptmx_open to lock
> > Oct 29 16:15:13 ocho kernel: 35: ptmx_open locked
> >
> > So we can see it took 15 seconds to acquire a lock in this case. In all
> > other pairs of lock messages there was no time difference. To me it
> > looks like 15 seconds in order to acquire a lock in the kernel is a
> > smoking gun.
Agreed. When I changed the locking to use a mutex instead of the BKL,
I intentionally left it locked across sleeping functions, but none of
them are supposed to sleep for multiple seconds.
>
> Odd. Presumably someone else was holding big_tty_mutex for 15 seconds.
>
> We can find out who, with the sysrq-d command if you have the time
> please. You'll need to enable lockdep and magic sysrq in .config.
> Then run `dmesg -n 8' so all messages get printed by the kernel and
> then, in the middle of that 15-second delay, do
>
> echo d > /proc/sysrq-trigger
>
> I'll confess that I've never used sysrq-d and am unsure what the output
> looks like. Fingers crossed!
With a little luck, lockdep by itself might even be able to find an
inconsistency in the BTM use and warn right away about it. I found
a number of bugs in the TTY code just by running with lockdep in the
mutex version.
Arnd
next prev parent reply other threads:[~2010-10-30 20:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-30 7:47 Eli Billauer
2010-10-30 18:46 ` Andrew Morton
2010-10-30 20:46 ` Arnd Bergmann [this message]
2010-10-31 0:20 ` Eli Billauer
2010-10-31 3:36 ` Arnd Bergmann
2010-10-31 6:34 ` James Cloos
2010-10-31 11:36 ` Arnd Bergmann
2010-11-02 10:28 ` Tejun Heo
2010-11-01 1:12 ` Eli Billauer
2010-11-01 19:39 ` Arnd Bergmann
2010-11-01 20:46 ` Alan Cox
2010-11-03 0:15 ` Eli Billauer
2010-11-03 3:32 ` Arnd Bergmann
2010-11-03 10:34 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201010302246.56539.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=eli@billauer.co.il \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome