diff options
Diffstat (limited to 'lib/refcount.c')
-rw-r--r-- | lib/refcount.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/refcount.c b/lib/refcount.c index ebcf8cd49e05..6e904af0fb3e 100644 --- a/lib/refcount.c +++ b/lib/refcount.c | |||
@@ -33,6 +33,9 @@ | |||
33 | * Note that the allocator is responsible for ordering things between free() | 33 | * Note that the allocator is responsible for ordering things between free() |
34 | * and alloc(). | 34 | * and alloc(). |
35 | * | 35 | * |
36 | * The decrements dec_and_test() and sub_and_test() also provide acquire | ||
37 | * ordering on success. | ||
38 | * | ||
36 | */ | 39 | */ |
37 | 40 | ||
38 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
@@ -164,8 +167,8 @@ EXPORT_SYMBOL(refcount_inc_checked); | |||
164 | * at UINT_MAX. | 167 | * at UINT_MAX. |
165 | * | 168 | * |
166 | * Provides release memory ordering, such that prior loads and stores are done | 169 | * Provides release memory ordering, such that prior loads and stores are done |
167 | * before, and provides a control dependency such that free() must come after. | 170 | * before, and provides an acquire ordering on success such that free() |
168 | * See the comment on top. | 171 | * must come after. |
169 | * | 172 | * |
170 | * Use of this function is not recommended for the normal reference counting | 173 | * Use of this function is not recommended for the normal reference counting |
171 | * use case in which references are taken and released one at a time. In these | 174 | * use case in which references are taken and released one at a time. In these |
@@ -190,7 +193,12 @@ bool refcount_sub_and_test_checked(unsigned int i, refcount_t *r) | |||
190 | 193 | ||
191 | } while (!atomic_try_cmpxchg_release(&r->refs, &val, new)); | 194 | } while (!atomic_try_cmpxchg_release(&r->refs, &val, new)); |
192 | 195 | ||
193 | return !new; | 196 | if (!new) { |
197 | smp_acquire__after_ctrl_dep(); | ||
198 | return true; | ||
199 | } | ||
200 | return false; | ||
201 | |||
194 | } | 202 | } |
195 | EXPORT_SYMBOL(refcount_sub_and_test_checked); | 203 | EXPORT_SYMBOL(refcount_sub_and_test_checked); |
196 | 204 | ||
@@ -202,8 +210,8 @@ EXPORT_SYMBOL(refcount_sub_and_test_checked); | |||
202 | * decrement when saturated at UINT_MAX. | 210 | * decrement when saturated at UINT_MAX. |
203 | * | 211 | * |
204 | * Provides release memory ordering, such that prior loads and stores are done | 212 | * Provides release memory ordering, such that prior loads and stores are done |
205 | * before, and provides a control dependency such that free() must come after. | 213 | * before, and provides an acquire ordering on success such that free() |
206 | * See the comment on top. | 214 | * must come after. |
207 | * | 215 | * |
208 | * Return: true if the resulting refcount is 0, false otherwise | 216 | * Return: true if the resulting refcount is 0, false otherwise |
209 | */ | 217 | */ |