mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-21 19:53:59 +08:00
tile: modify arch_spin_unlock_wait() semantics
Rather than trying to wait until all possible lockers have
unlocked the lock, we now only wait until the current locker
(if any) has released the lock.
The old code was correct, but the new code works more like the x86
code and thus hopefully is more appropriate under contention.
See commit 78bff1c868
("x86/ticketlock: Fix spin_unlock_wait()
livelock") for x86.
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
This commit is contained in:
parent
b787f68c36
commit
14c3dec2a8
@ -65,8 +65,17 @@ EXPORT_SYMBOL(arch_spin_trylock);
|
|||||||
void arch_spin_unlock_wait(arch_spinlock_t *lock)
|
void arch_spin_unlock_wait(arch_spinlock_t *lock)
|
||||||
{
|
{
|
||||||
u32 iterations = 0;
|
u32 iterations = 0;
|
||||||
while (arch_spin_is_locked(lock))
|
int curr = READ_ONCE(lock->current_ticket);
|
||||||
|
int next = READ_ONCE(lock->next_ticket);
|
||||||
|
|
||||||
|
/* Return immediately if unlocked. */
|
||||||
|
if (next == curr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Wait until the current locker has released the lock. */
|
||||||
|
do {
|
||||||
delay_backoff(iterations++);
|
delay_backoff(iterations++);
|
||||||
|
} while (READ_ONCE(lock->current_ticket) == curr);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(arch_spin_unlock_wait);
|
EXPORT_SYMBOL(arch_spin_unlock_wait);
|
||||||
|
|
||||||
|
@ -65,8 +65,17 @@ EXPORT_SYMBOL(arch_spin_trylock);
|
|||||||
void arch_spin_unlock_wait(arch_spinlock_t *lock)
|
void arch_spin_unlock_wait(arch_spinlock_t *lock)
|
||||||
{
|
{
|
||||||
u32 iterations = 0;
|
u32 iterations = 0;
|
||||||
while (arch_spin_is_locked(lock))
|
u32 val = READ_ONCE(lock->lock);
|
||||||
|
u32 curr = arch_spin_current(val);
|
||||||
|
|
||||||
|
/* Return immediately if unlocked. */
|
||||||
|
if (arch_spin_next(val) == curr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Wait until the current locker has released the lock. */
|
||||||
|
do {
|
||||||
delay_backoff(iterations++);
|
delay_backoff(iterations++);
|
||||||
|
} while (arch_spin_current(READ_ONCE(lock->lock)) == curr);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(arch_spin_unlock_wait);
|
EXPORT_SYMBOL(arch_spin_unlock_wait);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user