Commit 8578bdf8 authored by Andi Kleen's avatar Andi Kleen Committed by Andi Kleen

[PATCH] Don't use lock section for mutexes and semaphores

Lock sections cannot be handled by the dwarf2 unwinder.

Disadvantage is a taken branch in the hot path.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
parent 7ca2b49b
...@@ -25,13 +25,9 @@ do { \ ...@@ -25,13 +25,9 @@ do { \
\ \
__asm__ __volatile__( \ __asm__ __volatile__( \
LOCK_PREFIX " decl (%%rdi) \n" \ LOCK_PREFIX " decl (%%rdi) \n" \
" js 2f \n" \ " jns 1f \n" \
"1: \n" \ " call "#fail_fn" \n" \
\ "1:" \
LOCK_SECTION_START("") \
"2: call "#fail_fn" \n" \
" jmp 1b \n" \
LOCK_SECTION_END \
\ \
:"=D" (dummy) \ :"=D" (dummy) \
: "D" (v) \ : "D" (v) \
...@@ -75,13 +71,9 @@ do { \ ...@@ -75,13 +71,9 @@ do { \
\ \
__asm__ __volatile__( \ __asm__ __volatile__( \
LOCK_PREFIX " incl (%%rdi) \n" \ LOCK_PREFIX " incl (%%rdi) \n" \
" jle 2f \n" \ " jg 1f \n" \
"1: \n" \ " call "#fail_fn" \n" \
\ "1: " \
LOCK_SECTION_START("") \
"2: call "#fail_fn" \n" \
" jmp 1b \n" \
LOCK_SECTION_END \
\ \
:"=D" (dummy) \ :"=D" (dummy) \
: "D" (v) \ : "D" (v) \
......
...@@ -107,12 +107,9 @@ static inline void down(struct semaphore * sem) ...@@ -107,12 +107,9 @@ static inline void down(struct semaphore * sem)
__asm__ __volatile__( __asm__ __volatile__(
"# atomic down operation\n\t" "# atomic down operation\n\t"
LOCK_PREFIX "decl %0\n\t" /* --sem->count */ LOCK_PREFIX "decl %0\n\t" /* --sem->count */
"js 2f\n" "jns 1f\n\t"
"1:\n" "call __down_failed\n"
LOCK_SECTION_START("") "1:"
"2:\tcall __down_failed\n\t"
"jmp 1b\n"
LOCK_SECTION_END
:"=m" (sem->count) :"=m" (sem->count)
:"D" (sem) :"D" (sem)
:"memory"); :"memory");
...@@ -130,14 +127,11 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -130,14 +127,11 @@ static inline int down_interruptible(struct semaphore * sem)
__asm__ __volatile__( __asm__ __volatile__(
"# atomic interruptible down operation\n\t" "# atomic interruptible down operation\n\t"
"xorl %0,%0\n\t"
LOCK_PREFIX "decl %1\n\t" /* --sem->count */ LOCK_PREFIX "decl %1\n\t" /* --sem->count */
"js 2f\n\t" "jns 2f\n\t"
"xorl %0,%0\n" "call __down_failed_interruptible\n"
"1:\n" "2:\n"
LOCK_SECTION_START("")
"2:\tcall __down_failed_interruptible\n\t"
"jmp 1b\n"
LOCK_SECTION_END
:"=a" (result), "=m" (sem->count) :"=a" (result), "=m" (sem->count)
:"D" (sem) :"D" (sem)
:"memory"); :"memory");
...@@ -154,14 +148,11 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -154,14 +148,11 @@ static inline int down_trylock(struct semaphore * sem)
__asm__ __volatile__( __asm__ __volatile__(
"# atomic interruptible down operation\n\t" "# atomic interruptible down operation\n\t"
"xorl %0,%0\n\t"
LOCK_PREFIX "decl %1\n\t" /* --sem->count */ LOCK_PREFIX "decl %1\n\t" /* --sem->count */
"js 2f\n\t" "jns 2f\n\t"
"xorl %0,%0\n" "call __down_failed_trylock\n\t"
"1:\n" "2:\n"
LOCK_SECTION_START("")
"2:\tcall __down_failed_trylock\n\t"
"jmp 1b\n"
LOCK_SECTION_END
:"=a" (result), "=m" (sem->count) :"=a" (result), "=m" (sem->count)
:"D" (sem) :"D" (sem)
:"memory","cc"); :"memory","cc");
...@@ -179,12 +170,9 @@ static inline void up(struct semaphore * sem) ...@@ -179,12 +170,9 @@ static inline void up(struct semaphore * sem)
__asm__ __volatile__( __asm__ __volatile__(
"# atomic up operation\n\t" "# atomic up operation\n\t"
LOCK_PREFIX "incl %0\n\t" /* ++sem->count */ LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
"jle 2f\n" "jg 1f\n\t"
"1:\n" "call __up_wakeup\n"
LOCK_SECTION_START("") "1:"
"2:\tcall __up_wakeup\n\t"
"jmp 1b\n"
LOCK_SECTION_END
:"=m" (sem->count) :"=m" (sem->count)
:"D" (sem) :"D" (sem)
:"memory"); :"memory");
......
...@@ -22,14 +22,13 @@ ...@@ -22,14 +22,13 @@
#define __raw_spin_lock_string \ #define __raw_spin_lock_string \
"\n1:\t" \ "\n1:\t" \
LOCK_PREFIX " ; decl %0\n\t" \ LOCK_PREFIX " ; decl %0\n\t" \
"js 2f\n" \ "jns 2f\n" \
LOCK_SECTION_START("") \ "3:\n" \
"2:\t" \
"rep;nop\n\t" \ "rep;nop\n\t" \
"cmpl $0,%0\n\t" \ "cmpl $0,%0\n\t" \
"jle 2b\n\t" \ "jle 3b\n\t" \
"jmp 1b\n" \ "jmp 1b\n" \
LOCK_SECTION_END "2:\t" \
#define __raw_spin_lock_string_up \ #define __raw_spin_lock_string_up \
"\n\tdecl %0" "\n\tdecl %0"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment