mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: davidel@xmailserver.org, linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, mingo@elte.hu
Subject: deadlock in epoll (found by lockdep)
Date: Thu, 01 Jun 2006 10:45:37 +0200	[thread overview]
Message-ID: <1149151538.3115.29.camel@laptopd505.fenrus.org> (raw)

Hi,

in ep_poll() (fs/eventpoll.c) the code does

       write_lock_irqsave(&ep->lock, flags);

        res = 0;
        if (list_empty(&ep->rdllist)) {
                /*
                 * We don't have any available event to return to the caller.
                 * We need to sleep here, and we will be wake up by
                 * ep_poll_callback() when events will become available.
                 */
                init_waitqueue_entry(&wait, current);
                add_wait_queue(&ep->wq, &wait);

eg we first take ep->lock and then call add_wait_queue which takes 
         spin_lock_irqsave(&q->lock, flags);
for obvious reasons.
this would mean that ep->lock would be the outer lock, and q->lock the
inner lock.


HOWEVER, __wake_up does this:
void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode,
                        int nr_exclusive, void *key)
{
        unsigned long flags;

        spin_lock_irqsave(&q->lock, flags);
        __wake_up_common(q, mode, nr_exclusive, 0, key);
        spin_unlock_irqrestore(&q->lock, flags);
}

where __wake_up_common calls into ep_poll_callback, which in term does
        write_lock_irqsave(&ep->lock, flags);
as one of the first things.

... which implies that q->lock is the outer lock, and ep->lock is the
inner lock.... 

can you explain which order is right, and if/why this is not an AB-BA
deadlock??

Greetings,
   Arjan van de Ven


             reply	other threads:[~2006-06-01  8:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-01  8:45 Arjan van de Ven [this message]
2006-06-01 13:27 ` Arjan van de Ven
2006-06-01 15:52 ` Davide Libenzi

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=1149151538.3115.29.camel@laptopd505.fenrus.org \
    --to=arjan@infradead.org \
    --cc=akpm@osdl.org \
    --cc=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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

all inboxes | Powered by JetHome®