[PATCH 15/20] futex: Simplify double_lock_hb()
From: Peter Zijlstra
Date: Wed Sep 15 2021 - 10:18:55 EST
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/futex/futex.h | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -316,14 +316,12 @@ extern void futex_q_unlock(struct futex_
static inline void
double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
{
- if (hb1 <= hb2) {
- spin_lock(&hb1->lock);
- if (hb1 < hb2)
- spin_lock_nested(&hb2->lock, SINGLE_DEPTH_NESTING);
- } else { /* hb1 > hb2 */
- spin_lock(&hb2->lock);
- spin_lock_nested(&hb1->lock, SINGLE_DEPTH_NESTING);
- }
+ if (hb1 > hb2)
+ swap(hb1, hb2);
+
+ spin_lock(&hb1->lock);
+ if (hb1 != hb2)
+ spin_lock_nested(&hb2->lock, SINGLE_DEPTH_NESTING);
}
static inline void