From: Marco Elver Date: Fri, 19 Dec 2025 15:40:05 +0000 (+0100) Subject: kref: Add context-analysis annotations X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e256db9325e75e9f000ddd64e4f1dbd2a6d8acd;p=thirdparty%2Fkernel%2Flinux.git kref: Add context-analysis annotations Mark functions that conditionally acquire the passed lock. Signed-off-by: Marco Elver Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/20251219154418.3592607-17-elver@google.com --- diff --git a/include/linux/kref.h b/include/linux/kref.h index 88e82ab1367cf..9bc6abe575724 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h @@ -81,6 +81,7 @@ static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref) static inline int kref_put_mutex(struct kref *kref, void (*release)(struct kref *kref), struct mutex *mutex) + __cond_acquires(true, mutex) { if (refcount_dec_and_mutex_lock(&kref->refcount, mutex)) { release(kref); @@ -102,6 +103,7 @@ static inline int kref_put_mutex(struct kref *kref, static inline int kref_put_lock(struct kref *kref, void (*release)(struct kref *kref), spinlock_t *lock) + __cond_acquires(true, lock) { if (refcount_dec_and_lock(&kref->refcount, lock)) { release(kref);