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:
parent
38195d5dd1
commit
1d51e888d8
1 changed files with 2 additions and 5 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue