linux/kernel/rcu
Pranith Kumar 42d49f4525 rcu: Use rcu_gp_kthread_wake() to wake up grace period kthreads
commit 2aa792e6fa upstream.

The rcu_gp_kthread_wake() function checks for three conditions before
waking up grace period kthreads:

*  Is the thread we are trying to wake up the current thread?
*  Are the gp_flags zero? (all threads wait on non-zero gp_flags condition)
*  Is there no thread created for this flavour, hence nothing to wake up?

If any one of these condition is true, we do not call wake_up().
It was found that there are quite a few avoidable wake ups both during
idle time and under stress induced by rcutorture.

Idle:

Total:66000, unnecessary:66000, case1:61827, case2:66000, case3:0
Total:68000, unnecessary:68000, case1:63696, case2:68000, case3:0

rcutorture:

Total:254000, unnecessary:254000, case1:199913, case2:254000, case3:0
Total:256000, unnecessary:256000, case1:201784, case2:256000, case3:0

Here case{1-3} are the cases listed above. We can avoid these wake
ups by using rcu_gp_kthread_wake() to conditionally wake up the grace
period kthreads.

There is a comment about an implied barrier supplied by the wake_up()
logic.  This barrier is necessary for the awakened thread to see the
updated ->gp_flags.  This flag is always being updated with the root node
lock held. Also, the awakened thread tries to acquire the root node lock
before reading ->gp_flags because of which there is proper ordering.

Hence this commit tries to avoid calling wake_up() whenever we can by
using rcu_gp_kthread_wake() function.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
CC: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-21 09:23:05 -08:00
..
Makefile
rcu.h rcu: Remove "extern" from function declarations in kernel/rcu/rcu.h 2013-12-12 12:34:17 -08:00
srcu.c rcu: Improve SRCU's grace-period comments 2013-12-09 15:12:38 -08:00
tiny.c
tiny_plugin.h
torture.c rcu/torture: Dynamically allocate SRCU output buffer to avoid overflow 2013-12-12 12:34:16 -08:00
tree.c rcu: Use rcu_gp_kthread_wake() to wake up grace period kthreads 2014-11-21 09:23:05 -08:00
tree.h rcu: Don't activate RCU core on NO_HZ_FULL CPUs 2013-12-12 12:34:15 -08:00
tree_plugin.h Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-01-20 10:25:12 -08:00
tree_trace.c rcu: Break call_rcu() deadlock involving scheduler and perf 2013-12-03 10:10:18 -08:00
update.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-01-28 08:38:04 -08:00