]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/namei: Remove redundant DCACHE_MANAGED_DENTRY check in __follow_mount_rcu
authorBreno Leitao <leitao@debian.org>
Mon, 5 Jan 2026 15:10:27 +0000 (07:10 -0800)
committerChristian Brauner <brauner@kernel.org>
Tue, 6 Jan 2026 21:48:15 +0000 (22:48 +0100)
The check for DCACHE_MANAGED_DENTRY at the start of __follow_mount_rcu()
is redundant because the only caller (handle_mounts) already verifies
d_managed(dentry) before calling this function, so, dentry in
__follow_mount_rcu() has always DCACHE_MANAGED_DENTRY set.

This early-out optimization never fires in practice - but it is marking
as likely().

This was detected with branch profiling, which shows 100% misprediction
in this likely.

Remove the whole if clause instead of removing the likely, given we
know for sure that dentry is not DCACHE_MANAGED_DENTRY.

Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260105-dcache-v1-1-f0d904b4a7c2@debian.org
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namei.c

index 280c69e8fb991ac10e2eec534f01795729c1d9ff..e0d5ebdf43a343ded3ab5c5154e91020a46124e9 100644 (file)
@@ -1624,9 +1624,6 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path)
        struct dentry *dentry = path->dentry;
        unsigned int flags = dentry->d_flags;
 
-       if (likely(!(flags & DCACHE_MANAGED_DENTRY)))
-               return true;
-
        if (unlikely(nd->flags & LOOKUP_NO_XDEV))
                return false;