* Re: [PATCH] BUILD_LOCK_OPS: cleanup preempt_disable() usage
2006-01-19 14:45 [PATCH] BUILD_LOCK_OPS: cleanup preempt_disable() usage Oleg Nesterov
@ 2006-01-19 13:31 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2006-01-19 13:31 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: linux-kernel, Andrew Morton
* Oleg Nesterov <oleg@tv-sign.ru> wrote:
> 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>
good one!
Acked-by: Ingo Molnar <mingo@elte.hu>
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] BUILD_LOCK_OPS: cleanup preempt_disable() usage
@ 2006-01-19 14:45 Oleg Nesterov
2006-01-19 13:31 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2006-01-19 14:45 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Andrew Morton
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>
--- 2.6.15/kernel/spinlock.c~ 2005-09-17 18:57:30.000000000 +0400
+++ 2.6.15/kernel/spinlock.c 2006-01-19 19:57:42.000000000 +0300
@@ -179,16 +179,16 @@ EXPORT_SYMBOL(_write_lock);
#define BUILD_LOCK_OPS(op, locktype) \
void __lockfunc _##op##_lock(locktype##_t *lock) \
{ \
- preempt_disable(); \
for (;;) { \
+ preempt_disable(); \
if (likely(_raw_##op##_trylock(lock))) \
break; \
preempt_enable(); \
+ \
if (!(lock)->break_lock) \
(lock)->break_lock = 1; \
while (!op##_can_lock(lock) && (lock)->break_lock) \
cpu_relax(); \
- preempt_disable(); \
} \
(lock)->break_lock = 0; \
} \
@@ -199,19 +199,18 @@ unsigned long __lockfunc _##op##_lock_ir
{ \
unsigned long flags; \
\
- preempt_disable(); \
for (;;) { \
+ preempt_disable(); \
local_irq_save(flags); \
if (likely(_raw_##op##_trylock(lock))) \
break; \
local_irq_restore(flags); \
- \
preempt_enable(); \
+ \
if (!(lock)->break_lock) \
(lock)->break_lock = 1; \
while (!op##_can_lock(lock) && (lock)->break_lock) \
cpu_relax(); \
- preempt_disable(); \
} \
(lock)->break_lock = 0; \
return flags; \
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-19 13:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-19 14:45 [PATCH] BUILD_LOCK_OPS: cleanup preempt_disable() usage Oleg Nesterov
2006-01-19 13:31 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox