kernel/z_swap: Remove on-stack dummy spinlock

The z_swap_unlocked() function used a dummy spinlock for simplicity.
But this runs afouls of checking for stack-resident spinlocks
(forbidden when KERNEL_COHERENCE is set).  And it's executing needless
code to release the lock anyway.  Replace with a compile time NULL,
which will improve performance, correctness and code size.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2021-02-09 12:30:46 -08:00 committed by Anas Nashif
commit 1d51e888d8

View file

@ -68,7 +68,7 @@ static ALWAYS_INLINE unsigned int do_swap(unsigned int key,
z_check_stack_sentinel();
if (is_spinlock) {
if (is_spinlock && lock != NULL) {
k_spin_release(lock);
}
@ -136,10 +136,7 @@ static inline int z_swap(struct k_spinlock *lock, k_spinlock_key_t key)
static inline void z_swap_unlocked(void)
{
struct k_spinlock lock = {};
k_spinlock_key_t key = k_spin_lock(&lock);
(void) z_swap(&lock, key);
(void) do_swap(arch_irq_lock(), NULL, 1);
}
#else /* !CONFIG_USE_SWITCH */