[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1432575859.6866.34.camel@odin.com>
Date: Mon, 25 May 2015 20:44:19 +0300
From: Kirill Tkhai <ktkhai@...n.com>
To: <linux-kernel@...r.kernel.org>
CC: Oleg Nesterov <oleg@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...hat.com>,
"Peter Zijlstra" <peterz@...radead.org>,
Michal Hocko <mhocko@...e.cz>,
"Rik van Riel" <riel@...hat.com>,
Ionut Alexa <ionut.m.alexa@...il.com>,
Peter Hurley <peter@...leysoftware.com>,
Kirill Tkhai <tkhai@...dex.ru>
Subject: [PATCH RFC 02/13] rwlock_t: Implement double_write_{,un}lock()
New helpers for locking two locks at a time.
Signed-off-by: Kirill Tkhai <ktkhai@...n.com>
---
include/linux/spinlock.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 3e18379..e1e3054 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -426,4 +426,23 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
#define atomic_dec_and_lock(atomic, lock) \
__cond_lock(lock, _atomic_dec_and_lock(atomic, lock))
+static inline void double_write_lock(rwlock_t *lock1, rwlock_t *lock2)
+{
+ if (lock1 < lock2) {
+ write_lock(lock1);
+ write_lock(lock2);
+ } else if (lock1 > lock2) {
+ write_lock(lock2);
+ write_lock(lock1);
+ } else {
+ write_lock(lock1);
+ }
+}
+static inline void double_write_unlock(rwlock_t *lock1, rwlock_t *lock2)
+{
+ if (lock2 != lock1)
+ write_unlock(lock2);
+ write_unlock(lock1);
+}
+
#endif /* __LINUX_SPINLOCK_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists