lockref: add a __cond_lock annotation for lockref_put_or_lock
Changes
2 files changed · +3 −0
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| include/linux/lockref.h | modified | +2 | −0 | View file |
| lib/lockref.c | modified | +1 | −0 | View file |
include/linux/lockref.h
View filediff --git a/include/linux/lockref.h b/include/linux/lockref.h
index 676721e..815d871 100644
--- a/include/linux/lockref.h
+++ b/include/linux/lockref.h
@@ -50,6 +50,8 @@ void lockref_get(struct lockref *lockref);
int lockref_put_return(struct lockref *lockref);
bool lockref_get_not_zero(struct lockref *lockref);
bool lockref_put_or_lock(struct lockref *lockref);
+#define lockref_put_or_lock(_lockref) \
+ (!__cond_lock((_lockref)->lock, !lockref_put_or_lock(_lockref)))
void lockref_mark_dead(struct lockref *lockref);
bool lockref_get_not_dead(struct lockref *lockref);
lib/lockref.c
View filediff --git a/lib/lockref.c b/lib/lockref.c
index 5d8e3ef..9210fc6 100644
--- a/lib/lockref.c
+++ b/lib/lockref.c
@@ -105,6 +105,7 @@ EXPORT_SYMBOL(lockref_put_return);
* @lockref: pointer to lockref structure
* Return: 1 if count updated successfully or 0 if count <= 1 and lock taken
*/
+#undef lockref_put_or_lock
bool lockref_put_or_lock(struct lockref *lockref)
{
CMPXCHG_LOOP(