From: Al Viro <viro@ZenIV.linux.org.uk>
To: John Ogness <john.ogness@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Christoph Hellwig <hch@lst.de>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/4] fs/dcache: Avoid the try_lock loops in dentry_kill()
Date: Thu, 22 Feb 2018 05:29:06 +0000 [thread overview]
Message-ID: <20180222052906.GM30522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <878tbov9i6.fsf@linutronix.de>
On Tue, Feb 20, 2018 at 12:34:57AM +0100, John Ogness wrote:
> Implementation 3: The same as implementation 2 but using if's to
> support branch prediction. This approach is probably the most
> complicated to understand but will be the fastest.
>
> /*
> * Lock the inode. Might drop dentry->d_lock temporarily
> * which allows inode to change. Start over if that happens.
> */
> int ret = dentry_lock_inode(dentry);
> if (unlikely(ret != LOCK_FAST)) {
> if (ret == LOCK_FAILED)
> goto again;
> /*
> * Recheck refcount as it might have been
> * incremented while d_lock was dropped.
> */
> if (dentry->d_lockref.count != 1)
> goto drop_ref;
> }
Implementation 4: screw the tristate, move the loop inside dentry_lock_inode().
> If lock_parent() returns a non-NULL, it is returning
> dentry->d_parent. So the return value is really just a boolean and the
> locked parent is the parent of the dentry. The function is a little bit
> tricky because it could return NULL (lock failed) even if the dentry has
> a non-NULL d_parent. So any caller using a tristate return variation of
> lock_parent() must rely on the return value instead of a non-NULL
> dentry->d_parent.
dentry always has non-NULL ->d_parent; it might point to dentry itself, but
it's never NULL.
> if (!dentry->d_lockref.count) {
> - struct dentry *parent = lock_parent(dentry);
> + int ret = lock_parent(dentry);
> + parent = dentry->d_parent;
> if (likely(!dentry->d_lockref.count)) {
> __dentry_kill(dentry);
> dput(parent);
Broken. In IS_ROOT case you'll hit an extra dput() on dentry itself.
dput(NULL) is no-op; this, OTOH, isn't.
next prev parent reply other threads:[~2018-02-22 5:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 15:09 [PATCH 0/4] fs/dcache: avoid trylock loops John Ogness
2018-02-16 15:09 ` [PATCH 1/4] fs/dcache: Remove stale comment from dentry_kill() John Ogness
2018-02-16 15:09 ` [PATCH 2/4] fs/dcache: Move dentry_kill() below lock_parent() John Ogness
2018-02-16 15:09 ` [PATCH 3/4] fs/dcache: Avoid the try_lock loop in d_delete() John Ogness
2018-02-16 17:10 ` Peter Zijlstra
2018-02-16 17:30 ` Peter Zijlstra
2018-02-22 5:18 ` Al Viro
2018-02-22 8:35 ` John Ogness
2018-02-16 15:09 ` [PATCH 4/4] fs/dcache: Avoid the try_lock loops in dentry_kill() John Ogness
2018-02-16 18:03 ` Linus Torvalds
2018-02-16 22:32 ` John Ogness
2018-02-16 22:42 ` Linus Torvalds
2018-02-16 23:05 ` John Ogness
2018-02-16 23:31 ` Linus Torvalds
2018-02-16 23:49 ` John Ogness
2018-02-17 0:06 ` Linus Torvalds
2018-02-19 23:34 ` John Ogness
2018-02-20 0:42 ` Linus Torvalds
2018-02-20 8:39 ` Peter Zijlstra
2018-02-20 8:43 ` Peter Zijlstra
2018-02-22 5:29 ` Al Viro [this message]
2018-02-22 5:40 ` 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=20180222052906.GM30522@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=bigeasy@linutronix.de \
--cc=hch@lst.de \
--cc=john.ogness@linutronix.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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.