spinlock wakeup
Looking at
void _spin_lock(spinlock_t *lock)
{
spinlock_tickets_t tickets = SPINLOCK_TICKET_INC;
LOCK_PROFILE_VAR;
check_lock(&lock->debug);
tickets.head_tail = arch_fetch_and_add(&lock->tickets.head_tail,
tickets.head_tail);
while ( tickets.tail != observe_head(&lock->tickets) )
{
LOCK_PROFILE_BLOCK;
arch_lock_relax();
}
LOCK_PROFILE_GOT;
preempt_disable();
arch_lock_acquire_barrier();
}If the lock is dropped during LOCK_PROFILE_BLOCK, isn't there a chance that we are never woken up from arch_lock_relax()? (This would only be an issue on ARM which IIUIC sleeps there).
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Boris,
Quoted 20 lines · Boris Ostrovsky
Looking at
void
_spin_lock(spinlock_t *lock){ spinlock_tickets_t tickets = SPINLOCK_TICKET_INC; LOCK_PROFILE_VAR; check_lock(&lock->debug); tickets.head_tail = arch_fetch_and_add(&lock->tickets.head_tail, tickets.head_tail); while ( tickets.tail != observe_head(&lock->tickets) ) { LOCK_PROFILE_BLOCK; arch_lock_relax(); } LOCK_PROFILE_GOT; preempt_disable(); arch_lock_acquire_barrier(); }
Quoted 3 lines
If the lock is dropped during
LOCK_PROFILE_BLOCK, isn't there a chance that we are never woken up fromarch_lock_relax()? (This would only be an issue on ARM which IIUIC sleeps there).
The function arch_lock_signal will broadcast the event to all the processors and each of them will record the event. This event will be only cleared by a WFE (the implementation of arch_lock_acquire_barrier).
This means that if the event was happening during LOCK_PROFILE_BLOCK, the processor will not go to sleep and try again.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel