diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-11-14 11:29:48 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-01-14 05:37:18 -0500 |
commit | 2c935bc57221cc2edc787c72ea0e2d30cdcd3d5e (patch) | |
tree | 4ccb975ac9142887b4e7e7bf1c0cca5c53d4cf99 /include/linux/sunrpc/cache.h | |
parent | 1e24edca0557dba6486d39d3c24c288475432bcf (diff) |
locking/atomic, kref: Add kref_read()
Since we need to change the implementation, stop exposing internals.
Provide kref_read() to read the current reference count; typically
used for debug messages.
Kills two anti-patterns:
atomic_read(&kref->refcount)
kref->refcount.counter
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/sunrpc/cache.h')
-rw-r--r-- | include/linux/sunrpc/cache.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 62a60eeacb0a..8a511c0985aa 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -198,7 +198,7 @@ static inline struct cache_head *cache_get(struct cache_head *h) | |||
198 | 198 | ||
199 | static inline void cache_put(struct cache_head *h, struct cache_detail *cd) | 199 | static inline void cache_put(struct cache_head *h, struct cache_detail *cd) |
200 | { | 200 | { |
201 | if (atomic_read(&h->ref.refcount) <= 2 && | 201 | if (kref_read(&h->ref) <= 2 && |
202 | h->expiry_time < cd->nextcheck) | 202 | h->expiry_time < cd->nextcheck) |
203 | cd->nextcheck = h->expiry_time; | 203 | cd->nextcheck = h->expiry_time; |
204 | kref_put(&h->ref, cd->cache_put); | 204 | kref_put(&h->ref, cd->cache_put); |