diff options
author | Tejun Heo <tj@kernel.org> | 2014-09-24 13:31:48 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-09-24 13:31:48 -0400 |
commit | 6251f9976af7656b6970a8820153f356430f5de2 (patch) | |
tree | aa2d83279dfb125b9bbd88083a32bfa5e99bf3da /include/linux | |
parent | a2237370194484ee6aeeff04b617e4b14d178966 (diff) |
percpu_ref: minor code and comment updates
* Some comments became stale. Updated.
* percpu_ref_tryget() unnecessarily initializes @ret. Removed.
* A blank line removed from percpu_ref_kill_rcu().
* Explicit function name in a WARN format string replaced with __func__.
* WARN_ON() in percpu_ref_reinit() converted to WARN_ON_ONCE().
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/percpu-refcount.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index f015f139d491..d44b027f74fd 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h | |||
@@ -115,8 +115,10 @@ static inline bool __pcpu_ref_alive(struct percpu_ref *ref, | |||
115 | * percpu_ref_get - increment a percpu refcount | 115 | * percpu_ref_get - increment a percpu refcount |
116 | * @ref: percpu_ref to get | 116 | * @ref: percpu_ref to get |
117 | * | 117 | * |
118 | * Analagous to atomic_inc(). | 118 | * Analagous to atomic_long_inc(). |
119 | */ | 119 | * |
120 | * This function is safe to call as long as @ref is between init and exit. | ||
121 | */ | ||
120 | static inline void percpu_ref_get(struct percpu_ref *ref) | 122 | static inline void percpu_ref_get(struct percpu_ref *ref) |
121 | { | 123 | { |
122 | unsigned long __percpu *pcpu_count; | 124 | unsigned long __percpu *pcpu_count; |
@@ -138,12 +140,12 @@ static inline void percpu_ref_get(struct percpu_ref *ref) | |||
138 | * Increment a percpu refcount unless its count already reached zero. | 140 | * Increment a percpu refcount unless its count already reached zero. |
139 | * Returns %true on success; %false on failure. | 141 | * Returns %true on success; %false on failure. |
140 | * | 142 | * |
141 | * The caller is responsible for ensuring that @ref stays accessible. | 143 | * This function is safe to call as long as @ref is between init and exit. |
142 | */ | 144 | */ |
143 | static inline bool percpu_ref_tryget(struct percpu_ref *ref) | 145 | static inline bool percpu_ref_tryget(struct percpu_ref *ref) |
144 | { | 146 | { |
145 | unsigned long __percpu *pcpu_count; | 147 | unsigned long __percpu *pcpu_count; |
146 | int ret = false; | 148 | int ret; |
147 | 149 | ||
148 | rcu_read_lock_sched(); | 150 | rcu_read_lock_sched(); |
149 | 151 | ||
@@ -166,12 +168,13 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref) | |||
166 | * Increment a percpu refcount unless it has already been killed. Returns | 168 | * Increment a percpu refcount unless it has already been killed. Returns |
167 | * %true on success; %false on failure. | 169 | * %true on success; %false on failure. |
168 | * | 170 | * |
169 | * Completion of percpu_ref_kill() in itself doesn't guarantee that tryget | 171 | * Completion of percpu_ref_kill() in itself doesn't guarantee that this |
170 | * will fail. For such guarantee, percpu_ref_kill_and_confirm() should be | 172 | * function will fail. For such guarantee, percpu_ref_kill_and_confirm() |
171 | * used. After the confirm_kill callback is invoked, it's guaranteed that | 173 | * should be used. After the confirm_kill callback is invoked, it's |
172 | * no new reference will be given out by percpu_ref_tryget(). | 174 | * guaranteed that no new reference will be given out by |
175 | * percpu_ref_tryget_live(). | ||
173 | * | 176 | * |
174 | * The caller is responsible for ensuring that @ref stays accessible. | 177 | * This function is safe to call as long as @ref is between init and exit. |
175 | */ | 178 | */ |
176 | static inline bool percpu_ref_tryget_live(struct percpu_ref *ref) | 179 | static inline bool percpu_ref_tryget_live(struct percpu_ref *ref) |
177 | { | 180 | { |
@@ -196,6 +199,8 @@ static inline bool percpu_ref_tryget_live(struct percpu_ref *ref) | |||
196 | * | 199 | * |
197 | * Decrement the refcount, and if 0, call the release function (which was passed | 200 | * Decrement the refcount, and if 0, call the release function (which was passed |
198 | * to percpu_ref_init()) | 201 | * to percpu_ref_init()) |
202 | * | ||
203 | * This function is safe to call as long as @ref is between init and exit. | ||
199 | */ | 204 | */ |
200 | static inline void percpu_ref_put(struct percpu_ref *ref) | 205 | static inline void percpu_ref_put(struct percpu_ref *ref) |
201 | { | 206 | { |
@@ -216,6 +221,8 @@ static inline void percpu_ref_put(struct percpu_ref *ref) | |||
216 | * @ref: percpu_ref to test | 221 | * @ref: percpu_ref to test |
217 | * | 222 | * |
218 | * Returns %true if @ref reached zero. | 223 | * Returns %true if @ref reached zero. |
224 | * | ||
225 | * This function is safe to call as long as @ref is between init and exit. | ||
219 | */ | 226 | */ |
220 | static inline bool percpu_ref_is_zero(struct percpu_ref *ref) | 227 | static inline bool percpu_ref_is_zero(struct percpu_ref *ref) |
221 | { | 228 | { |