From: Tejun Heo Date: Wed, 4 Jun 2014 16:50:14 +0000 (-0400) Subject: Merge branch 'for-3.15-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj... X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=315c5554c406fdad404a99dfefc931db0df80692;p=openwrt%2Fstaging%2Fblogic.git Merge branch 'for-3.15-fixes' of git://git./linux/kernel/git/tj/percpu.git into for-3.16 Pull percpu/for-3.15-fixes into percpu/for-3.16 to receive 0c36b390a546 ("percpu-refcount: fix usage of this_cpu_ops"). The merge doesn't produce any conflict but the automatic merge is still incorrect because 4fb6e25049cb ("percpu-refcount: implement percpu_ref_tryget()") added another use of __this_cpu_inc() which should also be converted to this_cpu_ince(). This commit pulls in percpu/for-3.15-fixes and converts the newly added __this_cpu_inc() to this_cpu_inc(). Signed-off-by: Tejun Heo --- 315c5554c406fdad404a99dfefc931db0df80692 diff --cc include/linux/percpu-refcount.h index dba35c411e8c,0afb48fd449d..5d8920e23073 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h @@@ -121,36 -121,6 +121,36 @@@ static inline void percpu_ref_get(struc * percpu_ref_tryget - try to increment a percpu refcount * @ref: percpu_ref to try-get * + * Increment a percpu refcount unless its count already reached zero. + * Returns %true on success; %false on failure. + * + * The caller is responsible for ensuring that @ref stays accessible. + */ +static inline bool percpu_ref_tryget(struct percpu_ref *ref) +{ + unsigned __percpu *pcpu_count; + int ret = false; + + rcu_read_lock_sched(); + + pcpu_count = ACCESS_ONCE(ref->pcpu_count); + + if (likely(REF_STATUS(pcpu_count) == PCPU_REF_PTR)) { - __this_cpu_inc(*pcpu_count); ++ this_cpu_inc(*pcpu_count); + ret = true; + } else { + ret = atomic_inc_not_zero(&ref->count); + } + + rcu_read_unlock_sched(); + + return ret; +} + +/** + * percpu_ref_tryget_live - try to increment a live percpu refcount + * @ref: percpu_ref to try-get + * * Increment a percpu refcount unless it has already been killed. Returns * %true on success; %false on failure. *