Skip to content

Commit

Permalink
percpu_ref: implement percpu_ref_is_dying()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tejun Heo committed Jan 6, 2015
1 parent 6810e4a commit 4c907ba
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/linux/percpu-refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c907ba

Please sign in to comment.