Re: [RFC][PATCH] Fix hang in posix_locks_deadlock()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: George G. Davis <gdavis@...>
Cc: <linux-kernel@...>
Date: Friday, October 26, 2007 - 6:47 pm

On Fri, Oct 26, 2007 at 01:07:50PM -0400, bfields wrote:

Hm.  After another look: assume we have four tasks, t1, t2, t3, and t4.
Assume t1 and t2 share the same current->files (so they're the same
"owner" for the purpose of posix_same_owner()).  Assume:

	t1 is waiting on a conflicting lock held by t3.
	t2 is waiting on a conflicting lock held by t4.

Now suppose t4 requests a lock that conflicts with a lock held by t1 and
t2.  The list_for_each_entry() above will search for a task with t1 or
t2 as owner, which is waiting on a lock.  If it finds t1 first, the loop
won't be noticed, so t4 will be put to sleep.  Now we have a loop; t3
can release its lock (it no longer matters), and we'll have

	t2 waiting on a conflicting lock held by t4, and
	t4 waiting on a conflicting lock held by t2.

If a new task t5 then requests a lock conflicting with the one held by
t2, then the above function will go into an infinite loop.  I think.

Consider the directed graph with each vertex representing the set of all
tasks sharing the same file table, and each edge representing the
relationship "a task at this vertex is waiting on a lock held by a task
on another vertex".  The existance of multiple tasks with the same file
table means that we can no longer assume that each vertex has outdegree
at most one, so we have to switch to an algorithm that works on an
arbitrary directed graph.  That sounds painful.

Am I right about that, and about the example above?  It'd be interesting
to code it up just to make sure.

If so, one can imagine various bandaids, but maybe we should just rip
out the deadlock detection completely.... It's hard to imagine it being
really useful anyway.

--b.
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH] Fix hang in posix_locks_deadlock(), George G. Davis, (Wed Oct 17, 2:51 pm)
Re: [RFC][PATCH] Fix hang in posix_locks_deadlock(), George G. Davis, (Thu Oct 18, 2:57 pm)
Re: [RFC][PATCH] Fix hang in posix_locks_deadlock(), J. Bruce Fields, (Fri Oct 26, 1:07 pm)
Re: [RFC][PATCH] Fix hang in posix_locks_deadlock(), George G. Davis, (Fri Nov 2, 11:05 am)
Re: [RFC][PATCH] Fix hang in posix_locks_deadlock(), J. Bruce Fields, (Fri Oct 26, 6:47 pm)
Re: [RFC][PATCH] Fix hang in posix_locks_deadlock(), J. Bruce Fields, (Sun Oct 28, 1:47 pm)
[RFC, PATCH] locks: remove posix deadlock detection, J. Bruce Fields, (Sun Oct 28, 1:43 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, J. Bruce Fields, (Tue Oct 30, 11:51 am)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Matthew Wilcox, (Sun Oct 28, 2:27 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, J. Bruce Fields, (Sun Oct 28, 9:13 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Matthew Wilcox, (Sun Oct 28, 4:11 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Trond Myklebust, (Sun Oct 28, 5:50 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Matthew Wilcox, (Sun Oct 28, 6:41 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Trond Myklebust, (Sun Oct 28, 11:26 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, J. Bruce Fields, (Sun Oct 28, 10:10 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Matthew Wilcox, (Sun Oct 28, 7:31 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Matthew Wilcox, (Sun Oct 28, 6:55 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, J. Bruce Fields, (Sun Oct 28, 10:29 pm)
Re: [RFC, PATCH] locks: remove posix deadlock detection, J. Bruce Fields, (Tue Oct 30, 11:35 am)
Re: [RFC, PATCH] locks: remove posix deadlock detection, Matthew Wilcox, (Sun Oct 28, 7:38 pm)
Re: [RFC][PATCH] Fix hang in posix_locks_deadlock(), George G. Davis, (Wed Oct 17, 7:41 pm)