From: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Dmitry Vyukov <dvyukov@google.com>,
Ingo Molnar <mingo@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>, LKML <linux-kernel@vger.kernel.org>,
J Freyensee <james_p_freyensee@linux.intel.com>,
syzkaller <syzkaller@googlegroups.com>,
Kostya Serebryany <kcc@google.com>,
Alexander Potapenko <glider@google.com>,
Sasha Levin <sasha.levin@oracle.com>,
Eric Dumazet <edumazet@google.com>
Subject: Re: tty: deadlock between n_tracerouter_receivebuf and flush_to_ldisc
Date: Wed, 20 Jan 2016 14:58:43 +0000 [thread overview]
Message-ID: <20160120145843.4a51359e@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <20160120120752.GQ3421@worktop>
> I read that, I didn't understand it. Which link is wrong and why?
>
> > And I don't understand how the following is a deadlock, since there is
> > no cycle...
> >
> > Possible unsafe locking scenario:
> > CPU0 CPU1
> > ---- ----
> > lock(&buf->lock);
> > lock(&o_tty->termios_rwsem/1);
> > lock(&buf->lock);
> > lock(routelock);
>
> Ignore the stupid picture, it only really works for simple cases.
There are two line disciplines using two different locking orders
The two line disciplines never execute at once. A given tty is either
using one or the other and there is a clear and correctly locked
changeover.
semantically its something a bit like
foo(x)
{
if (x == 1) {
lock(A)
lock(B)
} else {
lock(B)
lock(A)
}
Do stuff();
if (x == 1) {
unlock(B)
unlock(A)
} else {
unlock(A)
unlock(B)
}
}
with the guarantee made elsewhere that no instances of foo(1) and foo(0)
are ever executing at the same time.
That's not by dumb design - it's an interesting "nobody ever noticed
this" turned up by the lock detector between two totaly unrelated bits of
code.
Alan
next prev parent reply other threads:[~2016-01-20 14:59 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-30 10:44 Dmitry Vyukov
2016-01-15 7:51 ` Dmitry Vyukov
2016-01-15 16:33 ` One Thousand Gnomes
2016-01-15 17:22 ` Dmitry Vyukov
2016-01-20 9:36 ` Dmitry Vyukov
2016-01-20 11:44 ` Peter Zijlstra
2016-01-20 11:54 ` Dmitry Vyukov
2016-01-20 12:07 ` Peter Zijlstra
2016-01-20 14:58 ` One Thousand Gnomes [this message]
2016-01-20 15:16 ` Dmitry Vyukov
2016-01-20 16:32 ` Peter Zijlstra
2016-01-20 2:09 ` J Freyensee
2016-01-20 12:47 ` Jiri Slaby
2016-01-20 13:02 ` Peter Zijlstra
2016-01-20 13:07 ` Dmitry Vyukov
2016-01-20 16:08 ` Peter Hurley
2016-01-20 20:47 ` Peter Hurley
2016-01-21 10:06 ` Dmitry Vyukov
2016-01-21 10:20 ` Peter Zijlstra
2016-01-21 17:51 ` Peter Hurley
2016-01-22 14:10 ` Dmitry Vyukov
2016-01-25 16:56 ` Peter Hurley
2016-01-21 17:43 ` Peter Hurley
2016-02-03 4:24 ` Peter Hurley
2016-02-03 17:32 ` Dmitry Vyukov
2016-02-03 19:09 ` Peter Hurley
2016-02-04 12:39 ` Dmitry Vyukov
2016-02-04 13:17 ` Dmitry Vyukov
2016-02-04 18:46 ` Peter Hurley
2016-02-04 18:48 ` Dmitry Vyukov
2016-02-05 21:22 ` Dmitry Vyukov
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=20160120145843.4a51359e@lxorguk.ukuu.org.uk \
--to=gnomes@lxorguk.ukuu.org.uk \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=glider@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=james_p_freyensee@linux.intel.com \
--cc=jslaby@suse.com \
--cc=kcc@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sasha.levin@oracle.com \
--cc=syzkaller@googlegroups.com \
/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