zephyr/tests/kernel
Josh DeWitt c05cfbf15e kernel/sched: Re-sort waitq on priority change
k_thread_priority_set() on a pended thread wasn't re-inserting into the
waitq, causing the incorrect thread to run based on priority. When using
the scalable waitq config, this can also break assumptions of the tree
and leave the owner of a waitq still being in the waitq tree, cycles in
the tree, or a crash.

Remove and re-add a thread to a waitq to ensure the waitq remains in
order and the tree's assumptions are not violated.

To illustrate the issue, consider 4 threads in decreasing priority
order: A, B, C, and D along with two mutexes, m0 and m1. This is
implemented in the new complex_inversion mutex_api test.
1. D locks m1
2. C locks m0
3. C pends on m1
4. B pends on m1
5. A pends on m0, boosts C's priority, now tree on m1 is not sorted
6. D unlocks m1, left-most thread on tree is B. When removing B from
   tree it cannot be found because it searches to the right of C due to
   C's boosted priority when the node is actually on the left. rb_remove
   silently fails.
7. B unlocks m1, left-most thread on tree is still B and it tries to
   unpend itself, resulting in a NULL pointer dereference on
   B->base.pended_on.

Signed-off-by: Josh DeWitt <josh.dewitt@garmin.com>
2025-03-24 07:58:36 +01:00
..
cache
common Revert "tests: kernel: adopt new count_bits util function" 2025-03-18 16:39:47 +01:00
condvar/condvar_api
context tests/kernel/context: Remove BOARD_NATIVE_POSIX check 2025-03-12 02:27:36 +01:00
device linker: Allow for 999 priority levels in init levels 2025-03-19 18:53:22 -04:00
early_sleep
events
fatal everywhere: Replace diagnostic pragmas with TOOLCHAIN_* macros 2025-03-20 21:57:47 +01:00
fifo
fpu_sharing toolchain: iar: Add experimental IAR support 2025-02-14 19:12:44 +00:00
gen_isr_table irq: multilevel: compile 3rd level IRQ APIs only when enabled 2025-02-19 14:49:27 +00:00
interrupt tests: kernel: interrupt: Remove MS_TO_US 2025-02-20 06:05:37 +01:00
ipi_cascade Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
ipi_optimize tests: Update ipi_optimize for x86_64 directed IPIs 2025-03-07 20:22:40 +01:00
lifo
mbox
mem_heap/k_heap_api kernel: Add tests for k_heap_calloc 2024-12-30 17:32:03 +01:00
mem_protect everywhere: Use correct macro for gcc-specific warnings 2025-03-20 21:57:47 +01:00
mem_slab
mp
msgq tests: kernel/msgq_api: join threads after each test 2025-01-22 20:47:05 +01:00
mutex kernel/sched: Re-sort waitq on priority change 2025-03-24 07:58:36 +01:00
obj_core tests: Update tests to use new k_pipe API 2025-01-17 19:43:44 +01:00
obj_tracking tests: Update tests to use new k_pipe API 2025-01-17 19:43:44 +01:00
pending samples, tests: remove usage of space-separated lists 2024-12-04 14:14:53 -05:00
pipe tests: kernel/pipe_api: move local k_pipe var to global 2025-03-14 17:55:50 +01:00
poll test: k_msgq_put should trigger reschedule 2024-12-14 01:04:43 +01:00
profiling/profiling_api
queue tests: copy intel_adsp_ace30_ptl.conf to *_sim.conf 2024-11-18 13:18:22 -05:00
sched kernel: rename 'dumb' scheduler and simply call it 'simple' 2025-03-15 00:34:58 +01:00
semaphore tests: Update tests to use new k_pipe API 2025-01-17 19:43:44 +01:00
sleep tests: kernel: sleep: Add Silabs adjustment to max limit 2025-03-18 16:42:42 +01:00
smp arch: common: be able to use ROM_START_OFFSET on RISCV 2025-01-17 09:07:45 +01:00
smp_abort
smp_boot_delay samples, tests: remove usage of space-separated lists 2024-12-04 14:14:53 -05:00
smp_suspend
spinlock
stack/stack
threads tests: drivers: add overlay/testcase for silabs xg29_rb4412a board 2025-03-20 17:14:35 +01:00
tickless/tickless_concept
timer scripts: make sure we do not install vulunerable python packages 2025-03-22 14:03:56 -04:00
usage/thread_runtime_stats tests: kernel: usage: thread_runtime_stats: Improve test_all_stats_usage 2025-02-25 15:14:33 +00:00
workq tests: kernel: workq_stop uninitialized variable 2025-01-14 13:25:35 +01:00
xip