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 RFC tip/core/rcu 2/5] rcu: Short-circuit normal GPs via expedited GPs
Date: Tue, 30 Jun 2015 14:48:27 -0700 [thread overview]
Message-ID: <1435700910-9104-2-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <1435700910-9104-1-git-send-email-paulmck@linux.vnet.ibm.com>
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
If an expedited grace period executes after the start of a normal
grace period, there is no point in the normal grace period doing any
more work, as the expedited grace period has supplied all the needed
quiescent states. This commit therefore makes the normal grace-period
initialization process take a snapshot of the expedited grace-period
state, and then recheck the state just before each force-quiescent-state
scan. If the recheck determines that a full expedited grace period
executed since the beginning of the normal grace period, the grace-period
kthread proceeds immediately to grace-period cleanup.
Because the expedited grace period does not awaken the grace-period
kthread, this change should provide only a minimal reduction in
grace-period latency, however, it does reduce the overhead of detecting
the end of the grace period.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
kernel/rcu/tree.c | 40 ++++++++++++++++++++++++++++++++--------
kernel/rcu/tree.h | 6 ++++++
2 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index bea9b9c80d91..5365f6332a60 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -104,6 +104,7 @@ struct rcu_state sname##_state = { \
.orphan_nxttail = &sname##_state.orphan_nxtlist, \
.orphan_donetail = &sname##_state.orphan_donelist, \
.barrier_mutex = __MUTEX_INITIALIZER(sname##_state.barrier_mutex), \
+ .exp_rsp = &sname##_state, \
.name = RCU_STATE_NAME(sname), \
.abbr = sabbr, \
}
@@ -1954,6 +1955,15 @@ static int rcu_gp_init(struct rcu_state *rsp)
WRITE_ONCE(rsp->gp_activity, jiffies);
}
+ /*
+ * Record associated expedited-grace-period snapshot. This cannot
+ * be done before the root rcu_node structure has been initialized
+ * due to the fact that callbacks can still be registered for the
+ * current grace period until that initialization is complete.
+ */
+ rsp->gp_exp_snap = rcu_exp_gp_seq_snap(rsp->exp_rsp);
+ rsp->gp_exp_help = false;
+
return 1;
}
@@ -2035,8 +2045,14 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
rcu_for_each_node_breadth_first(rsp, rnp) {
raw_spin_lock_irq(&rnp->lock);
smp_mb__after_unlock_lock();
- WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp));
- WARN_ON_ONCE(rnp->qsmask);
+ if (!rsp->gp_exp_help) {
+ WARN_ON_ONCE(rnp->qsmask);
+ WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp));
+ } else {
+ /* Clear out state from truncated grace period. */
+ rnp->qsmask = 0;
+ rnp->gp_tasks = NULL;
+ }
WRITE_ONCE(rnp->completed, rsp->gpnum);
rdp = this_cpu_ptr(rsp->rda);
if (rnp == rdp->mynode)
@@ -2121,17 +2137,24 @@ static int __noreturn rcu_gp_kthread(void *arg)
TPS("fqswait"));
rsp->gp_state = RCU_GP_WAIT_FQS;
ret = wait_event_interruptible_timeout(rsp->gp_wq,
- ((gf = READ_ONCE(rsp->gp_flags)) &
- RCU_GP_FLAG_FQS) ||
- (!READ_ONCE(rnp->qsmask) &&
- !rcu_preempt_blocked_readers_cgp(rnp)),
- j);
+ ((gf = READ_ONCE(rsp->gp_flags)) &
+ RCU_GP_FLAG_FQS) ||
+ (!READ_ONCE(rnp->qsmask) &&
+ !rcu_preempt_blocked_readers_cgp(rnp)) ||
+ rcu_exp_gp_seq_done(rsp->exp_rsp,
+ rsp->gp_exp_snap),
+ j);
rsp->gp_state = RCU_GP_DONE_FQS;
/* Locking provides needed memory barriers. */
/* If grace period done, leave loop. */
if (!READ_ONCE(rnp->qsmask) &&
- !rcu_preempt_blocked_readers_cgp(rnp))
+ !rcu_preempt_blocked_readers_cgp(rnp)) {
break;
+ } else if (rcu_exp_gp_seq_done(rsp->exp_rsp,
+ rsp->gp_exp_snap)) {
+ rsp->gp_exp_help = true;
+ break;
+ }
/* If time for quiescent-state forcing, do it. */
if (ULONG_CMP_GE(jiffies, rsp->jiffies_force_qs) ||
(gf & RCU_GP_FLAG_FQS)) {
@@ -4190,6 +4213,7 @@ void __init rcu_init(void)
rcu_init_geometry();
rcu_init_one(&rcu_bh_state, &rcu_bh_data);
rcu_init_one(&rcu_sched_state, &rcu_sched_data);
+ rcu_bh_state.exp_rsp = &rcu_sched_state;
if (dump_tree)
rcu_dump_rcu_node_tree(&rcu_sched_state);
__rcu_init_preempt();
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
index e40b65d45495..eed6e84cb182 100644
--- a/kernel/rcu/tree.h
+++ b/kernel/rcu/tree.h
@@ -466,6 +466,10 @@ struct rcu_state {
wait_queue_head_t gp_wq; /* Where GP task waits. */
short gp_flags; /* Commands for GP task. */
short gp_state; /* GP kthread sleep state. */
+ bool gp_exp_help; /* Expedited GP helped the */
+ /* just-completed normal GP. */
+ unsigned long gp_exp_snap; /* Expedited snapshot for */
+ /* FQS short-circuiting. */
/* End of fields guarded by root rcu_node's lock. */
@@ -495,6 +499,8 @@ struct rcu_state {
atomic_long_t expedited_normal; /* # fallbacks to normal. */
atomic_t expedited_need_qs; /* # CPUs left to check in. */
wait_queue_head_t expedited_wq; /* Wait for check-ins. */
+ struct rcu_state *exp_rsp; /* RCU flavor that expedites */
+ /* for this flavor. */
unsigned long jiffies_force_qs; /* Time at which to invoke */
/* force_quiescent_state(). */
--
1.8.1.5
next prev parent reply other threads:[~2015-06-30 21:49 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 21:48 [PATCH RFC tip/core/rcu 0/5] Expedited grace periods encouraging normal ones Paul E. McKenney
2015-06-30 21:48 ` [PATCH RFC tip/core/rcu 1/5] rcu: Prepare for expedited GP driving normal GP Paul E. McKenney
2015-06-30 21:48 ` Paul E. McKenney [this message]
2015-07-01 10:03 ` [PATCH RFC tip/core/rcu 2/5] rcu: Short-circuit normal GPs via expedited GPs Peter Zijlstra
2015-07-01 13:42 ` Paul E. McKenney
2015-07-01 20:59 ` Paul E. McKenney
2015-07-01 10:05 ` Peter Zijlstra
2015-07-01 13:41 ` Paul E. McKenney
2015-07-01 13:48 ` Peter Zijlstra
2015-07-01 14:03 ` Paul E. McKenney
2015-07-02 12:03 ` Peter Zijlstra
2015-07-02 14:06 ` Paul E. McKenney
2015-07-02 16:48 ` Peter Zijlstra
2015-07-02 19:35 ` Paul E. McKenney
2015-07-06 14:52 ` Peter Zijlstra
2015-06-30 21:48 ` [PATCH RFC tip/core/rcu 3/5] rcutorture: Ensure that normal GPs advance without " Paul E. McKenney
2015-06-30 21:48 ` [PATCH RFC tip/core/rcu 4/5] rcu: Wake grace-period kthread at end of expedited grace period Paul E. McKenney
2015-06-30 21:48 ` [PATCH RFC tip/core/rcu 5/5] rcu: Limit expedited helping to every 10 ms or every 4th GP Paul E. McKenney
2015-06-30 21:56 ` Eric Dumazet
2015-06-30 22:10 ` Paul E. McKenney
2015-07-01 10:07 ` Peter Zijlstra
2015-07-01 13:45 ` Paul E. McKenney
2015-07-01 19:30 ` Paul E. McKenney
2015-06-30 22:00 ` [PATCH RFC tip/core/rcu 0/5] Expedited grace periods encouraging normal ones josh
2015-06-30 22:12 ` Paul E. McKenney
2015-06-30 23:46 ` josh
2015-07-01 0:15 ` Paul E. McKenney
2015-07-01 0:42 ` Josh Triplett
2015-07-01 3:37 ` Paul E. McKenney
2015-07-01 10:12 ` Peter Zijlstra
2015-07-01 14:01 ` Paul E. McKenney
2015-07-01 14:08 ` Eric Dumazet
2015-07-01 15:58 ` Paul E. McKenney
2015-07-01 15:43 ` Josh Triplett
2015-07-01 15:59 ` Paul E. McKenney
2015-07-01 10:09 ` Peter Zijlstra
2015-07-01 10:55 ` Peter Zijlstra
2015-07-01 14:00 ` Paul E. McKenney
2015-07-01 14:17 ` Peter Zijlstra
2015-07-01 16:17 ` Paul E. McKenney
2015-07-01 17:02 ` Peter Zijlstra
2015-07-01 20:09 ` Paul E. McKenney
2015-07-01 21:20 ` josh
2015-07-01 21:49 ` Paul E. McKenney
2015-07-02 7:47 ` Ingo Molnar
2015-07-02 13:58 ` Paul E. McKenney
2015-07-02 18:35 ` Ingo Molnar
2015-07-02 18:47 ` Mathieu Desnoyers
2015-07-02 19:23 ` Paul E. McKenney
2015-07-02 21:07 ` Mathieu Desnoyers
2015-07-02 19:22 ` Paul E. McKenney
2015-07-02 1:11 ` Mike Galbraith
2015-07-02 1:34 ` josh
2015-07-02 1:59 ` Mike Galbraith
2015-07-02 2:18 ` Paul E. McKenney
2015-07-02 2:50 ` Mike Galbraith
2015-07-02 3:15 ` 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=1435700910-9104-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome