zephyr/kernel
Andy Ross d537267fc3 kernel/sched: Fix thread selection misordering with aborted threads
When a running thread gets aborted asynchronously (this only happens
in SMP contexts, obviously) it gets flagged "aborting", but the actual
abort needs to happen in the thread's own context.  For convenience,
this was done in the next_up() routine that selects the next thread to
run at interrupt exit time.

But this check was being done AFTER the next candidate thread was
selected from the run queue.  Thread abort can wake up threads blocked
in k_thread_join(), and therefore these weren't seen as runable
threads, even if they should have been.

Executive summary: if you killed a thread running on another CPU, and
there was another thread joined to the killed thread that should have
run on that CPU, it wouldn't (until it received an interrupt or
otherwise reached a schedule point).

Move the abort check above the run queue inspection and into the
end-of-interrupt processing in z_get_next_switch_handle() (so it's
actually a mild performance boost as it's no longer part of the
cooperative context switch path).  Simple fix, subtle bug.

Fixes #58040

Signed-off-by: Andy Ross <andyross@google.com>
2023-05-22 08:06:49 +00:00
..
include kernel: Remove unused absolute symbols 2023-04-18 10:51:28 -04:00
paging arch/kernel/soc/samples: use unsigned int for irq_lock() 2022-07-14 14:37:13 -05:00
atomic_c.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
banner.c kernel: banner: Remove unnecessary header 2023-01-09 12:07:28 -05:00
CMakeLists.txt cache: Fix cache API calling from userspace 2022-08-23 10:14:17 +02:00
compiler_stack_protect.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
condvar.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
device.c device: use iterable sections 2023-05-12 12:01:10 +02:00
errno.c kernel: Allow Zephyr to use libc's internal errno 2022-05-12 19:06:48 -04:00
events.c kernel: events: fix waitq timeout race condition 2023-03-09 09:22:21 +01:00
fatal.c debug: coredump: add xtensa intel adsp, support toolchains 2022-06-23 15:44:45 -04:00
futex.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
idle.c kernel: idle: fix build error on arm-clang 2023-05-02 15:01:24 -05:00
init.c kernel: pin _kernel variable in case of paging 2023-05-16 11:41:11 -04:00
Kconfig intel_adsp: ace20_lnl: Change LNL core count to 5 2023-05-15 08:00:11 -04:00
Kconfig.vm everywhere: fix typos 2022-03-18 13:24:08 -04:00
kheap.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
mailbox.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
main_weak.c kernel: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
mem_domain.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
mem_slab.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
mempool.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
mmu.c kernel: mmu: fix potential running out of virtual memory space 2022-11-17 15:56:04 +00:00
msg_q.c kernel: fix buffer overflow from incorrect K_MSGQ_DEFINE definition 2023-05-12 13:39:10 -04:00
mutex.c kernel: mutex: fix races when lock timeout 2022-08-12 17:40:20 +02:00
pipes.c kernel: pipes: ISRs use a private pipe descriptor 2023-02-11 06:45:13 +09:00
poll.c kernel: allow k_poll to wait on pipes 2022-08-24 17:49:20 +00:00
queue.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
sched.c kernel/sched: Fix thread selection misordering with aborted threads 2023-05-22 08:06:49 +00:00
sem.c kernel: Minor k_sem_give() performance enhancement 2023-04-28 10:09:46 +02:00
smp.c smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS 2022-10-21 13:14:58 +02:00
stack.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
system_work_q.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
thread.c kernel: events: fix waitq timeout race condition 2023-03-09 09:22:21 +01:00
timeout.c kernel/sched: Use kernel timeouts for timeslice expirations 2023-03-09 09:21:12 +01:00
timer.c kernel/timer: fix period argument clamp handling 2023-02-20 09:52:53 +01:00
usage.c smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS 2022-10-21 13:14:58 +02:00
userspace.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
userspace_handler.c kernel: migrate includes to <zephyr/...> 2022-05-09 09:26:20 +02:00
version.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
work.c kernel/work: Fix race under with delayed work item cancellation 2023-02-11 12:14:16 +09:00
xip.c kernel: remove redundant <zephyr/zephyr.h> includes 2022-06-15 09:13:11 +02:00