public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Andi Kleen <andi@firstfloor.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	linux-kernel@vger.kernel.org
Subject: Re: NFS lockdep lock misordering mmap_sem<->i_mutex_key with 2.6.32-git1
Date: Wed, 16 Dec 2009 08:16:32 -0500	[thread overview]
Message-ID: <1260969392.3219.65.camel@localhost> (raw)
In-Reply-To: <20091216000924.GZ14381@ZenIV.linux.org.uk>

On Wed, 2009-12-16 at 00:09 +0000, Al Viro wrote: 
> On Tue, Dec 15, 2009 at 06:54:37PM -0500, Trond Myklebust wrote:
> 
> > > nfs_revalidate_mapping takes i_mutex, but mmap already has mmap_sem
> > > hold and taking i_mutex inside mmap_sem is not allowed by the VFS.
> 
> VM, actually...
> 
> > If you want to work around the problem rather than going for something
> > like Peter's split up of the mmap() callback, then I'd suggest changing
> > to using nfs_revalidate_mapping_nolock() instead. The fact that we are
> > seeing these lock misordering warnings is proof that the call to
> > nfs_revalidate_mapping() is not always a no-op.
> > 
> > By not taking the i_mutex your call to invalidate_inode_pages2() can
> > potentially end up racing with another process that is writing to the
> > file, but that should be a rare occurrence. The effect will be that the
> > two processes can end up fighting to alternatively dirty and then clean
> > the pages...
> 
> Um...  The really interesting question is whether it's a false positive;
> *can* we hit the deadlock here?  getdents() is a red herring; write() and
> truncate() are real candidates.
> 
> What happens if we have one thread do mmap() while another (sharing the
> address space with it) does write() or truncate() on the same file?

If the two threads are sharing a VM then it looks to me as if they can
potentially deadlock.

The scenario would be that the writing thread triggers a page fault
(through __get_user()) when holding the i_mutex, while the other thread
is trying to grab the i_mutex within the mmap() call.

Cheers
  Trond


  reply	other threads:[~2009-12-16 13:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07 11:59 NFS lockdep lock misordering mmap_sem<->i_mutex_key with 2.6.32-git1 Andi Kleen
2009-12-07 12:19 ` KOSAKI Motohiro
2009-12-07 13:20   ` Andi Kleen
2009-12-07 17:38     ` KOSAKI Motohiro
2009-12-15 22:21     ` Al Viro
2009-12-15 23:38       ` Andi Kleen
2009-12-15 23:54         ` Trond Myklebust
2009-12-16  0:09           ` Al Viro
2009-12-16 13:16             ` Trond Myklebust [this message]
2009-12-23 16:32               ` Andi Kleen
2009-12-16  0:53           ` Andi Kleen
2009-12-16 13:09             ` Trond Myklebust
2009-12-16 15:57               ` Andi Kleen
2009-12-16  0:06         ` KOSAKI Motohiro
2009-12-16  0:48           ` Andi Kleen

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=1260969392.3219.65.camel@localhost \
    --to=trond.myklebust@fys.uio.no \
    --cc=andi@firstfloor.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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