Skip to content

Commit

Permalink
spinlock: validate: fix the dependency with MP_NUM_CPUS
Browse files Browse the repository at this point in the history
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 <zhiwei@synopsys.com>
  • Loading branch information
IRISZZW authored and nashif committed Jan 26, 2021
1 parent 3d267ee commit f71cd2a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/**
Expand Down
2 changes: 1 addition & 1 deletion subsys/debug/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/spinlock/testcase.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f71cd2a

Please sign in to comment.