Skip to contentSkip to conversation

futex: remove the pointer math from double_unlock_hb

PATCH In review Darren Hart 3 participants 5 messages Mar 12, 2009 – Mar 13, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: remove the pointer math from double_unlock_hb

I mistakenly included the pointer value ordering in the double_unlock_hb in my previous patch. It's only necessary in the double_lock_hb function. This patch removes it.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Rusty Russell <[email protected]>

---

 kernel/futex.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
kernel/futex.c +2 -8
index 9c97f67..2331b73 100644
@@ -658,14 +658,8 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 static inline void
 double_unlock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 {
-	if (hb1 <= hb2) {
-		spin_unlock(&hb2->lock);
-		if (hb1 < hb2)
-			spin_unlock(&hb1->lock);
-	} else { /* hb1 > hb2 */
-		spin_unlock(&hb1->lock);
-		spin_unlock(&hb2->lock);
-	}
+	spin_unlock(&hb1->lock);
+	spin_unlock(&hb2->lock);
 }
 
 /*
#1 lore raw
Commit-ID:  f061d35150003b7fd5b133d14d66a74500fdaa60
Gitweb:     http://git.kernel.org/tip/f061d35150003b7fd5b133d14d66a74500fdaa60
Author:     Darren Hart <[email protected]>
AuthorDate: Thu, 12 Mar 2009 15:11:18 -0700
Commit:     Ingo Molnar <[email protected]>
CommitDate: Fri, 13 Mar 2009 01:15:46 +0100

futex: remove the pointer math from double_unlock_hb

Impact: simplify code

I mistakenly included the pointer value ordering in the double_unlock_hb() in my previous patch. It's only necessary in the double_lock_hb() function. This patch removes it.

LKML-Reference: <20090312221118.11146.68610.stgit@Aeon>

---
 kernel/futex.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
kernel/futex.c +2 -8
index 9c97f67..2331b73 100644
@@ -658,14 +658,8 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 static inline void
 double_unlock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 {
-	if (hb1 <= hb2) {
-		spin_unlock(&hb2->lock);
-		if (hb1 < hb2)
-			spin_unlock(&hb1->lock);
-	} else { /* hb1 > hb2 */
-		spin_unlock(&hb1->lock);
-		spin_unlock(&hb2->lock);
-	}
+	spin_unlock(&hb1->lock);
+	spin_unlock(&hb2->lock);
 }
 
 /*
#2 lore raw
In reply to Darren Hart
Quoted 22 lines · Darren Hart

I mistakenly included the pointer value ordering in the double_unlock_hb in my previous patch. It's only necessary in the double_lock_hb function. This patch removes it.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Rusty Russell <[email protected]>

---

 kernel/futex.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
kernel/futex.c +0 -0
index 9c97f67..2331b73 100644
@@ -658,14 +658,8 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 static inline void
 double_unlock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 {

kernel/futex.c double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2) · line 662

Quoted 10 lines
kernel/futex.c +2 -8
-	if (hb1 <= hb2) {
-		spin_unlock(&hb2->lock);
-		if (hb1 < hb2)
-			spin_unlock(&hb1->lock);
-	} else { /* hb1 > hb2 */
-		spin_unlock(&hb1->lock);
-		spin_unlock(&hb2->lock);
-	}
+	spin_unlock(&hb1->lock);
+	spin_unlock(&hb2->lock);

This is missing the check for hb1 == hb2. As I said before:

Quoted 7 lines

Can we just put the code into double_unlock_hb() which gets replaced ?

i.e:

       spin_unlock(&hb1->lock);
       if (hb1 != hb2)
             spin_unlock(&hb2->lock);

Thanks,

tglx

#3 lore raw

[tip:core/futexes] futex: remove the pointer math from double_unlock_hb, fix

In reply to Darren Hart
Commit-ID:  88f502fedba82eff252b6420e8b8328e4ae25c67
Gitweb:     http://git.kernel.org/tip/88f502fedba82eff252b6420e8b8328e4ae25c67
Author:     Ingo Molnar <[email protected]>
AuthorDate: Fri, 13 Mar 2009 10:32:07 +0100
Commit:     Ingo Molnar <[email protected]>
CommitDate: Fri, 13 Mar 2009 10:32:07 +0100

futex: remove the pointer math from double_unlock_hb, fix

Impact: fix double unlock crash

Thomas Gleixner noticed that the simplified double_unlock_hb() became ... too unsophisticated: in the hb1 == hb2 case it will do a double unlock.

LKML-Reference: <20090312221118.11146.68610.stgit@Aeon>

---
 kernel/futex.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/futex.c +2 -1
index 2331b73..6b50a02 100644
@@ -659,7 +659,8 @@ static inline void
 double_unlock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 {
 	spin_unlock(&hb1->lock);
-	spin_unlock(&hb2->lock);
+	if (hb1 != hb2)
+		spin_unlock(&hb2->lock);
 }
 
 /*
author Acked-by
#4 lore raw

Re: [tip:core/futexes] futex: remove the pointer math from double_unlock_hb, fix

Quoted 7 lines · Ingo Molnar
Commit-ID:  88f502fedba82eff252b6420e8b8328e4ae25c67
Gitweb:     http://git.kernel.org/tip/88f502fedba82eff252b6420e8b8328e4ae25c67
Author:     Ingo Molnar <[email protected]>
AuthorDate: Fri, 13 Mar 2009 10:32:07 +0100
Commit:     Ingo Molnar <[email protected]>
CommitDate: Fri, 13 Mar 2009 10:32:07 +0100
Quoted 7 lines

futex: remove the pointer math from double_unlock_hb, fix

Impact: fix double unlock crash

Thomas Gleixner noticed that the simplified double_unlock_hb() became ... too unsophisticated: in the hb1 == hb2 case it will do a double unlock.

Gah. Thanks for catching it.

Quoted 5 lines

LKML-Reference: <20090312221118.11146.68610.stgit@Aeon>

Quoted 20 lines

---
 kernel/futex.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/futex.c +2 -1
index 2331b73..6b50a02 100644
@@ -659,7 +659,8 @@ static inline void
 double_unlock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
 {
 	spin_unlock(&hb1->lock);
-	spin_unlock(&hb2->lock);
+	if (hb1 != hb2)
+		spin_unlock(&hb2->lock);
 }
 
 /*
Signature · 3 lines
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team