All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Miklos Szeredi <mszeredi@suse.cz>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: fs/dcache.c - BUG: soft lockup - CPU#5 stuck for 22s! [systemd-udevd:1667]
Date: Fri, 30 May 2014 11:12:38 +0300	[thread overview]
Message-ID: <20140530081238.GA1957@lahna.fi.intel.com> (raw)
In-Reply-To: <20140529185201.GN18016@ZenIV.linux.org.uk>

On Thu, May 29, 2014 at 07:52:01PM +0100, Al Viro wrote:
> On Thu, May 29, 2014 at 05:53:51PM +0100, Al Viro wrote:
> > On Thu, May 29, 2014 at 09:29:42AM -0700, Linus Torvalds wrote:
> > > On Thu, May 29, 2014 at 9:23 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> > > >
> > > > BTW, lock_parent() might be better off if in contended case it would not
> > > > bother with rename_lock and did something like this:
> > > > again:
> > > 
> > > Ack. I think that's much better.
> > 
> > Pushed to #for-linus (with dumb braino fixed - it's if (parent != dentry),
> > not if (parent)).  I'll wait with folding it back into the commit that
> > introduces lock_parent() until we get testing results...
> 
> Grrr...  Sadly, that's not good enough.  Leaking rcu_read_lock() on
> success is trivial, but there's more serious problem: suppose dentries
> involved get moved before we get to locking what we thought was parent.
> We end up taking ->d_lock on two dentries that might be nowhere near each
> other in the tree, with obvious nasty implications.  Would be _very_ hard
> to reproduce ;-/
> 
> AFAICS, the following would be safe, but I'd really appreciate any extra
> eyes on that sucker:
> 
> static inline struct dentry *lock_parent(struct dentry *dentry)
> {
>         struct dentry *parent = dentry->d_parent;
>         if (IS_ROOT(dentry))
>                 return NULL;
>         if (likely(spin_trylock(&parent->d_lock)))
>                 return parent;
>         spin_unlock(&dentry->d_lock);
>         rcu_read_lock();
> again:
>         parent = ACCESS_ONCE(dentry->d_parent);
>         spin_lock(&parent->d_lock);
>         /*
>          * We can't blindly lock dentry until we are sure
>          * that we won't violate the locking order.
>          * While parent->d_lock is not enough to stabilize
> 	 * dentry->d_parent, it *is* enough to stabilize
> 	 * dentry->d_parent == parent.
>          */
>         if (unlikely(parent != dentry->d_parent)) {
>                 spin_unlock(&parent->d_lock);
>                 goto again;
>         }
>         rcu_read_unlock();
>         if (parent != dentry)
>                 spin_lock(&dentry->d_lock);
>         else
>                 parent = NULL;
>         return parent;
> }
> 
> That variant got force-pushed in place of the previous one, again at the
> head of #for-linus.  And I'm definitely not folding it in until it gets
> more review and testing.

Tested your latest #for-linus from here:

https://git.kernel.org/cgit/linux/kernel/git/viro/vfs.git/log/?h=for-linus

and the livelock is gone,

Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Thanks again!

  parent reply	other threads:[~2014-05-30  8:12 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26  9:37 fs/dcache.c - BUG: soft lockup - CPU#5 stuck for 22s! [systemd-udevd:1667] Mika Westerberg
2014-05-26 13:57 ` Al Viro
2014-05-26 14:29   ` Mika Westerberg
2014-05-26 14:29     ` Mika Westerberg
2014-05-26 15:27     ` Al Viro
2014-05-26 16:42       ` Al Viro
2014-05-26 18:17       ` Linus Torvalds
2014-05-26 18:26         ` Al Viro
2014-05-26 20:24           ` Linus Torvalds
2014-05-27  1:40             ` Al Viro
2014-05-27  3:14               ` Al Viro
2014-05-27  4:00                 ` Al Viro
2014-05-27  7:04                   ` Mika Westerberg
2014-05-27  7:04                     ` Mika Westerberg
2014-05-28  3:19                     ` Al Viro
2014-05-28  7:37                       ` Mika Westerberg
2014-05-28 11:57                         ` Al Viro
2014-05-28 13:11                           ` Mika Westerberg
2014-05-28 14:19                             ` Al Viro
2014-05-28 18:39                               ` Al Viro
2014-05-28 19:43                                 ` Linus Torvalds
2014-05-28 20:02                                   ` Linus Torvalds
2014-05-28 20:25                                     ` Al Viro
2014-05-29 10:42                                     ` Mika Westerberg
2014-05-28 20:14                                   ` Al Viro
2014-05-28 21:11                                     ` Linus Torvalds
2014-05-28 21:28                                       ` Al Viro
2014-05-29  3:11                                 ` Al Viro
2014-05-29  3:52                                   ` Al Viro
2014-05-29  5:34                                     ` Al Viro
2014-05-29 10:51                                       ` Mika Westerberg
2014-05-29 10:51                                         ` Mika Westerberg
2014-05-29 11:04                                         ` Mika Westerberg
2014-05-29 13:30                                           ` Al Viro
2014-05-29 14:56                                             ` Mika Westerberg
2014-05-29 15:10                                             ` Linus Torvalds
2014-05-29 15:44                                               ` Al Viro
2014-05-29 16:23                                                 ` Al Viro
2014-05-29 16:29                                                   ` Linus Torvalds
2014-05-29 16:53                                                     ` Al Viro
2014-05-29 18:52                                                       ` Al Viro
2014-05-29 19:14                                                         ` Linus Torvalds
2014-05-30  4:50                                                           ` Al Viro
2014-05-30  5:00                                                             ` Linus Torvalds
2014-05-30  6:49                                                               ` Al Viro
2014-05-30  8:12                                                         ` Mika Westerberg [this message]
2014-05-30 15:21                                                           ` Al Viro
2014-05-30 15:31                                                             ` Linus Torvalds
2014-05-30 16:48                                                               ` [git pull] " Al Viro
2014-05-30 17:14                                                                 ` Al Viro
2014-05-31 14:18                                                                   ` Josh Boyer
2014-05-31 14:48                                                                     ` Linus Torvalds
2014-05-31 14:58                                                                       ` Josh Boyer
2014-05-31 16:12                                                                       ` Josh Boyer
2014-05-30 17:15                                                                 ` Sedat Dilek
2014-05-29  4:21                                   ` Linus Torvalds
2014-05-29  5:16                                     ` Al Viro
2014-05-29  5:26                                       ` Al Viro

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=20140530081238.GA1957@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mszeredi@suse.cz \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.