[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCHv2 5/6] xen: use ticket locks for spin locks
On 04/10/2015 01:29 PM, David Vrabel wrote: On 10/04/2015 17:44, Boris Ostrovsky wrote:On 04/10/2015 10:19 AM, David Vrabel wrote:@@ -138,14 +138,17 @@ void spin_debug_disable(void) void _spin_lock(spinlock_t *lock) { + spinlock_tickets_t tickets = { .tail = 1, }; LOCK_PROFILE_VAR; check_lock(&lock->debug); - while ( unlikely(!_raw_spin_trylock(&lock->raw)) ) + tickets.head_tail = xadd(&lock->tickets, tickets.head_tail); + if ( tickets.tail != read_atomic(&lock->tickets.head) ) { LOCK_PROFILE_BLOCK; - while ( likely(_raw_spin_is_locked(&lock->raw)) ) + do { cpu_relax(); + } while ( tickets.tail != read_atomic(&lock->tickets.head) ); }Why do you use both 'if' and 'while"? I.e. why not just while ( tickets.tail != read_atomic(&lock->tickets.head) ) { LOCK_PROFILE_BLOCK; cpu_relax(); }We need to only call LOCK_PROFILE_BLOCK once when we start blocking. LOCK_PROFILE_BLOCK is a "one-shot" assignment. Once 'block' is set to NOW() it doesn't change anymore. So it will be updated only on the first iteration of the loop. -boris _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |