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 <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2019-02-23 07:41:53 -08:00 committed by Andrew Boie
commit 9c2c115716

View file

@ -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 <misc/__assert.h>
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;