linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fw: Spam: [Bugme-new] [Bug 2829] New: posix_locks_deadlock() loops infinitely
@ 2004-06-04  5:50 Andrew Morton
  2004-06-04  5:53 ` Andrew Morton
  2004-06-04 11:20 ` Fw: Spam: [Bugme-new] " Matthew Wilcox
  0 siblings, 2 replies; 12+ messages in thread
From: Andrew Morton @ 2004-06-04  5:50 UTC (permalink / raw)
  To: linux-fsdevel



Begin forwarded message:

Date: Thu, 3 Jun 2004 22:45:56 -0700
From: bugme-daemon@osdl.org
To: bugme-new@lists.osdl.org
Subject: Spam: [Bugme-new] [Bug 2829] New: posix_locks_deadlock() loops infinitely


http://bugme.osdl.org/show_bug.cgi?id=2829

           Summary: posix_locks_deadlock() loops infinitely
    Kernel Version: 2.6.6
            Status: NEW
          Severity: normal
             Owner: fs_vfs@kernel-bugs.osdl.org
         Submitter: i-sakamoto@pb.jp.nec.com


Distribution: debian
Hardware Environment:
Software Environment:
Problem Description: Using POSIX threads makes posix_locks_deadlock() loop
infinitely.

Steps to reproduce:

There are 3 processes; "A", "B" and "C".
Each process opens "file1", "file2" and "file3".

"A" creates 3 POSIX threads; "A1", "A2" and "A3". (These threads' PIDs are the
same.)
"B" creates 2 POSIX threads; "B1" and "B2". (These threads' PIDs are the same.)
"C" creates 1 POSIX thread; "C1".


1. "A1" locks "file1" exclusively.
2. "B1" locks "file2" exclusively.
3. "C1" locks "file3" exclusively.
4. "A2" trys to lock "file2" and sleeps (blocked by "B1").
5. "A3" trys to lock "file3" and sleeps (blocked by "C1").
6. "B2" trys to lock "file1".
   Here, posix_locks_deadlock() must detect deadlock, but
   it does not. Then "B2" sleeps (blocked "A1").

  "A"                                    "B"
   |                                      |
   +--A1(LOCK)---->(file1)<-B2(*deadlock)-+
   |                                      |
   |                                      |
   +--A2(BLOCK)--->(file2)<---B1(LOCK)----+
   |
   |
   +--A3(BLOCK)--->(file3)<---C1(LOCK)----"C"

    block_list -> A3(BLOCK) -> A2(BLOCK)


7. "C1" unlocks "file3". ("A3" wakes up and locks "file3".)
8. "A3" unlocks "file3".
9. Another process locks "file1".
   This makes posix_locks_deadlock() loop infinitely.

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Fw: Spam: [Bugme-new] [Bug 2829] New: posix_locks_deadlock() loops infinitely
@ 2004-06-05  3:29 Stephen Rothwell
  2004-06-05  3:47 ` Trond Myklebust
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Rothwell @ 2004-06-05  3:29 UTC (permalink / raw)
  To: akpm, willy; +Cc: linux-fsdevel

From: Andrew Morton <akpm@osdl.org>
>
> (How can we simply rip it?  Isn't it trying to do something useful?)

I used to think so, but Andrew Tridgell convinced me that since it
actually returns false positives and false negatives in the presence of
threads, all we are really doing is trying to paper over user mode
programming errors ...

Cheers,
Stephen Rothwell

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Fw: Spam: [Bugme-new] [Bug 2829] New: posix_locks_deadlock() loops infinitely
@ 2004-06-05  3:32 Stephen Rothwell
  0 siblings, 0 replies; 12+ messages in thread
From: Stephen Rothwell @ 2004-06-05  3:32 UTC (permalink / raw)
  To: akpm, sfr, willy; +Cc: linux-fsdevel

From: Stephen Rothwell <sfr@canb.auug.org.au>
> 
> From: Andrew Morton <akpm@osdl.org>
> >
> > (How can we simply rip it?  Isn't it trying to do something useful?)
> 
> I used to think so, but Andrew Tridgell convinced me that since it
> actually returns false positives and false negatives in the presence of
> threads, all we are really doing is trying to paper over user mode
> programming errors ...

And it significantly complicates the kernel code ...

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Fw: Spam: [Bugme-new] [Bug 2829] New: posix_locks_deadlock() loops infinitely
@ 2004-06-05  7:25 Stephen Rothwell
  2004-06-06  3:04 ` Stephen Rothwell
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Rothwell @ 2004-06-05  7:25 UTC (permalink / raw)
  To: sfr, trond.myklebust; +Cc: akpm, linux-fsdevel, willy

From: Trond Myklebust <trond.myklebust@fys.uio.no>
> På fr , 04/06/2004 klokka 23:29, skreiv Stephen Rothwell:
> > 
> > I used to think so, but Andrew Tridgell convinced me that since it
> > actually returns false positives and false negatives in the presence of
> > threads, all we are really doing is trying to paper over user mode
> > programming errors ...
> 
> So you are saying that extending a lock is basically a programming
> error?

No, I am saying that (given POSIX semnatics) if you have a set of
cooperating processes or threads that use POSIX advisory file locks for
resource management (or synchronization) (and any set of processing
using file locks had better be cooperating) and you get a deadlock,
then you have a programming or design error.  Especially if you depend
on the OS to detect that deadlock as POSIX says that the OS does not
have to do the detection.

So any correctly written program that suspects (for some unforseen
reason) that its use of POSIX file locking may cause deadlock, MUST be
able to cope if the OS dies not detect that deadlock anyway.  If it
deosn't, then there are some OS platforms that are POSIX compliant on
which that program will deadlock and it is not the OS platform's
fault/problem.

I am saying that for the sake of less complicated kernel code Linux
should become one such platform.

At the moment we return false positives and false negatives (and
apparently freeze solid under some circumstances), so we would be much
better off not trying to do something that is possibly impossible for
us to do anyway.

Besides which, the POSIX spec does not even talk about the interaction
of POSIX files locks with POSIX thread as far as I can tell, so we are
basically making up the semantics ...

Cheers,
Stephen Rothwell

P.S. If you want the longer version, ask Tridge how sambs copes with
doing locking ...
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-06-06  3:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-04  5:50 Fw: Spam: [Bugme-new] [Bug 2829] New: posix_locks_deadlock() loops infinitely Andrew Morton
2004-06-04  5:53 ` Andrew Morton
2004-06-04  7:15   ` Ichiko Sakamoto
2004-06-04 11:20 ` Fw: Spam: [Bugme-new] " Matthew Wilcox
2004-06-05  2:18   ` Andrew Morton
2004-06-05  2:45     ` Trond Myklebust
2004-06-05  3:36       ` Trond Myklebust
  -- strict thread matches above, loose matches on Subject: below --
2004-06-05  3:29 Stephen Rothwell
2004-06-05  3:47 ` Trond Myklebust
2004-06-05  3:32 Stephen Rothwell
2004-06-05  7:25 Stephen Rothwell
2004-06-06  3:04 ` Stephen Rothwell

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).