linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Cartwright <joshc@linux.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
	Darcy Watkins <DWatkins@tranzeo.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-mtd@lists.infradead.org,
	Thomas Gleixner <tglx@linutronix.de>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: jffs2 filesystem: possible circular locking dependency detected
Date: Mon, 13 Feb 2012 15:02:32 -0500	[thread overview]
Message-ID: <20120213200232.GA19958@joshcartwright.net> (raw)
In-Reply-To: <CAN8TOE8xLdawRm9i6oTXJOE5T+MUEinkQysH9_ossikdW+8ZhA@mail.gmail.com>

On Fri, Feb 10, 2012 at 10:57:54PM -0800, Brian Norris wrote:
> On Wed, Feb 8, 2012 at 12:09 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > On Wed, 8 Feb 2012, Darcy Watkins wrote:
> >> [   20.932000] =======================================================
> >> [   20.932000] [ INFO: possible circular locking dependency detected ]
> >> [   20.932000] 3.0.18-rt34 #41
> >> [   20.932000] -------------------------------------------------------
> >> [   20.932000] depmod/734 is trying to acquire lock:
> >> [   20.932000]  (&mm->mmap_sem){++++++}, at: [<800e82d0>] might_fault+0x4c/0xa4
> >> [   20.932000]
> >> [   20.932000] but task is already holding lock:
> >> [   20.932000]  (&f->sem){+.+.+.}, at: [<80184f88>] jffs2_readdir+0x108/0x1c0
> >> [   20.932000]
> >> [   20.932000] which lock already depends on the new lock.
> >
> > Classic ABBA deadlock. I don't think it's RT specific, but I might be
> > wrong as usual. Will have a look later this week, when noone beats me.
> 
> Looks like someone beat you :) Josh Cartwright has a patch here:
> http://lists.infradead.org/pipermail/linux-mtd/2012-February/039787.html

Unfortunately, Darcy's lockdep splat implicates a different set of
locks, so I think it is a different issue then I resolved in the linked
patch.

Looking into this one, however, I think I convinced myself that the
lockdep warning is bogus.  Here are two stack snippets that lockdep
claims would be problematic if interleaved:

do_page_fault()
   down_read(&current->mm->mmap_sem)
   /* readahead... */
      jffs2_readpage()
         mutex_lock(&JFFS2_INODE_INFO(inode)->sem)

vfs_readdir()
  /* ... */
  jffs2_readdir()
     mutex_lock(&JFFS2_INODE_INFO(inode)->sem)
     filldir()
        __put_user()
        /* fault ... */
           do_page_fault()
              down_read(&current->mm->mmap_sem)

In Darcy's case, the validator saw the do_page_fault() segment first,
and decided the lock order should be [mmap_sem, &JFFS2_INODE_INFO(inode)->sem].
It complained when it then saw the vfs_readdir() codepath reverse the
order [1].

This would be problematic, if it wasn't for the guarantee that the
jffs2_inode_info::sem in both paths will be different.  In the readdir()
path, the inode is the directory inode, whose i_fops doesn't even
support mmap(), and so couldn't possibly be involved in a fault().

1: Well, not exactly the same codepath, since a fault was not generated.
   put_user() includes a might_fault() which hints to lockdep that
   mmap_sem _could_ be acquired if a fault occurs.

-- 
                                           joshc

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2012-02-13 20:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08 18:18 jffs2 filesystem: possible circular locking dependency detected Darcy Watkins
2012-02-08 20:09 ` Thomas Gleixner
2012-02-11  6:57   ` Brian Norris
2012-02-13 20:02     ` Josh Cartwright [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=20120213200232.GA19958@joshcartwright.net \
    --to=joshc@linux.com \
    --cc=DWatkins@tranzeo.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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).