diff options
| author | Tejun Heo <tj@kernel.org> | 2015-01-06 10:26:10 -0500 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2015-01-06 10:26:10 -0500 |
| commit | 4c907baf36d8339f393bb576d0bab29194d0e6ad (patch) | |
| tree | 86a550f40df9f004913f5b6db4b1e3b69e7d040e | |
| parent | 6810e4a394f9d781050107529b8d1465c00b7b13 (diff) | |
percpu_ref: implement percpu_ref_is_dying()
Implement percpu_ref_is_dying() which tests whether the ref is dying
or dead. This is useful to determine the current state when a
percpu_ref is used as a cyclic on/off switch via kill and reinit.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Kent Overstreet <kmo@daterainc.com>
| -rw-r--r-- | include/linux/percpu-refcount.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index 6a7a670366ab..12c9b485beb7 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h | |||
| @@ -295,6 +295,20 @@ static inline void percpu_ref_put(struct percpu_ref *ref) | |||
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | /** | 297 | /** |
| 298 | * percpu_ref_is_dying - test whether a percpu refcount is dying or dead | ||
| 299 | * @ref: percpu_ref to test | ||
| 300 | * | ||
| 301 | * Returns %true if @ref is dying or dead. | ||
| 302 | * | ||
| 303 | * This function is safe to call as long as @ref is between init and exit | ||
| 304 | * and the caller is responsible for synchronizing against state changes. | ||
| 305 | */ | ||
| 306 | static inline bool percpu_ref_is_dying(struct percpu_ref *ref) | ||
| 307 | { | ||
| 308 | return ref->percpu_count_ptr & __PERCPU_REF_DEAD; | ||
| 309 | } | ||
| 310 | |||
| 311 | /** | ||
| 298 | * percpu_ref_is_zero - test whether a percpu refcount reached zero | 312 | * percpu_ref_is_zero - test whether a percpu refcount reached zero |
| 299 | * @ref: percpu_ref to test | 313 | * @ref: percpu_ref to test |
| 300 | * | 314 | * |
