I've been trying to enable context switch events on perf and use perf script's dump from perf.data to investigate thread blocked time.
So far the only two recording options that seem to be helpful are context switch and all the sched events.
Here's the command I'm running on perf:
perf record -g -a -F 999 -e cpu-clock,sched:sched_stat_sleep,sched:sched_switch,sched:sched_process_exit,context-switches
However, both seem to be incomplete, usually a sched_switch event looks something like this:
comm1 0/0  0.0: 1 sched:sched_switch: prev_comm=comm1 prev_pid=0 prev_prio=0 prev_state=S ==> next_comm=comm2 next_pid=1 next_prio=1 stacktrace...
From my understanding, the prev_comm is always the thread that is going to be blocked, and the next_comm is the thread that is going to be unblocked. Is this a correct assumption? If it is, I can't seem to get complete data on the events since there are many threads that get blocked on prev_comm, but never seem to get a corresponding next_comm.
Enabling context switches doesn't seem to do much since there is no information on the thread being blocked or unblocked (unless I'm completely missing something, in which I would appreciate an explanation on how they work).
Here's how a typical context switch event looks like:
comm1 0/0  0.0: 1 context-switch: stacktrace...
tl;dr, how can I do blocked time investigations on linux through perf script's output and what options need to be enabled on perf record?