Re: [PATCH] fs/namei: Remove redundant DCACHE_MANAGED_DENTRY check in __follow_mount_rcu

From: Al Viro

Date: Mon Jan 05 2026 - 11:19:41 EST


On Mon, Jan 05, 2026 at 07:10:27AM -0800, Breno Leitao wrote:
> 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.

... since 9d2a6211a7b9 "fs: tidy up step_into() & friends before inlining",
when the check got duplicated into the caller.

> 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.

AFAICS, that's OK, for the same reason why we didn't need barriers in
the original...

Acked-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>