diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2006-03-23 06:00:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 10:38:16 -0500 |
commit | ee25e96fcd78837c9f192aa655ce12a88bfd63d4 (patch) | |
tree | e244e0903bd9583b5c0e6df5e46867427641e131 /kernel | |
parent | eb8782ef72758b8700963ef8b949f5c812e6d630 (diff) |
[PATCH] BUILD_LOCK_OPS: cleanup preempt_disable() usage
This patch changes the code from:
preempt_disable();
for (;;) {
...
preempt_disable();
}
to:
for (;;) {
preempt_disable();
...
}
which seems more clean to me and saves a couple of bytes for
each function.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/spinlock.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/spinlock.c b/kernel/spinlock.c index 0375fcd5921d..d1b810782bc4 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c | |||
@@ -179,16 +179,16 @@ EXPORT_SYMBOL(_write_lock); | |||
179 | #define BUILD_LOCK_OPS(op, locktype) \ | 179 | #define BUILD_LOCK_OPS(op, locktype) \ |
180 | void __lockfunc _##op##_lock(locktype##_t *lock) \ | 180 | void __lockfunc _##op##_lock(locktype##_t *lock) \ |
181 | { \ | 181 | { \ |
182 | preempt_disable(); \ | ||
183 | for (;;) { \ | 182 | for (;;) { \ |
183 | preempt_disable(); \ | ||
184 | if (likely(_raw_##op##_trylock(lock))) \ | 184 | if (likely(_raw_##op##_trylock(lock))) \ |
185 | break; \ | 185 | break; \ |
186 | preempt_enable(); \ | 186 | preempt_enable(); \ |
187 | \ | ||
187 | if (!(lock)->break_lock) \ | 188 | if (!(lock)->break_lock) \ |
188 | (lock)->break_lock = 1; \ | 189 | (lock)->break_lock = 1; \ |
189 | while (!op##_can_lock(lock) && (lock)->break_lock) \ | 190 | while (!op##_can_lock(lock) && (lock)->break_lock) \ |
190 | cpu_relax(); \ | 191 | cpu_relax(); \ |
191 | preempt_disable(); \ | ||
192 | } \ | 192 | } \ |
193 | (lock)->break_lock = 0; \ | 193 | (lock)->break_lock = 0; \ |
194 | } \ | 194 | } \ |
@@ -199,19 +199,18 @@ unsigned long __lockfunc _##op##_lock_irqsave(locktype##_t *lock) \ | |||
199 | { \ | 199 | { \ |
200 | unsigned long flags; \ | 200 | unsigned long flags; \ |
201 | \ | 201 | \ |
202 | preempt_disable(); \ | ||
203 | for (;;) { \ | 202 | for (;;) { \ |
203 | preempt_disable(); \ | ||
204 | local_irq_save(flags); \ | 204 | local_irq_save(flags); \ |
205 | if (likely(_raw_##op##_trylock(lock))) \ | 205 | if (likely(_raw_##op##_trylock(lock))) \ |
206 | break; \ | 206 | break; \ |
207 | local_irq_restore(flags); \ | 207 | local_irq_restore(flags); \ |
208 | \ | ||
209 | preempt_enable(); \ | 208 | preempt_enable(); \ |
209 | \ | ||
210 | if (!(lock)->break_lock) \ | 210 | if (!(lock)->break_lock) \ |
211 | (lock)->break_lock = 1; \ | 211 | (lock)->break_lock = 1; \ |
212 | while (!op##_can_lock(lock) && (lock)->break_lock) \ | 212 | while (!op##_can_lock(lock) && (lock)->break_lock) \ |
213 | cpu_relax(); \ | 213 | cpu_relax(); \ |
214 | preempt_disable(); \ | ||
215 | } \ | 214 | } \ |
216 | (lock)->break_lock = 0; \ | 215 | (lock)->break_lock = 0; \ |
217 | return flags; \ | 216 | return flags; \ |