[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190214230058.196511-21-bvanassche@acm.org>
Date: Thu, 14 Feb 2019 15:00:55 -0800
From: Bart Van Assche <bvanassche@....org>
To: peterz@...radead.org
Cc: mingo@...hat.com, will.deacon@....com, tj@...nel.org,
longman@...hat.com, johannes.berg@...el.com,
linux-kernel@...r.kernel.org, Bart Van Assche <bvanassche@....org>,
Ingo Molnar <mingo@...nel.org>
Subject: [PATCH v7 20/23] locking/spinlock: Introduce spin_lock_init_key()
Some code uses nested locking of different spinlocks that share a
lock class. That results in false positives because spin_lock_init()
forces these instances to share a lock class. Make it possible to
avoid these false positives by allowing spinlock users to specify
the lock class at runtime.
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Will Deacon <will.deacon@....com>
Signed-off-by: Bart Van Assche <bvanassche@....org>
---
include/linux/spinlock.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index e089157dcf97..09b3e27ed21d 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -99,10 +99,19 @@ do { \
\
__raw_spin_lock_init((lock), #lock, &__key); \
} while (0)
+#define raw_spin_lock_init_key(lock, key) \
+ __raw_spin_lock_init((lock), #lock, key)
#else
+
# define raw_spin_lock_init(lock) \
do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)
+static inline void raw_spin_lock_init_key(struct raw_spinlock *lock,
+ struct lock_class_key *key)
+{
+ *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock);
+}
+
#endif
#define raw_spin_is_locked(lock) arch_spin_is_locked(&(lock)->raw_lock)
@@ -324,6 +333,12 @@ do { \
raw_spin_lock_init(&(_lock)->rlock); \
} while (0)
+#define spin_lock_init_key(_lock, _key) \
+do { \
+ spinlock_check(_lock); \
+ raw_spin_lock_init_key(&(_lock)->rlock, _key); \
+} while (0)
+
static __always_inline void spin_lock(spinlock_t *lock)
{
raw_spin_lock(&lock->rlock);
--
2.21.0.rc0.258.g878e2cd30e-goog
Powered by blists - more mailing lists