linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@linux.intel.com>
To: Davidlohr Bueso <davidlohr@hp.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Mike Galbraith <efault@gmx.de>, Jeff Mahoney <jeffm@suse.com>,
	Jason Low <jason.low2@hp.com>, Waiman Long <Waiman.Long@hp.com>,
	Tom Vaden <tom.vaden@hp.com>,
	"Norton, Scott J" <scott.norton@hp.com>,
	"Chandramouleeswaran, Aswin" <aswin@hp.com>
Subject: Re: [PATCH v5 4/4] futex: Avoid taking hb lock if nothing to wakeup
Date: Mon, 06 Jan 2014 12:56:45 -0800	[thread overview]
Message-ID: <1389041805.30730.47.camel@dvhart-mobl4.amr.corp.intel.com> (raw)
In-Reply-To: <1388696357.11119.10.camel@buesod1.americas.hpqcorp.net>

On Thu, 2014-01-02 at 12:59 -0800, Davidlohr Bueso wrote:
> On Thu, 2014-01-02 at 11:23 -0800, Linus Torvalds wrote:
> > On Thu, Jan 2, 2014 at 7:05 AM, Davidlohr Bueso <davidlohr@hp.com> wrote:
> > >
> > > In futex_wake() there is clearly no point in taking the hb->lock if we know
> > > beforehand that there are no tasks to be woken.
> > 
> > Btw, I think we could optimize this a bit further for the wakeup case.
> > 
> > wake_futex() does a get_task_struct(p)/put_task_struct(p) around its
> > actual waking logic, and I don't think that's necessary. The task
> > structures are RCU-delayed, and the task cannot go away until the
> > "q->lock_ptr = NULL" afaik, so you could replace that atomic inc/dec
> > with just a RCU read region.
> 
> I had originally explored making the whole plist thing more rcu aware
> but never got to anything worth sharing. What you say does make a lot of
> sense, however, I haven't been able to see any actual improvements. It
> doesn't hurt however, so I'd have no problem adding such patch to the
> lot.
> 
> > 
> > Maybe it's not a big deal ("wake_up_state()" ends up getting the task
> > struct pi_lock anyway, so it's not like we can avoid toucing the task
> > structure), but I'm getting the feeling that we're doing a lot of
> > unnecessary work here.
> 
> I passed this idea through my wakeup measuring program and didn't notice
> hardly any difference, just noise, even for large amounts of futexes.
> I believe that peterz's idea of lockless batch wakeups is the next step
> worth looking into for futexes -- even though the spurious wakeup
> problem can become a real pain.
> 
> Thanks,
> Davidlohr
> 
> 

While I love to see significant performance improvements to the futex
hot paths, I am wary of the sort of implicit improvements we've been
exploring here. At the risk of being a wimp here, this code is
incredibly complex already, so I would prefer anything along these lines
have very strong empirical justification first - as Davidlohr's changes
here have provided.

Does anyone see any reason to hold off getting them in at this point?
I've made a couple points on comments and docs to the 4/5 patch, but
otherwise, I think it's time to get them in and more broadly tested.

-- 
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel



  reply	other threads:[~2014-01-06 20:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-02 15:05 [PATCH v5 0/4] futex: Wakeup optimizations Davidlohr Bueso
2014-01-02 15:05 ` [PATCH v5 1/4] futex: Misc cleanups Davidlohr Bueso
2014-01-11  6:43   ` Paul E. McKenney
2014-01-02 15:05 ` [PATCH v5 2/4] futex: Larger hash table Davidlohr Bueso
2014-01-11  7:37   ` Paul E. McKenney
2014-01-02 15:05 ` [PATCH v5 3/4] futex: Document ordering guarantees Davidlohr Bueso
2014-01-06 18:58   ` Darren Hart
2014-01-11  7:40   ` Paul E. McKenney
2014-01-02 15:05 ` [PATCH v5 4/4] futex: Avoid taking hb lock if nothing to wakeup Davidlohr Bueso
2014-01-02 19:23   ` Linus Torvalds
2014-01-02 20:59     ` Davidlohr Bueso
2014-01-06 20:56       ` Darren Hart [this message]
2014-01-06 20:52   ` Darren Hart
2014-01-07  3:29     ` Davidlohr Bueso
2014-01-07 17:40       ` Darren Hart
2014-01-11  9:49   ` Paul E. McKenney
2014-01-11  9:52     ` Paul E. McKenney
2014-01-11 18:21       ` Davidlohr Bueso
2014-01-06  0:59 ` [PATCH v5 0/4] futex: Wakeup optimizations Davidlohr Bueso
2014-01-06  1:38 ` [PATCH 5/4] futex: silence uninitialized warnings Davidlohr Bueso
2014-01-06 18:48   ` Darren Hart
2014-01-07  2:55   ` Linus Torvalds
2014-01-07  3:02     ` Davidlohr Bueso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389041805.30730.47.camel@dvhart-mobl4.amr.corp.intel.com \
    --to=dvhart@linux.intel.com \
    --cc=Waiman.Long@hp.com \
    --cc=aswin@hp.com \
    --cc=davidlohr@hp.com \
    --cc=efault@gmx.de \
    --cc=jason.low2@hp.com \
    --cc=jeffm@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=scott.norton@hp.com \
    --cc=tglx@linutronix.de \
    --cc=tom.vaden@hp.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).