From: "J. Bruce Fields" <bfields@fieldses.org>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org,
"George G. Davis" <gdavis@mvista.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-fsdevel@vger.kernel.org
Subject: Re: [RFC, PATCH] locks: remove posix deadlock detection
Date: Sun, 28 Oct 2007 22:10:36 -0400 [thread overview]
Message-ID: <20071029021036.GC10307@fieldses.org> (raw)
In-Reply-To: <20071028224157.GC32359@parisc-linux.org>
On Sun, Oct 28, 2007 at 04:41:57PM -0600, Matthew Wilcox wrote:
> On Sun, Oct 28, 2007 at 05:50:30PM -0400, Trond Myklebust wrote:
> > > You can't fix the false EDEADLK detection without solving the halting
> > > problem. Best of luck with that.
> >
> > I can see that it would be difficult to do efficiently, but basically,
> > this boils down to finding a circular path in a graph. That is hardly an
> > unsolvable issue...
>
> Bzzt. You get a false deadlock with multiple threads like so:
>
> Thread A of task B takes lock 1
> Thread C of task D takes lock 2
> Thread C of task D blocks on lock 1
> Thread E of task B blocks on lock 2
Oh neat, I missed that case, thanks for pointing it out.
> We currently declare deadlock at this point (unless the deadlock detection
> code has changed since I last looked at it), despite thread A being about
> to release lock 1. Oh, and by the way, thread E is capable of releasing
> lock 1, so you can't just say "well, detect by thread instead of by task".
>
> So the only way I can see to accurately detect deadlock is to simulate
> the future execution of all threads in task B to see if any of them
> will release lock 1 without first gaining lock 2.
Hm. It's annoying, but I'm not convinced it's *that* annoying. We're
not trying to predict whether a deadlock could arise as the result of
future behavior. We're just trying to determine whether granting the
current lock request results in an immediate deadlock consisting purely
of posix file locks.
But yes, I'm assume it's possible, for example, that a thread-exit could
race with a lock request, with the result that we see no deadlock at the
time we handle the lock request, even though at that point the last task
with the ability to solve the problem is already exiting.
Supposing that we're willing to permit the request in such cases and
return EDEADLK only in cases where we're positive there's a deadlock, is
there still some useful subset of cases where we could return EDEADLK?
For example, could we take note of tasks that, when they block on a
lock, have a current->files with reference count one, and only follow
cycles consisting of such blocks?
I'm still not convinced it's worth the trouble, but I suspect you're
overstating the difficulty.
--b.
next prev parent reply other threads:[~2007-10-29 2:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20071017185157.GC3785@mvista.com>
[not found] ` <20071018185759.GU3785@mvista.com>
[not found] ` <20071026170750.GC13033@fieldses.org>
[not found] ` <20071026224707.GO13033@fieldses.org>
2007-10-28 17:31 ` [PATCH] locks: fix possible infinite loop in posix deadlock detection J. Bruce Fields
2007-10-28 17:43 ` [RFC, PATCH] locks: remove " J. Bruce Fields
2007-10-28 18:27 ` Matthew Wilcox
2007-10-28 18:40 ` Alan Cox
2007-10-28 20:11 ` Matthew Wilcox
2007-10-28 21:38 ` Alan Cox
2007-10-28 21:45 ` Jiri Kosina
2007-10-28 23:38 ` Matthew Wilcox
2007-10-28 23:44 ` Alan Cox
2007-10-28 21:50 ` Trond Myklebust
2007-10-28 22:41 ` Matthew Wilcox
2007-10-28 22:48 ` Alan Cox
2007-10-28 22:55 ` Matthew Wilcox
2007-10-28 23:38 ` Alan Cox
2007-10-29 2:29 ` J. Bruce Fields
2007-10-29 8:08 ` Alan Cox
2007-10-29 9:15 ` Jiri Kosina
2007-10-30 15:35 ` J. Bruce Fields
2007-10-28 22:55 ` Jiri Kosina
2007-10-28 23:31 ` Matthew Wilcox
2007-10-29 9:11 ` Jiri Kosina
2007-10-29 2:10 ` J. Bruce Fields [this message]
2007-10-29 3:26 ` Trond Myklebust
2007-10-29 1:13 ` J. Bruce Fields
2007-10-29 8:06 ` Alan Cox
2007-10-30 15:51 ` J. Bruce Fields
2007-10-30 15:20 ` [PATCH, RESEND] locks: fix possible infinite loop in " J. Bruce Fields
2007-10-30 15:35 ` 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=20071029021036.GC10307@fieldses.org \
--to=bfields@fieldses.org \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=gdavis@mvista.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=torvalds@linux-foundation.org \
--cc=trond.myklebust@fys.uio.no \
/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;
as well as URLs for NNTP newsgroup(s).