percpu_ref: implement percpu_ref_is_dying()
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)
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>
include/linux/percpu-refcount.h

index 6a7a670366ab1c7dcd9b633d96ea1cf4d5019f75..12c9b485beb718241f0346a261462d82939e266b 100644 (file)
@@ -294,6 +294,20 @@ static inline void percpu_ref_put(struct percpu_ref *ref)
        percpu_ref_put_many(ref, 1);
 }
 
+/**
+ * percpu_ref_is_dying - test whether a percpu refcount is dying or dead
+ * @ref: percpu_ref to test
+ *
+ * Returns %true if @ref is dying or dead.
+ *
+ * This function is safe to call as long as @ref is between init and exit
+ * and the caller is responsible for synchronizing against state changes.
+ */
+static inline bool percpu_ref_is_dying(struct percpu_ref *ref)
+{
+       return ref->percpu_count_ptr & __PERCPU_REF_DEAD;
+}
+
 /**
  * percpu_ref_is_zero - test whether a percpu refcount reached zero
  * @ref: percpu_ref to test
This page took 0.044285 seconds and 5 git commands to generate.