From: Al Viro <viro@ZenIV.linux.org.uk>
To: "J. R. Okajima" <hooanon05g@gmail.com>
Cc: linux-fsdevel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
George Spelvin <linux@sciencehorizons.net>
Subject: Re: Q. hlist_bl_add_head_rcu() in d_alloc_parallel()
Date: Thu, 23 Jun 2016 03:58:09 +0100 [thread overview]
Message-ID: <20160623025809.GT14480@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20287.1466644756@jrobl>
[Linus and George Cc'd since it's close to the area affected by hash
rework and friends]
On Thu, Jun 23, 2016 at 10:19:16AM +0900, J. R. Okajima wrote:
>
> Al Viro:
> > That check is definitely bogus and I'm completely at loss as to WTF is it
> > doing there. Thanks for catching that; this kind of idiotic braino can
> > escape notice when rereading the code again and again, unfortunately ;-/
> >
> > Fixed, will push to Linus tonight or tomorrow.
>
> Thank you too for fixing.
> I've confirmed the patch was merged and it passed my local tests
> too. Happy.
> I have another and relatively less important suggestion. Since the two
> groups tests in the loop are very similar, how about extract them as a
> new single static function?
> Do you think it will invite a performance down?
We do have too many duplicates, especially if you count the related but not
identical ones as well.
1) __d_lookup():
check hash
grab d_lock to stabilize the rest
check parent
check if it's hashed
check name/length
2) d_alloc_parallel(), search in in-lookup hash:
hash/parent/name stable for everything in in-lookup hash, need no locks
check hash
check parent
check name/length
3) d_alloc_parallel(), check after waiting:
d_lock already held
check hash
check parent
check if it's hashed
check name/length
4) d_exact_alias():
check hash
check parent
check name/length (simplified since at the moment it's only used for
filesystems that do not have ->d_compare()).
FWIW, now that I look at d_exact_alias()... the comment in there needs
an update; the code is correct, but only because we don't call
that thing for directories. Which means that d_splice_alias()-induced
moves do not affect us, leaving only d_move(), which is always called
with parent locked exclusive.
Hell knows... Order of checks can be delicate; out of those cases, (1) and (2)
are on the hottest paths. We certainly can do this:
static always_inline bool d_same_name(const struct dentry *dentry,
const struct dentry *parent,
const struct qstr *name)
{
if (parent->d_flags & DCACHE_OP_COMPARE) {
int tlen = dentry->d_name.len;
const char *tname = dentry->d_name.name;
if (parent->d_op->d_compare(parent, dentry, tlen, tname, name))
return false;
} else {
if (dentry->d_name.len != qstr->len)
return false;
if (dentry_cmp(dentry, qstr->name, qstr->len))
return false;
}
return true;
}
then switch all four to this. That would reduce the amount of boilerplate;
I would hesitate to replace always_inline with inline, since we don't want
(1) and (2) to become uninlined, but maybe even that doesn't matter all that
much - most of rejects will happen without looking at the names. It really
needs profiling...
next prev parent reply other threads:[~2016-06-23 2:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 20:50 Q. hlist_bl_add_head_rcu() in d_alloc_parallel() J. R. Okajima
2016-06-17 22:16 ` Al Viro
2016-06-17 22:56 ` Al Viro
2016-06-19 5:24 ` J. R. Okajima
2016-06-19 16:55 ` Al Viro
2016-06-20 4:34 ` J. R. Okajima
2016-06-20 5:35 ` Al Viro
2016-06-20 14:51 ` Al Viro
2016-06-20 17:14 ` [git pull] vfs fixes Al Viro
2016-06-23 1:19 ` Q. hlist_bl_add_head_rcu() in d_alloc_parallel() J. R. Okajima
2016-06-23 2:58 ` Al Viro [this message]
2016-06-24 5:57 ` Linus Torvalds
2016-06-25 22:54 ` Al Viro
2016-06-26 1:25 ` Linus Torvalds
2016-06-29 8:17 ` Al Viro
2016-06-29 9:22 ` Hekuang
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=20160623025809.GT14480@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=hooanon05g@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux@sciencehorizons.net \
--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 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).