]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kref: Add context-analysis annotations
authorMarco Elver <elver@google.com>
Fri, 19 Dec 2025 15:40:05 +0000 (16:40 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 5 Jan 2026 15:43:31 +0000 (16:43 +0100)
Mark functions that conditionally acquire the passed lock.

Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20251219154418.3592607-17-elver@google.com
include/linux/kref.h

index 88e82ab1367cfcc2b5c186fc83088d2c013ceb58..9bc6abe5757248f5e6b0cc27dcc75a8804881644 100644 (file)
@@ -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);