All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, laijs@cn.fujitsu.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
	rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
	dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com,
	bobby.prani@gmail.com,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 13/15] rcu: Use rcu_gp_kthread_wake() to wake up grace period kthreads
Date: Thu, 28 Aug 2014 11:26:32 -0700	[thread overview]
Message-ID: <1409250394-25159-13-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <1409250394-25159-1-git-send-email-paulmck@linux.vnet.ibm.com>

From: Pranith Kumar <bobby.prani@gmail.com>

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>
---
 kernel/rcu/tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index dd6c8b519691..9e83cd9a32f1 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1938,7 +1938,7 @@ static void rcu_report_qs_rsp(struct rcu_state *rsp, unsigned long flags)
 {
 	WARN_ON_ONCE(!rcu_gp_in_progress(rsp));
 	raw_spin_unlock_irqrestore(&rcu_get_root(rsp)->lock, flags);
-	wake_up(&rsp->gp_wq);  /* Memory barrier implied by wake_up() path. */
+	rcu_gp_kthread_wake(rsp);
 }
 
 /*
@@ -2516,7 +2516,7 @@ static void force_quiescent_state(struct rcu_state *rsp)
 	ACCESS_ONCE(rsp->gp_flags) =
 		ACCESS_ONCE(rsp->gp_flags) | RCU_GP_FLAG_FQS;
 	raw_spin_unlock_irqrestore(&rnp_old->lock, flags);
-	wake_up(&rsp->gp_wq);  /* Memory barrier implied by wake_up() path. */
+	rcu_gp_kthread_wake(rsp);
 }
 
 /*
-- 
1.8.1.5


  parent reply	other threads:[~2014-08-28 18:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 18:26 [PATCH tip/core/rcu 0/15] Miscellaneous fixes for 3.18 Paul E. McKenney
2014-08-28 18:26 ` [PATCH tip/core/rcu 01/15] rcu: Remove remaining read-modify-write ACCESS_ONCE() calls Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 02/15] rcu: Fix sparse warning about rcu_batches_completed_preempt() being non-static Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 03/15] rcu: Use bool type for return value in rcu_is_watching() Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 04/15] rcu: Return bool type for rcu_try_advance_all_cbs() Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 05/15] rcu: Return bool type in rcu_lockdep_current_cpu_online() Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 06/15] rcu: Use true/false instead of 1/0 for a bool type Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 07/15] rcu: Uninline rcu_read_lock_held() Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 08/15] rcu: Define tracepoint strings only if CONFIG_TRACING is set Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 09/15] rcu: Update tiny.c references to tree.c Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 10/15] rcu: Remove stale comment in tree.c Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 11/15] rcu: Break more call_rcu() deadlock involving scheduler and perf Paul E. McKenney
2014-09-01 11:29     ` Peter Zijlstra
2014-09-01 16:20       ` Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 12/15] rcu: Make TINY_RCU tinier by putting error checks under #ifdef Paul E. McKenney
2014-08-28 18:26   ` Paul E. McKenney [this message]
2014-08-28 18:26   ` [PATCH tip/core/rcu 14/15] rcu: Replace flush_signals() with WARN_ON(signal_pending()) Paul E. McKenney
2014-08-28 18:26   ` [PATCH tip/core/rcu 15/15] rcu: Add ACCESS_ONCE() for RCU_INIT_POINTER() Paul E. McKenney

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=1409250394-25159-13-git-send-email-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=bobby.prani@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=dvhart@linux.intel.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.