lkml.org 
[lkml]   [2014]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v5 4/4] futex: Avoid taking hb lock if nothing to wakeup
From
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.

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.

This only triggers for the actual case of having a task to wake up,
though, so not your particular test load.

Linus


\
 
 \ /
  Last update: 2014-01-02 21:01    [W:0.262 / U:1.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site