xen/spinlocks: spin_trylock with interrupts off is always fine
authorJuergen Gross <jgross@suse.com>
Wed, 4 Nov 2020 08:26:42 +0000 (09:26 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 4 Nov 2020 08:26:42 +0000 (09:26 +0100)
commitc0d3cc9b0f343ef455ce3e2c4c605064a2934865
tree091e339fb0ea9f50958332e1fcb51222270005aa
parent5816d327e44ab37ae08730f4c54a80835998f31f
xen/spinlocks: spin_trylock with interrupts off is always fine

Even if a spinlock was taken with interrupts on before calling
spin_trylock() with interrupts off is fine, as it can't block.

Add a bool parameter "try" to check_lock() for handling this case.

Remove the call of check_lock() from _spin_is_locked(), as it really
serves no purpose and it can even lead to false crashes, e.g. when
a lock was taken correctly with interrupts enabled and the call of
_spin_is_locked() happened with interrupts off. In case the lock is
taken with wrong interrupt flags this will be catched when taking
the lock.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/spinlock.c