Skip to contentSkip to conversation

x86: fix spin_is_contended()

PATCH Applied Jan Beulich 3 participants 3 messages Aug 4, 2008 – Aug 15, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fix spin_is_contended()

The masked difference is what needs to be compared against 1, rather than the difference of masked values (which can be negative).

---
 include/asm-x86/spinlock.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-x86/spinlock.h +2 -2
@@ -65,7 +65,7 @@ static inline int __ticket_spin_is_conte
 {
 	int tmp = ACCESS_ONCE(lock->slock);
 
-	return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1;
+	return (((tmp >> 8) - tmp) & 0xff) > 1;
 }
 
 static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
@@ -127,7 +127,7 @@ static inline int __ticket_spin_is_conte
 {
 	int tmp = ACCESS_ONCE(lock->slock);
 
-	return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1;
+	return (((tmp >> 16) - tmp) & 0xffff) > 1;
 }
 
 static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
#1 lore raw
Quoted 2 lines · Jan Beulich

The masked difference is what needs to be compared against 1, rather than the difference of masked values (which can be negative).

Dang, thanks.

Quoted 30 lines
---
 include/asm-x86/spinlock.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-x86/spinlock.h +2 -2
@@ -65,7 +65,7 @@ static inline int __ticket_spin_is_conte
 {
 	int tmp = ACCESS_ONCE(lock->slock);
 
-	return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1;
+	return (((tmp >> 8) - tmp) & 0xff) > 1;
 }
 
 static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
@@ -127,7 +127,7 @@ static inline int __ticket_spin_is_conte
 {
 	int tmp = ACCESS_ONCE(lock->slock);
 
-	return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1;
+	return (((tmp >> 16) - tmp) & 0xffff) > 1;
 }
 
 static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
Acked-by Nick Piggin Applied
#2 lore raw
Quoted 5 lines · Nick Piggin
Quoted 2 lines · Jan Beulich

The masked difference is what needs to be compared against 1, rather than the difference of masked values (which can be negative).

Dang, thanks.

applied to tip/x86/urgent, with your:

thanks Jan.

Ingo