From: Al Viro <viro@zeniv.linux.org.uk>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v4] fs: add predicts based on nd->depth
Date: Tue, 11 Nov 2025 03:32:26 +0000 [thread overview]
Message-ID: <20251111033226.GP2441659@ZenIV> (raw)
In-Reply-To: <20251110165901.1491476-1-mjguzik@gmail.com>
On Mon, Nov 10, 2025 at 05:59:01PM +0100, Mateusz Guzik wrote:
> Given these results:
> 1. terminate_walk() is called towards the end of the lookup. I failed
> run into a case where it has any depth to clean up. For now predict
> it does not.
Easy - just have an error while resolving a nested symlink in the middle
of pathname. On success it will have zero nd->depth, of course.
> 2. legitimize_links() is also called towards the end of lookup and most
> of the time there s 0 depth. Patch consumers to avoid calling into it
> in that case.
On transition from lazy to non-lazy mode on cache miss, ->d_revalidate()
saying "dunno, try in non-lazy mode", etc.
That can happen inside a nested symlink as well as on the top level, but
the latter is more common on most of the loads.
> 3. walk_component() is typically called with WALK_MORE and zero depth,
> checked in that order. Check depth first and predict it is 0.
Does it give a measurable effect?
> 4. link_path_walk() predicts not dealing with a symlink, but the other
> part of symlink handling fails to make the same predict. Add it.
Unconvincing, that - one is "we have a component; what are the odds of that
component being a symlink?", another - "we have reached the end of pathname
or the end of nested symlink; what are the odds of the latter being the case?"
I can believe that answers to both questions are fairly low, but they are
not the same. I'd expect the latter to be considerably higher than the
former.
> - if (unlikely(!legitimize_links(nd)))
> + if (unlikely(nd->depth && !legitimize_links(nd)))
I suspect that
if (unlikely(nd->depth) && !legitimize_links(nd))
might be better...
> - if (unlikely(!legitimize_links(nd)))
> + if (unlikely(nd->depth && !legitimize_links(nd)))
> goto out2;
Ditto.
next prev parent reply other threads:[~2025-11-11 3:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 16:59 [PATCH v4] fs: add predicts based on nd->depth Mateusz Guzik
2025-11-11 3:32 ` Al Viro [this message]
2025-11-11 18:00 ` Mateusz Guzik
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=20251111033226.GP2441659@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
/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