diff options
author | Andi Kleen <ak@suse.de> | 2006-09-26 04:52:32 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-09-26 04:52:32 -0400 |
commit | 8578bdf835d6d6ece6718858d351456367b8a5cf (patch) | |
tree | 5bf4aa72bda1f5c508d955a2d32b5d292f8bd5a7 | |
parent | 7ca2b49b06a6d26e89e3535653889f1d7892b085 (diff) |
[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: Andi Kleen <ak@suse.de>
-rw-r--r-- | include/asm-x86_64/mutex.h | 20 | ||||
-rw-r--r-- | include/asm-x86_64/semaphore.h | 40 | ||||
-rw-r--r-- | include/asm-x86_64/spinlock.h | 9 |
3 files changed, 24 insertions, 45 deletions
diff --git a/include/asm-x86_64/mutex.h b/include/asm-x86_64/mutex.h index 06fab6de2a88..16396b1de3e4 100644 --- a/include/asm-x86_64/mutex.h +++ b/include/asm-x86_64/mutex.h | |||
@@ -25,13 +25,9 @@ do { \ | |||
25 | \ | 25 | \ |
26 | __asm__ __volatile__( \ | 26 | __asm__ __volatile__( \ |
27 | LOCK_PREFIX " decl (%%rdi) \n" \ | 27 | LOCK_PREFIX " decl (%%rdi) \n" \ |
28 | " js 2f \n" \ | 28 | " jns 1f \n" \ |
29 | "1: \n" \ | 29 | " call "#fail_fn" \n" \ |
30 | \ | 30 | "1:" \ |
31 | LOCK_SECTION_START("") \ | ||
32 | "2: call "#fail_fn" \n" \ | ||
33 | " jmp 1b \n" \ | ||
34 | LOCK_SECTION_END \ | ||
35 | \ | 31 | \ |
36 | :"=D" (dummy) \ | 32 | :"=D" (dummy) \ |
37 | : "D" (v) \ | 33 | : "D" (v) \ |
@@ -75,13 +71,9 @@ do { \ | |||
75 | \ | 71 | \ |
76 | __asm__ __volatile__( \ | 72 | __asm__ __volatile__( \ |
77 | LOCK_PREFIX " incl (%%rdi) \n" \ | 73 | LOCK_PREFIX " incl (%%rdi) \n" \ |
78 | " jle 2f \n" \ | 74 | " jg 1f \n" \ |
79 | "1: \n" \ | 75 | " call "#fail_fn" \n" \ |
80 | \ | 76 | "1: " \ |
81 | LOCK_SECTION_START("") \ | ||
82 | "2: call "#fail_fn" \n" \ | ||
83 | " jmp 1b \n" \ | ||
84 | LOCK_SECTION_END \ | ||
85 | \ | 77 | \ |
86 | :"=D" (dummy) \ | 78 | :"=D" (dummy) \ |
87 | : "D" (v) \ | 79 | : "D" (v) \ |
diff --git a/include/asm-x86_64/semaphore.h b/include/asm-x86_64/semaphore.h index 064df08b9a0f..107bd90429e8 100644 --- a/include/asm-x86_64/semaphore.h +++ b/include/asm-x86_64/semaphore.h | |||
@@ -107,12 +107,9 @@ static inline void down(struct semaphore * sem) | |||
107 | __asm__ __volatile__( | 107 | __asm__ __volatile__( |
108 | "# atomic down operation\n\t" | 108 | "# atomic down operation\n\t" |
109 | LOCK_PREFIX "decl %0\n\t" /* --sem->count */ | 109 | LOCK_PREFIX "decl %0\n\t" /* --sem->count */ |
110 | "js 2f\n" | 110 | "jns 1f\n\t" |
111 | "1:\n" | 111 | "call __down_failed\n" |
112 | LOCK_SECTION_START("") | 112 | "1:" |
113 | "2:\tcall __down_failed\n\t" | ||
114 | "jmp 1b\n" | ||
115 | LOCK_SECTION_END | ||
116 | :"=m" (sem->count) | 113 | :"=m" (sem->count) |
117 | :"D" (sem) | 114 | :"D" (sem) |
118 | :"memory"); | 115 | :"memory"); |
@@ -130,14 +127,11 @@ static inline int down_interruptible(struct semaphore * sem) | |||
130 | 127 | ||
131 | __asm__ __volatile__( | 128 | __asm__ __volatile__( |
132 | "# atomic interruptible down operation\n\t" | 129 | "# atomic interruptible down operation\n\t" |
130 | "xorl %0,%0\n\t" | ||
133 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ | 131 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ |
134 | "js 2f\n\t" | 132 | "jns 2f\n\t" |
135 | "xorl %0,%0\n" | 133 | "call __down_failed_interruptible\n" |
136 | "1:\n" | 134 | "2:\n" |
137 | LOCK_SECTION_START("") | ||
138 | "2:\tcall __down_failed_interruptible\n\t" | ||
139 | "jmp 1b\n" | ||
140 | LOCK_SECTION_END | ||
141 | :"=a" (result), "=m" (sem->count) | 135 | :"=a" (result), "=m" (sem->count) |
142 | :"D" (sem) | 136 | :"D" (sem) |
143 | :"memory"); | 137 | :"memory"); |
@@ -154,14 +148,11 @@ static inline int down_trylock(struct semaphore * sem) | |||
154 | 148 | ||
155 | __asm__ __volatile__( | 149 | __asm__ __volatile__( |
156 | "# atomic interruptible down operation\n\t" | 150 | "# atomic interruptible down operation\n\t" |
151 | "xorl %0,%0\n\t" | ||
157 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ | 152 | LOCK_PREFIX "decl %1\n\t" /* --sem->count */ |
158 | "js 2f\n\t" | 153 | "jns 2f\n\t" |
159 | "xorl %0,%0\n" | 154 | "call __down_failed_trylock\n\t" |
160 | "1:\n" | 155 | "2:\n" |
161 | LOCK_SECTION_START("") | ||
162 | "2:\tcall __down_failed_trylock\n\t" | ||
163 | "jmp 1b\n" | ||
164 | LOCK_SECTION_END | ||
165 | :"=a" (result), "=m" (sem->count) | 156 | :"=a" (result), "=m" (sem->count) |
166 | :"D" (sem) | 157 | :"D" (sem) |
167 | :"memory","cc"); | 158 | :"memory","cc"); |
@@ -179,12 +170,9 @@ static inline void up(struct semaphore * sem) | |||
179 | __asm__ __volatile__( | 170 | __asm__ __volatile__( |
180 | "# atomic up operation\n\t" | 171 | "# atomic up operation\n\t" |
181 | LOCK_PREFIX "incl %0\n\t" /* ++sem->count */ | 172 | LOCK_PREFIX "incl %0\n\t" /* ++sem->count */ |
182 | "jle 2f\n" | 173 | "jg 1f\n\t" |
183 | "1:\n" | 174 | "call __up_wakeup\n" |
184 | LOCK_SECTION_START("") | 175 | "1:" |
185 | "2:\tcall __up_wakeup\n\t" | ||
186 | "jmp 1b\n" | ||
187 | LOCK_SECTION_END | ||
188 | :"=m" (sem->count) | 176 | :"=m" (sem->count) |
189 | :"D" (sem) | 177 | :"D" (sem) |
190 | :"memory"); | 178 | :"memory"); |
diff --git a/include/asm-x86_64/spinlock.h b/include/asm-x86_64/spinlock.h index a8e3d89f591f..1d0733b38a4b 100644 --- a/include/asm-x86_64/spinlock.h +++ b/include/asm-x86_64/spinlock.h | |||
@@ -22,14 +22,13 @@ | |||
22 | #define __raw_spin_lock_string \ | 22 | #define __raw_spin_lock_string \ |
23 | "\n1:\t" \ | 23 | "\n1:\t" \ |
24 | LOCK_PREFIX " ; decl %0\n\t" \ | 24 | LOCK_PREFIX " ; decl %0\n\t" \ |
25 | "js 2f\n" \ | 25 | "jns 2f\n" \ |
26 | LOCK_SECTION_START("") \ | 26 | "3:\n" \ |
27 | "2:\t" \ | ||
28 | "rep;nop\n\t" \ | 27 | "rep;nop\n\t" \ |
29 | "cmpl $0,%0\n\t" \ | 28 | "cmpl $0,%0\n\t" \ |
30 | "jle 2b\n\t" \ | 29 | "jle 3b\n\t" \ |
31 | "jmp 1b\n" \ | 30 | "jmp 1b\n" \ |
32 | LOCK_SECTION_END | 31 | "2:\t" \ |
33 | 32 | ||
34 | #define __raw_spin_lock_string_up \ | 33 | #define __raw_spin_lock_string_up \ |
35 | "\n\tdecl %0" | 34 | "\n\tdecl %0" |