From f71cd2aaf5e3f5942484a7ddb92e6192b2130dc6 Mon Sep 17 00:00:00 2001 From: Watson Zeng Date: Tue, 12 Jan 2021 15:27:55 +0800 Subject: [PATCH] spinlock: validate: fix the dependency with MP_NUM_CPUS the implementation of spinlock validation uses two LSB bits in the bottom of a pointer union to store a CPU index, which only has space for 4 CPUS. the MP_NUM_CPUS should be <= 4. Signed-off-by: Watson Zeng --- include/spinlock.h | 2 +- subsys/debug/Kconfig | 2 +- tests/kernel/spinlock/testcase.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/spinlock.h b/include/spinlock.h index 44d4c6abdad..779d891e117 100644 --- a/include/spinlock.h +++ b/include/spinlock.h @@ -61,7 +61,7 @@ struct k_spinlock { bool z_spin_lock_valid(struct k_spinlock *l); bool z_spin_unlock_valid(struct k_spinlock *l); void z_spin_lock_set_owner(struct k_spinlock *l); -BUILD_ASSERT(CONFIG_MP_NUM_CPUS < 4, "Too many CPUs for mask"); +BUILD_ASSERT(CONFIG_MP_NUM_CPUS <= 4, "Too many CPUs for mask"); #endif /* CONFIG_SPIN_VALIDATE */ /** diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index 8c886eb0fa4..99f2b381102 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -222,7 +222,7 @@ config ASSERT_LEVEL config SPIN_VALIDATE bool "Enable spinlock validation" depends on ASSERT - depends on MP_NUM_CPUS < 4 + depends on MP_NUM_CPUS <= 4 default y if !FLASH || FLASH_SIZE > 32 help There's a spinlock validation framework available when asserts are diff --git a/tests/kernel/spinlock/testcase.yaml b/tests/kernel/spinlock/testcase.yaml index 6afc1715a52..c4c6338e440 100644 --- a/tests/kernel/spinlock/testcase.yaml +++ b/tests/kernel/spinlock/testcase.yaml @@ -1,4 +1,4 @@ tests: kernel.multiprocessing.spinlock: tags: smp spinlock - filter: CONFIG_SMP and CONFIG_MP_NUM_CPUS > 1 + filter: CONFIG_SMP and CONFIG_MP_NUM_CPUS > 1 and CONFIG_MP_NUM_CPUS <= 4