[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180220084354.GO25235@hirez.programming.kicks-ass.net>
Date: Tue, 20 Feb 2018 09:43:54 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: John Ogness <john.ogness@...utronix.de>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Al Viro <viro@...iv.linux.org.uk>,
Christoph Hellwig <hch@....de>,
Thomas Gleixner <tglx@...utronix.de>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
hjl.tools@...il.com
Subject: Re: [PATCH 4/4] fs/dcache: Avoid the try_lock loops in dentry_kill()
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;
> > }
> >
Powered by blists - more mailing lists