[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250206175114.1974171-10-bvanassche@acm.org>
Date: Thu, 6 Feb 2025 09:50:50 -0800
From: Bart Van Assche <bvanassche@....org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Will Deacon <will@...nel.org>,
Christoph Hellwig <hch@....de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Marco Elver <elver@...gle.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nathan Chancellor <nathan@...nel.org>,
Kees Cook <kees@...nel.org>,
Jann Horn <jannh@...gle.com>,
linux-kernel@...r.kernel.org,
Bart Van Assche <bvanassche@....org>
Subject: [PATCH RFC 09/33] refcount: Add thread-safety annotations in <linux/refcount.h>
Inform the Clang thread-safety analyzer that refcount_dec_and_mutex_lock()
may lock a mutex.
Cc: Will Deacon <will@...nel.org>
Signed-off-by: Bart Van Assche <bvanassche@....org>
---
include/linux/refcount.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/refcount.h b/include/linux/refcount.h
index 35f039ecb272..dd854ad27df8 100644
--- a/include/linux/refcount.h
+++ b/include/linux/refcount.h
@@ -98,6 +98,7 @@
#include <linux/limits.h>
#include <linux/refcount_types.h>
#include <linux/spinlock_types.h>
+#include <linux/thread_safety.h>
struct mutex;
@@ -353,7 +354,9 @@ static inline void refcount_dec(refcount_t *r)
extern __must_check bool refcount_dec_if_one(refcount_t *r);
extern __must_check bool refcount_dec_not_one(refcount_t *r);
-extern __must_check bool refcount_dec_and_mutex_lock(refcount_t *r, struct mutex *lock) __cond_acquires(lock);
+__must_check bool refcount_dec_and_mutex_lock(refcount_t *r, struct mutex *lock)
+ __cond_acquires(lock)
+ TRY_ACQUIRE(true, *lock);
extern __must_check bool refcount_dec_and_lock(refcount_t *r, spinlock_t *lock) __cond_acquires(lock);
extern __must_check bool refcount_dec_and_lock_irqsave(refcount_t *r,
spinlock_t *lock,
Powered by blists - more mailing lists