lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210915141525.556892413@infradead.org>
Date:   Wed, 15 Sep 2021 16:07:25 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     andrealmeid@...labora.com, tglx@...utronix.de, mingo@...hat.com,
        dvhart@...radead.org, rostedt@...dmis.org, bigeasy@...utronix.de
Cc:     linux-kernel@...r.kernel.org, peterz@...radead.org,
        kernel@...labora.com, krisman@...labora.com,
        linux-api@...r.kernel.org, libc-alpha@...rceware.org,
        mtk.manpages@...il.com, dave@...olabs.net, arnd@...db.de
Subject: [PATCH 15/20] futex: Simplify double_lock_hb()


Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ