[Devel] [PATCH RHEL7 COMMIT] ms/percpu-refcount: consistently use plain (non-sched) RCU

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 28 03:49:22 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 41721ced765e1156651d31c8b9deb0111340e984
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Fri Aug 28 14:49:22 2015 +0400

    ms/percpu-refcount: consistently use plain (non-sched) 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_ref_get/put() are using preempt_disable/enable() while
    percpu_ref_kill() is using plain call_rcu() instead of
    call_rcu_sched().  This is buggy as grace periods of the two may not
    match.  Fix it by using plain RCU in percpu_ref_get/put().
    
    (I suggested using sched RCU in the first place but there's no actual
     benefit in doing so unless we're gonna introduce different variants
     of get/put to be called while preemption is alredy disabled, which we
     definitely shouldn't.)
    
    Signed-off-by: Tejun Heo <tj at kernel.org>
    Reported-by: Rusty Russell <rusty at rustcorp.com.au>
    Acked-by: Kent Overstreet <koverstreet at google.com>
    (cherry picked from commit 6a24474da83ea7c8b7d32f05f858b1259994067a)
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 include/linux/percpu-refcount.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
index 24b31ef..abe1411 100644
--- a/include/linux/percpu-refcount.h
+++ b/include/linux/percpu-refcount.h
@@ -85,7 +85,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
 {
 	unsigned __percpu *pcpu_count;
 
-	preempt_disable();
+	rcu_read_lock();
 
 	pcpu_count = ACCESS_ONCE(ref->pcpu_count);
 
@@ -94,7 +94,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
 	else
 		atomic_inc(&ref->count);
 
-	preempt_enable();
+	rcu_read_unlock();
 }
 
 /**
@@ -107,7 +107,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
 {
 	unsigned __percpu *pcpu_count;
 
-	preempt_disable();
+	rcu_read_lock();
 
 	pcpu_count = ACCESS_ONCE(ref->pcpu_count);
 
@@ -116,7 +116,7 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
 	else if (unlikely(atomic_dec_and_test(&ref->count)))
 		ref->release(ref);
 
-	preempt_enable();
+	rcu_read_unlock();
 }
 
 #endif



More information about the Devel mailing list