Prevent a recursion inside wakeup(9) when scheduler tracepoints are enabled.
authormpi <mpi@openbsd.org>
Sat, 30 Mar 2024 13:33:20 +0000 (13:33 +0000)
committermpi <mpi@openbsd.org>
Sat, 30 Mar 2024 13:33:20 +0000 (13:33 +0000)
commite1edc428842b76b591fa1e4e901ca4f15df52536
tree10aa04687ab71837589236da8bddcf499809a8a5
parent079ad427beb4200db54c59a602692de8ee5ae963
Prevent a recursion inside wakeup(9) when scheduler tracepoints are enabled.

Tracepoints like "sched:enqueue" and "sched:unsleep" were called from inside
the loop iterating over sleeping threads as part of wakeup_proc().  When such
tracepoints were enabled they could result in another wakeup(9) possibly
corrupting the sleepqueue.

Rewrite wakeup(9) in two stages, first dequeue threads from the sleepqueue then
call setrunnable() and possible tracepoints for each of them.

This requires moving unsleep() outside of setrunnable() because it messes with
the sleepqueue.

ok claudio@
sys/dev/pci/drm/drm_linux.c
sys/kern/kern_sig.c
sys/kern/kern_synch.c
sys/kern/sched_bsd.c
sys/kern/sys_process.c
sys/sys/proc.h