Skip to contentSkip to conversation

i386 spinlocks: disable interrupts only if we enabled them

PATCH Chuck Ebbert 1 participant 1 message Mar 8, 2006

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <[email protected]>

Quoted 6 lines · Andrew Morton
Quoted 5 lines · Chuck Ebbert

Fastpath before patch:

        jle <keep looping>      not-taken conditional jump
        cli                     disable interrupts
        jmp <try for lock>      unconditional jump
Quoted 7 lines
Quoted 3 lines

Fastpath after patch, if interrupts were not enabled:
jg <try for lock> taken conditional branch

Well no. The fastpath is:

jns 4f we got the lock.

That's debatable. Once the spinlock is available, jumping back to
try and get it becomes fastpath code, even though the spinloop itself is not. Any delay seen here means lost cycles that could be doing work.

My only real question is how long 'cli' takes if interrupts are already
disabled.

Quoted 2 lines

And it's increasing text size. Which wouldn't be a big problem if the spinning code was still in an out-of-line section, but it isn't any more.

__raw_spin_lock_flags is inlined, but only one place, in
_spin_lock_irqsave(), which is no longer an inline. So there's no real need to out-of-line the spin code anymore. This adds nine bytes, which should be acceptable in an out-of-line function. (Only the unlock functions are inlined, and even then only if !CONFIG_PREEMPT).

Signature · 2 lines
Chuck
"Penguins don't come from next door, they come from the Antarctic!"