I'm currently using ftrace (via atrace on Android, specifically) to help me understand the scheduler's thread wakeup flow. The line below is confusing to me, however. It suggests that the current task (ls-4787) is waking up itself (comm=ls pid=4787).
Why or how would this ever happen? I can't think of any situation where the currently running process (which is already in the run queue!) to... add itself to the queue. Am I reading this incorrectly? Thanks for any help you might be able to offer!
kworker/0:0-4692 ( 4692) [000] d..3 52894.176161: sched_switch: prev_comm=kworker/0:0 prev_pid=4692 prev_prio=120 prev_state=S ==> next_comm=ls next_pid=4787 next_prio=120
adbd-209 ( 209) [001] d..3 52894.176192: sched_switch: prev_comm=adbd prev_pid=209 prev_prio=120 prev_state=S ==> next_comm=adbd next_pid=230 next_prio=120
ls-4787 ( 4787) [000] dN.4 52894.176204: sched_wakeup: comm=kworker/0:0 pid=4692 prio=120 success=1 target_cpu=000
ls-4787 ( 4787) [000] dN.4 52894.176211: sched_wakeup: comm=ls pid=4787 prio=120 success=1 target_cpu=000
ls-4787 ( 4787) [000] d..3 52894.176221: sched_switch: prev_comm=ls prev_pid=4787 prev_prio=120 prev_state=R+ ==> next_comm=kworker/0:0 next_pid=4692 next_prio=120
As an addendum, these peculiar instances seem to always be coupled with a kworker event, but I'm not sure why this would be impacted from the scheduler's perspective.