zephyr/kernel/include
Andy Ross bd077561d0 kernel/swap: Add assertion to catch lock-breaking context switches
Our z_swap() API takes a key returned from arch_irq_lock() and
releases it atomically with the context switch.  Make sure that the
action of the unlocking is to unmask interrupts globally.  If
interrupts would still be masked then that means there is an OUTER
interrupt lock still held, and the code that locked it surely doesn't
expect the thread to be suspended and interrupts unmasked while it's
held!

Unfortunately, this kind of mistake is very easy to make.  We should
catch that with a simple assertion.  This is essentially a crude
Zephyr equivalent of the extremely common "BUG: scheduling while
atomic" error in Linux drivers (just google it).

The one exception made is the circumstance where a thread has already
aborted itself.  At that stage, whatever upthread lock state might
have existed will have already been messed up, so there's no value in
our asserting here.  We can't catch all bugs, and this can actually
happen in error handling and/or test frameworks.

Fixes #33319

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-17 15:27:37 -04:00
..
gen_offset.h aarch64: Use absolute symbols for the callee saved registers 2020-11-17 18:59:23 -05:00
kernel_arch_interface.h kernel: mmu: introduce arch_page_phys_get() 2021-05-07 13:36:22 -04:00
kernel_internal.h linker: add bits for pinned regions 2021-05-10 16:00:43 -05:00
kernel_offsets.h kernel: add an architecture specific structs header 2021-04-21 09:03:47 -04:00
kernel_tls.h kernel: tls: align tdata/tbss sections in stack 2021-02-07 23:28:43 -05:00
ksched.h Tracing: Thread tracing 2021-05-07 22:10:21 -04:00
kswap.h kernel/swap: Add assertion to catch lock-breaking context switches 2021-05-17 15:27:37 -04:00
mmu.h kernel: Make both operands of operators of same essential type category 2021-04-01 05:34:17 -04:00
offsets_short.h kernel: add common bits to support TLS 2020-10-24 10:52:00 -07:00