aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/util/scripting-engines/trace-event-python.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <[email protected]>2014-01-12 15:31:25 -0800
committerIngo Molnar <[email protected]>2014-01-13 11:45:21 +0100
commitb0c29f79ecea0b6fbcefc999e70f2843ae8306db (patch)
tree94e0d3d66c9b10d76cb0e635a352cae81d622530 /tools/perf/util/scripting-engines/trace-event-python.c
parent99b60ce69734dfeda58c6184a326b9475ce1dba3 (diff)
futexes: Avoid taking the hb->lock if there's nothing to wake up
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. While the hash bucket's plist head is a cheap way of knowing this, we cannot rely 100% on it as there is a racy window between the futex_wait call and when the task is actually added to the plist. To this end, we couple it with the spinlock check as tasks trying to enter the critical region are most likely potential waiters that will be added to the plist, thus preventing tasks sleeping forever if wakers don't acknowledge all possible waiters. Furthermore, the futex ordering guarantees are preserved, ensuring that waiters either observe the changed user space value before blocking or is woken by a concurrent waker. For wakers, this is done by relying on the barriers in get_futex_key_refs() -- for archs that do not have implicit mb in atomic_inc(), we explicitly add them through a new futex_get_mm function. For waiters we rely on the fact that spin_lock calls already update the head counter, so spinners are visible even if the lock hasn't been acquired yet. For more details please refer to the updated comments in the code and related discussion: https://lkml.org/lkml/2013/11/26/556 Special thanks to tglx for careful review and feedback. Suggested-by: Linus Torvalds <[email protected]> Reviewed-by: Darren Hart <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Reviewed-by: Peter Zijlstra <[email protected]> Signed-off-by: Davidlohr Bueso <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Jeff Mahoney <[email protected]> Cc: Scott Norton <[email protected]> Cc: Tom Vaden <[email protected]> Cc: Aswin Chandramouleeswaran <[email protected]> Cc: Waiman Long <[email protected]> Cc: Jason Low <[email protected]> Cc: Andrew Morton <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
0 files changed, 0 insertions, 0 deletions