From 9c2c115716700da3279fd4ab541f0f598d0c4d6d Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Sat, 23 Feb 2019 07:41:53 -0800 Subject: [PATCH] kernel/spinlock: Predicate spinlock validation on flash size The spinlock validation isn't super lightweight -- it adds only a few tens of bytess per call, but there are a LOT of locking calls. On smaller platforms with 32kb of flash, we're bumping into code size limits on the bigger tests (tests/kernel/poll is a particular offender). Check the declared flash size before enabling it. Signed-off-by: Andy Ross --- include/spinlock.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/spinlock.h b/include/spinlock.h index 4f20f744b12..dccbfeac2f4 100644 --- a/include/spinlock.h +++ b/include/spinlock.h @@ -24,6 +24,15 @@ static inline void _arch_irq_unlock(int key) } #endif +/* There's a spinlock validation framework available when asserts are + * enabled. It adds a relatively hefty overhead (about 3k or so) to + * kernel code size, don't use on platforms known to be small. (Note + * we're using the kconfig value here. This isn't defined for every + * board, but the default of zero works well as an "infinity" + * fallback. There is a DT_FLASH_SIZE parameter too, but that seems + * even more poorly supported. + */ +#if (CONFIG_FLASH_SIZE == 0) || (CONFIG_FLASH_SIZE > 32) #if defined(CONFIG_ASSERT) && (CONFIG_MP_NUM_CPUS < 4) #include struct k_spinlock; @@ -31,6 +40,7 @@ int z_spin_lock_valid(struct k_spinlock *l); int z_spin_unlock_valid(struct k_spinlock *l); #define SPIN_VALIDATE #endif +#endif struct k_spinlock_key { int key;