[Devel] [PATCH RHEL7 COMMIT] ms/percpu-refcount: use RCU-sched insted of normal RCU
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 28 03:49:25 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.3
------>
commit 932bf29b63b1e7c74669a8847d7c69cc8b8ba919
Author: Vladimir Davydov <vdavydov at parallels.com>
Date: Fri Aug 28 14:49:25 2015 +0400
ms/percpu-refcount: use RCU-sched insted of normal RCU
Patchset description:
Pulling upstream patches converting css refcnt to percpu_ref.
https://jira.sw.ru/browse/PSBM-34174
Kent Overstreet (2):
percpu: implement generic percpu refcounting
percpu-refcount: Don't use silly cmpxchg()
Tejun Heo (9):
percpu-refcount: consistently use plain (non-sched) RCU
percpu-refcount: cosmetic updates
percpu-refcount: add __must_check to percpu_ref_init() and don't use
ACCESS_ONCE() in percpu_ref_kill_rcu()
percpu-refcount: implement percpu_ref_cancel_init()
percpu-refcount: implement percpu_tryget() along with
percpu_ref_kill_and_confirm()
percpu-refcount: use RCU-sched insted of normal RCU
cgroup: reorder the operations in cgroup_destroy_locked()
cgroup: split cgroup destruction into two steps
cgroup: use percpu refcnt for cgroup_subsys_states
===
This patch description:
From: Tejun Heo <tj at kernel.org>
percpu-refcount was incorrectly using preempt_disable/enable() for RCU
critical sections against call_rcu(). 6a24474da8 ("percpu-refcount:
consistently use plain (non-sched) RCU") fixed it by converting the
preepmtion operations with rcu_read_[un]lock() citing that there isn't
any advantage in using sched-RCU over using the usual one; however,
rcu_read_[un]lock() for the preemptible RCU implementation -
CONFIG_TREE_PREEMPT_RCU, chosen when CONFIG_PREEMPT - are slightly
more expensive than preempt_disable/enable().
In a contrived microbench which repeats the followings,
- percpu_ref_get()
- copy 32 bytes of data into percpu buffer
- percpu_put_get()
- copy 32 bytes of data into percpu buffer
rcu_read_[un]lock() used in percpu_ref_get/put() makes it go slower by
about 15% when compared to using sched-RCU.
As the RCU critical sections are extremely short, using sched-RCU
shouldn't have any latency implications. Convert to RCU-sched.
Signed-off-by: Tejun Heo <tj at kernel.org>
Acked-by: Kent Overstreet <koverstreet at google.com>
Acked-by: "Paul E. McKenney" <paulmck at linux.vnet.ibm.com>
Cc: Michal Hocko <mhocko at suse.cz>
Cc: Rusty Russell <rusty at rustcorp.com.au>
(cherry picked from commit a4244454df1296e90cc961c1b636b1176ef0d9a0)
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
include/linux/percpu-refcount.h | 12 ++++++------
lib/percpu-refcount.c | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
index dd2a086..95961f0 100644
--- a/include/linux/percpu-refcount.h
+++ b/include/linux/percpu-refcount.h
@@ -105,7 +105,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
{
unsigned __percpu *pcpu_count;
- rcu_read_lock();
+ rcu_read_lock_sched();
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
@@ -114,7 +114,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
else
atomic_inc(&ref->count);
- rcu_read_unlock();
+ rcu_read_unlock_sched();
}
/**
@@ -134,7 +134,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref)
unsigned __percpu *pcpu_count;
int ret = false;
- rcu_read_lock();
+ rcu_read_lock_sched();
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
@@ -143,7 +143,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref)
ret = true;
}
- rcu_read_unlock();
+ rcu_read_unlock_sched();
return ret;
}
@@ -159,7 +159,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
{
unsigned __percpu *pcpu_count;
- rcu_read_lock();
+ rcu_read_lock_sched();
pcpu_count = ACCESS_ONCE(ref->pcpu_count);
@@ -168,7 +168,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
else if (unlikely(atomic_dec_and_test(&ref->count)))
ref->release(ref);
- rcu_read_unlock();
+ rcu_read_unlock_sched();
}
#endif
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
index 8bf9e71..7deeb62 100644
--- a/lib/percpu-refcount.c
+++ b/lib/percpu-refcount.c
@@ -154,5 +154,5 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
(((unsigned long) ref->pcpu_count)|PCPU_REF_DEAD);
ref->confirm_kill = confirm_kill;
- call_rcu(&ref->rcu, percpu_ref_kill_rcu);
+ call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu);
}
More information about the Devel
mailing list