[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>
This commit is contained in:
parent
eb8782ef72
commit
ee25e96fcd
@ -179,16 +179,16 @@ EXPORT_SYMBOL(_write_lock);
|
|||||||
#define BUILD_LOCK_OPS(op, locktype) \
|
#define BUILD_LOCK_OPS(op, locktype) \
|
||||||
void __lockfunc _##op##_lock(locktype##_t *lock) \
|
void __lockfunc _##op##_lock(locktype##_t *lock) \
|
||||||
{ \
|
{ \
|
||||||
preempt_disable(); \
|
|
||||||
for (;;) { \
|
for (;;) { \
|
||||||
|
preempt_disable(); \
|
||||||
if (likely(_raw_##op##_trylock(lock))) \
|
if (likely(_raw_##op##_trylock(lock))) \
|
||||||
break; \
|
break; \
|
||||||
preempt_enable(); \
|
preempt_enable(); \
|
||||||
|
\
|
||||||
if (!(lock)->break_lock) \
|
if (!(lock)->break_lock) \
|
||||||
(lock)->break_lock = 1; \
|
(lock)->break_lock = 1; \
|
||||||
while (!op##_can_lock(lock) && (lock)->break_lock) \
|
while (!op##_can_lock(lock) && (lock)->break_lock) \
|
||||||
cpu_relax(); \
|
cpu_relax(); \
|
||||||
preempt_disable(); \
|
|
||||||
} \
|
} \
|
||||||
(lock)->break_lock = 0; \
|
(lock)->break_lock = 0; \
|
||||||
} \
|
} \
|
||||||
@ -199,19 +199,18 @@ unsigned long __lockfunc _##op##_lock_irqsave(locktype##_t *lock) \
|
|||||||
{ \
|
{ \
|
||||||
unsigned long flags; \
|
unsigned long flags; \
|
||||||
\
|
\
|
||||||
preempt_disable(); \
|
|
||||||
for (;;) { \
|
for (;;) { \
|
||||||
|
preempt_disable(); \
|
||||||
local_irq_save(flags); \
|
local_irq_save(flags); \
|
||||||
if (likely(_raw_##op##_trylock(lock))) \
|
if (likely(_raw_##op##_trylock(lock))) \
|
||||||
break; \
|
break; \
|
||||||
local_irq_restore(flags); \
|
local_irq_restore(flags); \
|
||||||
\
|
|
||||||
preempt_enable(); \
|
preempt_enable(); \
|
||||||
|
\
|
||||||
if (!(lock)->break_lock) \
|
if (!(lock)->break_lock) \
|
||||||
(lock)->break_lock = 1; \
|
(lock)->break_lock = 1; \
|
||||||
while (!op##_can_lock(lock) && (lock)->break_lock) \
|
while (!op##_can_lock(lock) && (lock)->break_lock) \
|
||||||
cpu_relax(); \
|
cpu_relax(); \
|
||||||
preempt_disable(); \
|
|
||||||
} \
|
} \
|
||||||
(lock)->break_lock = 0; \
|
(lock)->break_lock = 0; \
|
||||||
return flags; \
|
return flags; \
|
||||||
|
Loading…
Reference in New Issue
Block a user