Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1376939

[PATCH tip/core/rcu 12/16] rcu: Add exp_funnel_lock() fastpath

From "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH tip/core/rcu 12/16] rcu: Add exp_funnel_lock() fastpath
Date 2016-04-12 17:40 +0200
Message-ID <rn8A3-1cd-37@gated-at.bofh.it> (permalink)
References <rn8qm-16v-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This commit speeds up the low-contention case, especially for systems
with large rcu_node trees, by attempting to directly acquire the
->exp_mutex.  This fastpath checks the leaves and root first in
order to avoid excessive memory contention on the mutex itself.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index bd2658edce00..892a140ae7b6 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3603,6 +3603,15 @@ static bool exp_funnel_lock(struct rcu_state *rsp, unsigned long s)
 {
 	struct rcu_data *rdp = per_cpu_ptr(rsp->rda, raw_smp_processor_id());
 	struct rcu_node *rnp = rdp->mynode;
+	struct rcu_node *rnp_root = rcu_get_root(rsp);
+
+	/* Low-contention fastpath. */
+	if (ULONG_CMP_LT(READ_ONCE(rnp->exp_seq_rq), s) &&
+	    (rnp == rnp_root ||
+	     ULONG_CMP_LT(READ_ONCE(rnp_root->exp_seq_rq), s)) &&
+	    !mutex_is_locked(&rsp->exp_mutex) &&
+	    mutex_trylock(&rsp->exp_mutex))
+		goto fastpath;
 
 	/*
 	 * Each pass through the following loop works its way up
@@ -3635,6 +3644,7 @@ static bool exp_funnel_lock(struct rcu_state *rsp, unsigned long s)
 					  rnp->grphi, TPS("nxtlvl"));
 	}
 	mutex_lock(&rsp->exp_mutex);
+fastpath:
 	if (sync_exp_work_done(rsp, &rdp->exp_workdone3, s)) {
 		mutex_unlock(&rsp->exp_mutex);
 		return true;
-- 
2.5.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH tip/core/rcu 0/16] Expedited grace-period changes for 4.7 "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:30 +0200
  [PATCH tip/core/rcu 07/16] rcu: Add expedited-grace-period event tracing "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:30 +0200
  [PATCH tip/core/rcu 02/16] rcu: Make expedited RCU-preempt stall warnings count accurately "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:30 +0200
  [PATCH tip/core/rcu 10/16] rcu: Shorten expedited_workdone* to exp_workdone* "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:30 +0200
  [PATCH tip/core/rcu 09/16] rcu: Force boolean subscript for expedited stall warnings "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:30 +0200
  [PATCH tip/core/rcu 08/16] rcu: Remove expedited GP funnel-lock bypass "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 05/16] rcu: Add event tracing definitions for expedited grace periods "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 03/16] rcu: Make cond_resched_rcu_qs() supply RCU-sched expedited QS "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 06/16] rcu: Add funnel-locking tracing for expedited grace periods "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 14/16] rcu: Consolidate expedited GP tracing into rcu_exp_gp_seq_snap() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 01/16] rcu: Make expedited RCU-sched grace period immediately detect idle "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 15/16] rcu: Consolidate expedited GP code into exp_funnel_lock() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 16/16] rcu: Overlap wakeups with next expedited grace period "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 12/16] rcu: Add exp_funnel_lock() fastpath "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 11/16] rcu: Enforce expedited-GP fairness via funnel wait queue "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 04/16] rcu: Fix synchronize_rcu_expedited() header comment "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200
  [PATCH tip/core/rcu 13/16] rcu: Consolidate expedited GP code into rcu_exp_wait_wake() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:40 +0200

csiph-web