diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2016-03-16 16:22:53 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2016-03-31 16:34:09 -0400 |
commit | 356051e1de3cf65575da4ee92d1f5cee86677ee2 (patch) | |
tree | 498fde3d22598558fc41ce20ebfb183d014b9c4f /kernel/rcu/tree.c | |
parent | f6a12f34a448cc8a624070fd365c29c890138a48 (diff) |
rcu: Add exp_funnel_lock() fastpath
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>
Diffstat (limited to 'kernel/rcu/tree.c')
-rw-r--r-- | kernel/rcu/tree.c | 10 |
1 files changed, 10 insertions, 0 deletions
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) | |||
3603 | { | 3603 | { |
3604 | struct rcu_data *rdp = per_cpu_ptr(rsp->rda, raw_smp_processor_id()); | 3604 | struct rcu_data *rdp = per_cpu_ptr(rsp->rda, raw_smp_processor_id()); |
3605 | struct rcu_node *rnp = rdp->mynode; | 3605 | struct rcu_node *rnp = rdp->mynode; |
3606 | struct rcu_node *rnp_root = rcu_get_root(rsp); | ||
3607 | |||
3608 | /* Low-contention fastpath. */ | ||
3609 | if (ULONG_CMP_LT(READ_ONCE(rnp->exp_seq_rq), s) && | ||
3610 | (rnp == rnp_root || | ||
3611 | ULONG_CMP_LT(READ_ONCE(rnp_root->exp_seq_rq), s)) && | ||
3612 | !mutex_is_locked(&rsp->exp_mutex) && | ||
3613 | mutex_trylock(&rsp->exp_mutex)) | ||
3614 | goto fastpath; | ||
3606 | 3615 | ||
3607 | /* | 3616 | /* |
3608 | * Each pass through the following loop works its way up | 3617 | * 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) | |||
3635 | rnp->grphi, TPS("nxtlvl")); | 3644 | rnp->grphi, TPS("nxtlvl")); |
3636 | } | 3645 | } |
3637 | mutex_lock(&rsp->exp_mutex); | 3646 | mutex_lock(&rsp->exp_mutex); |
3647 | fastpath: | ||
3638 | if (sync_exp_work_done(rsp, &rdp->exp_workdone3, s)) { | 3648 | if (sync_exp_work_done(rsp, &rdp->exp_workdone3, s)) { |
3639 | mutex_unlock(&rsp->exp_mutex); | 3649 | mutex_unlock(&rsp->exp_mutex); |
3640 | return true; | 3650 | return true; |