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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 20, 2018 at 09:39:37AM +0100, Peter Zijlstra wrote:
> 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));

Oooh shiny, you can actually write:

		switch(__builtin_expect(dentry_lock_inode(dentry), LOCK_FAST)) {

and have that work, see:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59521

> >                         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;
> >                 }
> > 




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux