mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pranith Kumar <bobby.prani@gmail.com>
To: paulmck@linux.vnet.ibm.com, Josh Triplett <josh@joshtriplett.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	linux-kernel@vger.kernel.org (open list:READ-COPY UPDATE...)
Subject: [RFC PATCH 1/1] rcu: Use rcu_gp_kthread_wake() to wake up kthreads
Date: Fri, 25 Jul 2014 01:06:58 -0400	[thread overview]
Message-ID: <1406264818-2296-1-git-send-email-bobby.prani@gmail.com> (raw)

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(). 

In rcu_report_qs_rsp(), I added a pr_info() call testing if any of the above
conditions is true, in which case we can avoid calling wake_up(). It turns out
that quite a few actually are. Most of the cases where we can avoid is condition 2
above and condition 1 also occurs quite often. Condition 3 never happens.

I could not test the wake_up() in force_quiescent_state() as that is not
triggered trivially, but I am assuming we can replace wake_up() there too.

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

One concern is the comment which states that we need a memory barrier at that
location which is being implied by the wake_up(). Should we put an smp_mb() and
just not rely on the barrier provided by wake_up()? Thoughts?

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 kernel/rcu/tree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 72e0b1f..d0e0d6e 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1938,7 +1938,8 @@ 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. */
+	/* Memory barrier implied by wake_up() path. */
+	rcu_gp_kthread_wake(rsp);
 }
 
 /*
@@ -2516,7 +2517,8 @@ 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. */
+	/* Memory barrier implied by wake_up() path. */
+	rcu_gp_kthread_wake(rsp);
 }
 
 /*
-- 
2.0.1


             reply	other threads:[~2014-07-25  5:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-25  5:06 Pranith Kumar [this message]
2014-07-25  6:24 ` Pranith Kumar
2014-07-25 15:02   ` Paul E. McKenney
2014-07-25 22:23     ` Pranith Kumar
2014-07-25 23:15       ` Paul E. McKenney
2014-07-25 23:29         ` Pranith Kumar
2014-07-27 17:19           ` Paul E. McKenney
2014-07-25 14:44 ` Paul E. McKenney
2014-07-25 20:19   ` Pranith Kumar
2014-07-25 22:47     ` Paul E. McKenney
2014-07-27 15:55       ` Pranith Kumar
2014-07-27 16:29         ` Paul E. McKenney
2014-07-27 16:44           ` Pranith Kumar
2014-07-27 17:16             ` 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=1406264818-2296-1-git-send-email-bobby.prani@gmail.com \
    --to=bobby.prani@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.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

Powered by JetHome