Skip to contentSkip to conversation

ARM/ARM64: Ticket Spinlock With GENERIC_BREAKLOCK

Question Leo Yan 2 participants 2 messages Apr 18, 2014 – Apr 23, 2014

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

hi,

I noticed now for ARM and ARM64 both have disabled GENERIC_BREAKLOCK, and i found the patch "ARM: 7484/1: Don't enable GENERIC_LOCKBREAK with ticket spinlocks" to remove related configuration.

The ticket spinlock will be helpful for spinlock's performance, but after disabled LOCKBREAK, it will always disable the preempt when the cpu is spinning to wait for the lock.

So even after have refined the spinlock with ticket algorithm, we still need LOCKBREAK for the cpu has the chance to do scheduling so that other threads have chance can run.

Thanks for any advice. :-)

Signature · 2 lines
Thx,
Leo Yan
#1 lore raw
Quoted 1 line · Leo Yan

hi,

Hello,

Quoted 11 lines

I noticed now for ARM and ARM64 both have disabled GENERIC_BREAKLOCK, and i found the patch "ARM: 7484/1: Don't enable GENERIC_LOCKBREAK with ticket spinlocks" to remove related configuration.

The ticket spinlock will be helpful for spinlock's performance, but after disabled LOCKBREAK, it will always disable the preempt when the cpu is spinning to wait for the lock.

So even after have refined the spinlock with ticket algorithm, we still need LOCKBREAK for the cpu has the chance to do scheduling so that other threads have chance can run.

The problem with GENERIC_LOCKBREAK is that we no longer end up using the lock() function. Instead, we trylock() in a busy loop, so if the machine doesn't have pending interrupts or other tasks to run, we end up chewing power in a busy loop while the lock is contended. Worse still, we're polling the lock value, so the relevant cacheline will be thrasing between all waiters (and potentially the CPU trying to unlock()!).

If latency is an issue for you, have you considered either using a mutex (where we explicitly block) or something like PREEMPT_RT instead?

Will