Re: [RFC PATCH v2 4/4] get rid of busy-waiting in shrink_dcache_tree()

Linus Torvalds
2026-04-02T19:52:49Z

On Thu, 2 Apr 2026 at 11:05, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> @@ -455,7 +455,9 @@ static void dentry_unlink_inode(struct dentry * dentry)
>
> raw_write_seqcount_begin(&dentry->d_seq);
> __d_clear_type_and_inode(dentry);
> - hlist_del_init(&dentry->d_alias);
> + if (likely(!hlist_unhashed(&dentry->d_alias)))
> + __hlist_del(&dentry->d_alias);
> + dentry->waiters = NULL;
> raw_write_seqcount_end(&dentry->d_seq);
> spin_unlock(&dentry->d_lock);
> spin_unlock(&inode->i_lock);

I have no real objections to this patch series, but I'd like this to
get a big comment here.

There's also a 'hlist_del_init(&dentry->d_alias);' in nfs/getroot.c,
and that one stays as such.

I thnk that's just because it can't actually be a real alias list at
that point, and all that case does is to remove its own inode from the
initial list to make it always be empty. And so it doesn't have any of
this 'negative live under lookup' case. But I'd like to have some
commentary about *this* particular one, because this is the subtle
one.

In particular, I have paged out the history from the last iteration of
this all, and the reason why you changed hlist_del_init() to that
'likely(!hlist_unhashed...' escapes me.

I'm sure I could look it up and remind myself, but honestly, I'd
rather have it just all explained in the code.

Please?

Linus