X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=kernel%2Farch%2Ftile%2Finclude%2Fasm%2Fspinlock_32.h;h=b14b1ba5bf9c328959bea3a14643fbb87e4ae7b1;hb=e09b41010ba33a20a87472ee821fa407a5b8da36;hp=c0a77b38d39a73c8b7064b4b92a340a92b7f83e8;hpb=f93b97fd65072de626c074dbe099a1fff05ce060;p=kvmfornfv.git diff --git a/kernel/arch/tile/include/asm/spinlock_32.h b/kernel/arch/tile/include/asm/spinlock_32.h index c0a77b38d..b14b1ba5b 100644 --- a/kernel/arch/tile/include/asm/spinlock_32.h +++ b/kernel/arch/tile/include/asm/spinlock_32.h @@ -41,8 +41,12 @@ static inline int arch_spin_is_locked(arch_spinlock_t *lock) * to claim the lock is held, since it will be momentarily * if not already. There's no need to wait for a "valid" * lock->next_ticket to become available. + * Use READ_ONCE() to ensure that calling this in a loop is OK. */ - return lock->next_ticket != lock->current_ticket; + int curr = READ_ONCE(lock->current_ticket); + int next = READ_ONCE(lock->next_ticket); + + return next != curr; } void arch_spin_lock(arch_spinlock_t *lock);