9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] interesting deadlock
Date: Fri, 17 Sep 2010 19:57:09 -0400	[thread overview]
Message-ID: <55f84040541e7af71099074be6d123bc@plug.quanstro.net> (raw)
In-Reply-To: <AANLkTimUE_yx3W=8eHkL=JyFRvR+HfGD2b-O6zxCUoOX@mail.gmail.com>

On Fri Sep 17 17:13:40 EDT 2010, rsc@swtch.com wrote:
> On Thu, Sep 16, 2010 at 11:02 PM, erik quanstrom <quanstro@quanstro.net> wrote:
> > i have these processes all deadlocked.  8.out
> > is serving /n/mntpt.
> >
> > xxx        11921346    0:00   0:00      436K Create   8.out
> > xxx        11921785    0:00   0:00       24K Open     cat /n/mntpt/sos
> > xxx        11921786    0:00   0:00       24K Unmount  unmount /n/mntpt
> > xxx        11921787    0:00   0:00       44K Pwrite   echo x y
>
> tell us why it's interesting.  it looks like 8.out can see
> itself so you've got a bad loop.

on second thought, i'm not sure i fully understand why
not forking the namespace should result in a deadlock.

8.out is opening /dev/sdC0/part OTRUNC
cat is opening /n/mntpt/sos
unmount is opening /n/mntpt

so 8.out isn't waiting for itself.
it seems that any one of the three could resonably
finish, but they deadlock.  but the problem is

		have				want
11921346					rlock(&pg->ns)
11921785	rlock(&mh->lock);
11921786	wlock(&pg->ns)			wlock(&m->lock);
		rlock(&mh->lock) [walk]

the locks for pg->ns mh->lock and m->lock aren't nested.
it would seem if they were, we would get a winner and all three
operations would complete (or fail).  so, why can't the locks
be nested?  and why does this have to deadlock?  what am i missing?

- erik



      parent reply	other threads:[~2010-09-17 23:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-17  3:02 erik quanstrom
2010-09-17 21:11 ` Russ Cox
2010-09-17 22:12   ` erik quanstrom
2010-09-17 23:21     ` Russ Cox
2010-09-17 23:57   ` erik quanstrom [this message]

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=55f84040541e7af71099074be6d123bc@plug.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /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).