]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - include/linux/percpu-refcount.h
percpu_ref: remove unnecessary ACCESS_ONCE() in percpu_ref_tryget_live()
authorTejun Heo <tj@kernel.org>
Tue, 6 Jan 2015 15:26:10 +0000 (10:26 -0500)
committerTejun Heo <tj@kernel.org>
Tue, 6 Jan 2015 15:26:10 +0000 (10:26 -0500)
commit6810e4a394f9d781050107529b8d1465c00b7b13
treebff56a1838d3c0d2e7d2e89a109ba3b739b9f666
parent97bf6af1f928216fd6c5a66e8a57bfa95a659672
percpu_ref: remove unnecessary ACCESS_ONCE() in percpu_ref_tryget_live()

__ref_is_percpu() needs the implied ACCESS_ONCE() in
lockless_dereference() on @ref->percpu_count_ptr because the value is
tested for !__PERCPU_REF_ATOMIC, which may be set asynchronously, and
then used as a pointer.  If the compiler generates a separate fetch
when using it as a pointer, __PERCPU_REF_ATOMIC may be set in between
contaminating the pointer value.

percpu_ref_tryget_live() also uses ACCESS_ONCE() to test
__PERCPU_REF_DEAD; however, there's no reason for this.  I just copied
ACCESS_ONCE() usage blindly from __ref_is_percpu().  All it does is
confusing people trying to understand what's going on.

This patch removes the unnecessary ACCESS_ONCE() usage from
percpu_ref_tryget_live() and adds a comment explaining why
__ref_is_percpu() needs it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Kent Overstreet <kmo@daterainc.com>
include/linux/percpu-refcount.h