History

percpu, locking: Revert ("percpu: Replace smp_read_barrier_depends() with lockless_dereference()")

lockless_dereference() is planned to grow a sanity check to ensure that the input parameter is a pointer. __ref_is_percpu() passes in an unsinged long value which is a combination of a pointer and a flag. While it can be casted to a pointer lvalue, the casting looks messy and it's a special case anyway. Let's revert back to open-coding READ_ONCE() and explicit barrier. This doesn't cause any functional changes.

Tejun Heo committed 10 years ago

Commit ed8ebd11 parent 6e281471 file · +5 −7Browse files

Unified · Split

include/linux/percpu-refcount.h+5−7
@@ -136,14 +136,12 @@ static inline bool __ref_is_percpu(struct percpu_ref *ref, · 135 unmodified lines
136 * used as a pointer. If the compiler generates a separate fetch136 * used as a pointer. If the compiler generates a separate fetch
137 * when using it as a pointer, __PERCPU_REF_ATOMIC may be set in137 * when using it as a pointer, __PERCPU_REF_ATOMIC may be set in
138 * between contaminating the pointer value, meaning that138 * between contaminating the pointer value, meaning that
139 * ACCESS_ONCE() is required when fetching it.139 * READ_ONCE() is required when fetching it.
140 *
141 * Also, we need a data dependency barrier to be paired with
142 * smp_store_release() in __percpu_ref_switch_to_percpu().
143 *
144 * Use lockless deref which contains both.
145 */140 */
146 percpu_ptr = lockless_dereference(ref->percpu_count_ptr);141 percpu_ptr = READ_ONCE(ref->percpu_count_ptr);
142
143 /* paired with smp_store_release() in __percpu_ref_switch_to_percpu() */
144 smp_read_barrier_depends();
147 145
148 /*146 /*
149 * Theoretically, the following could test just ATOMIC; however,147 * Theoretically, the following could test just ATOMIC; however,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t