Re: [PATCH 4/4] fs/dcache: Avoid the try_lock loops in dentry_kill()

From: Peter Zijlstra
Date: Tue Feb 20 2018 - 08:03:38 EST


On Tue, Feb 20, 2018 at 12:34:57AM +0100, John Ogness wrote:
> Implementation 2: Using switch on a dentry_lock_inode() that returns a
> tristate value. Does not support branch prediction. This approach is
> probably easiest to understand.
>
> /*
> * Lock the inode. Might drop dentry->d_lock temporarily
> * which allows inode to change. Start over if that happens.
> */
> switch (dentry_lock_inode(dentry)) {
> case LOCK_FAST:

Bah, I just checked, you cannot use GCC label attributes on statements
:/ Otherwise you could've done:

case LOCK_FAST: __attribute__((hot));

> break;
> case LOCK_SLOW:
> /*
> * Recheck refcount as it might have been
> * incremented while d_lock was dropped.
> */
> if (unlikely(dentry->d_lockref.count != 1))
> goto drop_ref;
> break;
> case LOCK_FAILED:
> goto again;
> }
>