xref: /aosp_15_r20/external/bcc/tools/wakeuptime_example.txt (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1*387f9dfdSAndroid Build Coastguard WorkerDemonstrations of wakeuptime, the Linux eBPF/bcc version.
2*387f9dfdSAndroid Build Coastguard Worker
3*387f9dfdSAndroid Build Coastguard Worker
4*387f9dfdSAndroid Build Coastguard WorkerThis program measures when threads block, and shows the stack traces for the
5*387f9dfdSAndroid Build Coastguard Workerthreads that performed the wakeup, along with the process names of the waker
6*387f9dfdSAndroid Build Coastguard Workerand target processes, and the total blocked time. This blocked time is measured
7*387f9dfdSAndroid Build Coastguard Workerfrom when a thread blocks, to when the wakeup signal is sent. Note that this
8*387f9dfdSAndroid Build Coastguard Workertime excludes some run queue latency from the target thread, which may not
9*387f9dfdSAndroid Build Coastguard Workerimmediately execute if it needs to wait its turn on-CPU. All the data shown,
10*387f9dfdSAndroid Build Coastguard Workerstack traces, process names, and times, are summarized in-kernel using an eBPF
11*387f9dfdSAndroid Build Coastguard Workermap for efficiency.
12*387f9dfdSAndroid Build Coastguard Worker
13*387f9dfdSAndroid Build Coastguard WorkerThis tool is intended to be used after offcputime, which shows the directly
14*387f9dfdSAndroid Build Coastguard Workerblocked stacks. wakeuptime can then be used to show the stacks that performed
15*387f9dfdSAndroid Build Coastguard Workerthe wakeups.
16*387f9dfdSAndroid Build Coastguard Worker
17*387f9dfdSAndroid Build Coastguard WorkerHere is some example (truncated) output. To explain what we are seeing: the
18*387f9dfdSAndroid Build Coastguard Workerfirst stack trace shown is for a "vmstat" thread, which was woken up by
19*387f9dfdSAndroid Build Coastguard Worker"swapper/1". The stack trace is for swapper/1, which shows a timer interrupt.
20*387f9dfdSAndroid Build Coastguard WorkerThe total time is 4.0 seconds: this actually corresponds to a "vmstat 1"
21*387f9dfdSAndroid Build Coastguard Workerprinting 4 x 1 second summaries -- we're seeing the interrupt stack that
22*387f9dfdSAndroid Build Coastguard Workerwakes up vmstat:
23*387f9dfdSAndroid Build Coastguard Worker
24*387f9dfdSAndroid Build Coastguard Worker# ./wakeuptime
25*387f9dfdSAndroid Build Coastguard WorkerTracing blocked time (us) by kernel stack... Hit Ctrl-C to end.
26*387f9dfdSAndroid Build Coastguard Worker^C
27*387f9dfdSAndroid Build Coastguard Worker[...truncated...]
28*387f9dfdSAndroid Build Coastguard Worker
29*387f9dfdSAndroid Build Coastguard Worker    target:          vmstat
30*387f9dfdSAndroid Build Coastguard Worker    ffffffff810df082 hrtimer_wakeup
31*387f9dfdSAndroid Build Coastguard Worker    ffffffff810df494 __hrtimer_run_queues
32*387f9dfdSAndroid Build Coastguard Worker    ffffffff810dfba8 hrtimer_interrupt
33*387f9dfdSAndroid Build Coastguard Worker    ffffffff8100b9e1 xen_timer_interrupt
34*387f9dfdSAndroid Build Coastguard Worker    ffffffff810cb9c8 handle_irq_event_percpu
35*387f9dfdSAndroid Build Coastguard Worker    ffffffff810cf1ca handle_percpu_irq
36*387f9dfdSAndroid Build Coastguard Worker    ffffffff810cb0c2 generic_handle_irq
37*387f9dfdSAndroid Build Coastguard Worker    ffffffff814766f7 evtchn_2l_handle_events
38*387f9dfdSAndroid Build Coastguard Worker    ffffffff81473e83 __xen_evtchn_do_upcall
39*387f9dfdSAndroid Build Coastguard Worker    ffffffff81475cf0 xen_evtchn_do_upcall
40*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178adee xen_do_hypervisor_callback
41*387f9dfdSAndroid Build Coastguard Worker    waker:           swapper/1
42*387f9dfdSAndroid Build Coastguard Worker        4000415
43*387f9dfdSAndroid Build Coastguard Worker
44*387f9dfdSAndroid Build Coastguard Worker    target:          sshd
45*387f9dfdSAndroid Build Coastguard Worker    ffffffff812037b6 pollwake
46*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
47*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
48*387f9dfdSAndroid Build Coastguard Worker    ffffffff814939fd n_tty_receive_buf_common
49*387f9dfdSAndroid Build Coastguard Worker    ffffffff81494424 n_tty_receive_buf2
50*387f9dfdSAndroid Build Coastguard Worker    ffffffff81496df5 flush_to_ldisc
51*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108c80a process_one_work
52*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108caeb worker_thread
53*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
54*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
55*387f9dfdSAndroid Build Coastguard Worker    waker:           kworker/u16:2
56*387f9dfdSAndroid Build Coastguard Worker        4001028
57*387f9dfdSAndroid Build Coastguard Worker
58*387f9dfdSAndroid Build Coastguard Worker    target:          rcuos/0
59*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5b12 autoremove_wake_function
60*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
61*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
62*387f9dfdSAndroid Build Coastguard Worker    ffffffff810d8043 rcu_gp_kthread
63*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
64*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
65*387f9dfdSAndroid Build Coastguard Worker    ffffffff81ca9420 ddebug_tables
66*387f9dfdSAndroid Build Coastguard Worker    waker:           rcu_sched
67*387f9dfdSAndroid Build Coastguard Worker        4009976
68*387f9dfdSAndroid Build Coastguard Worker
69*387f9dfdSAndroid Build Coastguard Worker    target:          rcuos/7
70*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5b12 autoremove_wake_function
71*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
72*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
73*387f9dfdSAndroid Build Coastguard Worker    ffffffff810d6f28 rcu_nocb_kthread
74*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
75*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
76*387f9dfdSAndroid Build Coastguard Worker    waker:           rcuos/6
77*387f9dfdSAndroid Build Coastguard Worker        4095781
78*387f9dfdSAndroid Build Coastguard Worker
79*387f9dfdSAndroid Build Coastguard Worker    target:          rcuos/6
80*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5b12 autoremove_wake_function
81*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
82*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
83*387f9dfdSAndroid Build Coastguard Worker    ffffffff810d8043 rcu_gp_kthread
84*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
85*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
86*387f9dfdSAndroid Build Coastguard Worker    ffffffff81ca9420 ddebug_tables
87*387f9dfdSAndroid Build Coastguard Worker    waker:           rcu_sched
88*387f9dfdSAndroid Build Coastguard Worker        4101075
89*387f9dfdSAndroid Build Coastguard Worker
90*387f9dfdSAndroid Build Coastguard Worker    target:          rcuos/5
91*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5b12 autoremove_wake_function
92*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
93*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
94*387f9dfdSAndroid Build Coastguard Worker    ffffffff810d6f28 rcu_nocb_kthread
95*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
96*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
97*387f9dfdSAndroid Build Coastguard Worker    waker:           rcuos/4
98*387f9dfdSAndroid Build Coastguard Worker        4103492
99*387f9dfdSAndroid Build Coastguard Worker
100*387f9dfdSAndroid Build Coastguard Worker    target:          rcuos/3
101*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5b12 autoremove_wake_function
102*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
103*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
104*387f9dfdSAndroid Build Coastguard Worker    ffffffff810d6f28 rcu_nocb_kthread
105*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
106*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
107*387f9dfdSAndroid Build Coastguard Worker    waker:           rcuos/2
108*387f9dfdSAndroid Build Coastguard Worker        4107785
109*387f9dfdSAndroid Build Coastguard Worker
110*387f9dfdSAndroid Build Coastguard Worker    target:          rcuos/2
111*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5b12 autoremove_wake_function
112*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
113*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
114*387f9dfdSAndroid Build Coastguard Worker    ffffffff810d8043 rcu_gp_kthread
115*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
116*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
117*387f9dfdSAndroid Build Coastguard Worker    ffffffff81ca9420 ddebug_tables
118*387f9dfdSAndroid Build Coastguard Worker    waker:           rcu_sched
119*387f9dfdSAndroid Build Coastguard Worker        4113308
120*387f9dfdSAndroid Build Coastguard Worker
121*387f9dfdSAndroid Build Coastguard Worker    target:          wakeuptime
122*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108109e signal_wake_up_state
123*387f9dfdSAndroid Build Coastguard Worker    ffffffff810811e6 complete_signal
124*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108186b __send_signal
125*387f9dfdSAndroid Build Coastguard Worker    ffffffff81081b0e send_signal
126*387f9dfdSAndroid Build Coastguard Worker    ffffffff810824e3 do_send_sig_info
127*387f9dfdSAndroid Build Coastguard Worker    ffffffff81082955 group_send_sig_info
128*387f9dfdSAndroid Build Coastguard Worker    ffffffff810829b4 __kill_pgrp_info
129*387f9dfdSAndroid Build Coastguard Worker    ffffffff81082a15 kill_pgrp
130*387f9dfdSAndroid Build Coastguard Worker    ffffffff8149081f __isig
131*387f9dfdSAndroid Build Coastguard Worker    ffffffff814912b4 isig
132*387f9dfdSAndroid Build Coastguard Worker    ffffffff81491f7c n_tty_receive_signal_char
133*387f9dfdSAndroid Build Coastguard Worker    ffffffff81493528 n_tty_receive_char_special
134*387f9dfdSAndroid Build Coastguard Worker    ffffffff8149419f n_tty_receive_buf_common
135*387f9dfdSAndroid Build Coastguard Worker    ffffffff81494424 n_tty_receive_buf2
136*387f9dfdSAndroid Build Coastguard Worker    ffffffff81496df5 flush_to_ldisc
137*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108c80a process_one_work
138*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108caeb worker_thread
139*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
140*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
141*387f9dfdSAndroid Build Coastguard Worker    waker:           kworker/u16:2
142*387f9dfdSAndroid Build Coastguard Worker        4125162
143*387f9dfdSAndroid Build Coastguard Worker
144*387f9dfdSAndroid Build Coastguard Worker    target:          sshd
145*387f9dfdSAndroid Build Coastguard Worker    ffffffff812037b6 pollwake
146*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
147*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b58d5 __wake_up_sync_key
148*387f9dfdSAndroid Build Coastguard Worker    ffffffff816707ba sock_def_readable
149*387f9dfdSAndroid Build Coastguard Worker    ffffffff816d9f87 tcp_data_queue
150*387f9dfdSAndroid Build Coastguard Worker    ffffffff816dd465 tcp_rcv_established
151*387f9dfdSAndroid Build Coastguard Worker    ffffffff816e7ec5 tcp_v4_do_rcv
152*387f9dfdSAndroid Build Coastguard Worker    ffffffff816e8ff7 tcp_v4_rcv
153*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c3a84 ip_local_deliver_finish
154*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c3d80 ip_local_deliver
155*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c3762 ip_rcv_finish
156*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c4062 ip_rcv
157*387f9dfdSAndroid Build Coastguard Worker    ffffffff816885be __netif_receive_skb_core
158*387f9dfdSAndroid Build Coastguard Worker    ffffffff81688928 __netif_receive_skb
159*387f9dfdSAndroid Build Coastguard Worker    ffffffff81688993 netif_receive_skb_internal
160*387f9dfdSAndroid Build Coastguard Worker    ffffffff816894c5 napi_gro_receive
161*387f9dfdSAndroid Build Coastguard Worker    ffffffff81593111 xennet_poll
162*387f9dfdSAndroid Build Coastguard Worker    ffffffff81688e0e net_rx_action
163*387f9dfdSAndroid Build Coastguard Worker    ffffffff8107932b __do_softirq
164*387f9dfdSAndroid Build Coastguard Worker    ffffffff810796b2 irq_exit
165*387f9dfdSAndroid Build Coastguard Worker    waker:           swapper/0
166*387f9dfdSAndroid Build Coastguard Worker        4515762
167*387f9dfdSAndroid Build Coastguard Worker
168*387f9dfdSAndroid Build Coastguard Worker    target:          supervise
169*387f9dfdSAndroid Build Coastguard Worker    ffffffff810df082 hrtimer_wakeup
170*387f9dfdSAndroid Build Coastguard Worker    ffffffff810df494 __hrtimer_run_queues
171*387f9dfdSAndroid Build Coastguard Worker    ffffffff810dfba8 hrtimer_interrupt
172*387f9dfdSAndroid Build Coastguard Worker    ffffffff8100b9e1 xen_timer_interrupt
173*387f9dfdSAndroid Build Coastguard Worker    ffffffff810cb9c8 handle_irq_event_percpu
174*387f9dfdSAndroid Build Coastguard Worker    ffffffff810cf1ca handle_percpu_irq
175*387f9dfdSAndroid Build Coastguard Worker    ffffffff810cb0c2 generic_handle_irq
176*387f9dfdSAndroid Build Coastguard Worker    ffffffff814766f7 evtchn_2l_handle_events
177*387f9dfdSAndroid Build Coastguard Worker    ffffffff81473e83 __xen_evtchn_do_upcall
178*387f9dfdSAndroid Build Coastguard Worker    ffffffff81475cf0 xen_evtchn_do_upcall
179*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178adee xen_do_hypervisor_callback
180*387f9dfdSAndroid Build Coastguard Worker    waker:           swapper/0
181*387f9dfdSAndroid Build Coastguard Worker        25523344
182*387f9dfdSAndroid Build Coastguard Worker
183*387f9dfdSAndroid Build Coastguard WorkerDetaching...
184*387f9dfdSAndroid Build Coastguard Worker
185*387f9dfdSAndroid Build Coastguard WorkerThe second last stack trace shows sshd being woken up by packets being received.
186*387f9dfdSAndroid Build Coastguard WorkerNear the bottom of the stack is driver processing, then IP, TCP, and finally
187*387f9dfdSAndroid Build Coastguard Workersocket processing as we work up the stack. The total time sshd (all sshd's)
188*387f9dfdSAndroid Build Coastguard Workerwere blocked and woken up in this way was 4.5 seconds.
189*387f9dfdSAndroid Build Coastguard Worker
190*387f9dfdSAndroid Build Coastguard WorkerDo be somewhat careful with overhead: this is tracing scheduler functions, which
191*387f9dfdSAndroid Build Coastguard Workercan be called very frequently. While this uses in-kernel summaries for
192*387f9dfdSAndroid Build Coastguard Workerefficiency, the rate of scheduler functions can be very high (> 1,000,000/sec),
193*387f9dfdSAndroid Build Coastguard Workerand this is performing stack walks when threads return to CPU. At some point
194*387f9dfdSAndroid Build Coastguard Workerthe overhead will be measurable.
195*387f9dfdSAndroid Build Coastguard Worker
196*387f9dfdSAndroid Build Coastguard Worker
197*387f9dfdSAndroid Build Coastguard WorkerA -p option can be used to filter (in-kernel) on a single process ID. For
198*387f9dfdSAndroid Build Coastguard Workerexample, only matching PID 19169, which is a bash shell:
199*387f9dfdSAndroid Build Coastguard Worker
200*387f9dfdSAndroid Build Coastguard Worker# ./wakeuptime -p 19169
201*387f9dfdSAndroid Build Coastguard WorkerTracing blocked time (us) by kernel stack... Hit Ctrl-C to end.
202*387f9dfdSAndroid Build Coastguard Worker^C
203*387f9dfdSAndroid Build Coastguard Worker    target:          bash
204*387f9dfdSAndroid Build Coastguard Worker    ffffffff81075eb8 child_wait_callback
205*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
206*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b58d5 __wake_up_sync_key
207*387f9dfdSAndroid Build Coastguard Worker    ffffffff81078046 __wake_up_parent
208*387f9dfdSAndroid Build Coastguard Worker    ffffffff810831b3 do_notify_parent
209*387f9dfdSAndroid Build Coastguard Worker    ffffffff81077eaf do_exit
210*387f9dfdSAndroid Build Coastguard Worker    ffffffff81077f93 do_group_exit
211*387f9dfdSAndroid Build Coastguard Worker    ffffffff81078014 sys_exit_group
212*387f9dfdSAndroid Build Coastguard Worker    ffffffff81789076 entry_SYSCALL_64_fastpath
213*387f9dfdSAndroid Build Coastguard Worker    waker:           ls
214*387f9dfdSAndroid Build Coastguard Worker        2015
215*387f9dfdSAndroid Build Coastguard Worker
216*387f9dfdSAndroid Build Coastguard Worker    target:          bash
217*387f9dfdSAndroid Build Coastguard Worker    ffffffff81075eb8 child_wait_callback
218*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
219*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b58d5 __wake_up_sync_key
220*387f9dfdSAndroid Build Coastguard Worker    ffffffff81078046 __wake_up_parent
221*387f9dfdSAndroid Build Coastguard Worker    ffffffff810831b3 do_notify_parent
222*387f9dfdSAndroid Build Coastguard Worker    ffffffff81077eaf do_exit
223*387f9dfdSAndroid Build Coastguard Worker    ffffffff81077f93 do_group_exit
224*387f9dfdSAndroid Build Coastguard Worker    ffffffff81078014 sys_exit_group
225*387f9dfdSAndroid Build Coastguard Worker    ffffffff81789076 entry_SYSCALL_64_fastpath
226*387f9dfdSAndroid Build Coastguard Worker    waker:           sleep
227*387f9dfdSAndroid Build Coastguard Worker        1001347
228*387f9dfdSAndroid Build Coastguard Worker
229*387f9dfdSAndroid Build Coastguard Worker    target:          bash
230*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5921 woken_wake_function
231*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
232*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
233*387f9dfdSAndroid Build Coastguard Worker    ffffffff814939fd n_tty_receive_buf_common
234*387f9dfdSAndroid Build Coastguard Worker    ffffffff81494424 n_tty_receive_buf2
235*387f9dfdSAndroid Build Coastguard Worker    ffffffff81496df5 flush_to_ldisc
236*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108c80a process_one_work
237*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108caeb worker_thread
238*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
239*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
240*387f9dfdSAndroid Build Coastguard Worker    waker:           kworker/u16:0
241*387f9dfdSAndroid Build Coastguard Worker        1871024
242*387f9dfdSAndroid Build Coastguard Worker
243*387f9dfdSAndroid Build Coastguard Worker    target:          bash
244*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5921 woken_wake_function
245*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
246*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
247*387f9dfdSAndroid Build Coastguard Worker    ffffffff814939fd n_tty_receive_buf_common
248*387f9dfdSAndroid Build Coastguard Worker    ffffffff81494424 n_tty_receive_buf2
249*387f9dfdSAndroid Build Coastguard Worker    ffffffff81496df5 flush_to_ldisc
250*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108c80a process_one_work
251*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108caeb worker_thread
252*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
253*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
254*387f9dfdSAndroid Build Coastguard Worker    waker:           kworker/u16:2
255*387f9dfdSAndroid Build Coastguard Worker        3019839
256*387f9dfdSAndroid Build Coastguard Worker
257*387f9dfdSAndroid Build Coastguard WorkerDetaching...
258*387f9dfdSAndroid Build Coastguard Worker
259*387f9dfdSAndroid Build Coastguard WorkerThese stack traces are fascinating! The first two shows bash waiting on child
260*387f9dfdSAndroid Build Coastguard Workerprocesses, an "ls" and a "sleep". The sleep stack was responsible for 1.0
261*387f9dfdSAndroid Build Coastguard Workerseconds of blocked time: I'd run a "sleep 1".
262*387f9dfdSAndroid Build Coastguard Worker
263*387f9dfdSAndroid Build Coastguard WorkerThe last two stacks show bash waking up to service tty input (keystrokes).
264*387f9dfdSAndroid Build Coastguard Worker
265*387f9dfdSAndroid Build Coastguard Worker
266*387f9dfdSAndroid Build Coastguard WorkerA duration can be added, for example, tracing PID 19097 (sshd) for 5 seconds
267*387f9dfdSAndroid Build Coastguard Workeronly:
268*387f9dfdSAndroid Build Coastguard Worker
269*387f9dfdSAndroid Build Coastguard Worker# ./wakeuptime -p 19097 5
270*387f9dfdSAndroid Build Coastguard WorkerTracing blocked time (us) by kernel stack for 5 secs.
271*387f9dfdSAndroid Build Coastguard Worker
272*387f9dfdSAndroid Build Coastguard Worker    target:          sshd
273*387f9dfdSAndroid Build Coastguard Worker    ffffffff812037b6 pollwake
274*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
275*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
276*387f9dfdSAndroid Build Coastguard Worker    ffffffff814939fd n_tty_receive_buf_common
277*387f9dfdSAndroid Build Coastguard Worker    ffffffff81494424 n_tty_receive_buf2
278*387f9dfdSAndroid Build Coastguard Worker    ffffffff81496df5 flush_to_ldisc
279*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108c80a process_one_work
280*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108caeb worker_thread
281*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
282*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
283*387f9dfdSAndroid Build Coastguard Worker    waker:           kworker/u16:1
284*387f9dfdSAndroid Build Coastguard Worker        785
285*387f9dfdSAndroid Build Coastguard Worker
286*387f9dfdSAndroid Build Coastguard Worker    target:          sshd
287*387f9dfdSAndroid Build Coastguard Worker    ffffffff812037b6 pollwake
288*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
289*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b54d9 __wake_up
290*387f9dfdSAndroid Build Coastguard Worker    ffffffff814939fd n_tty_receive_buf_common
291*387f9dfdSAndroid Build Coastguard Worker    ffffffff81494424 n_tty_receive_buf2
292*387f9dfdSAndroid Build Coastguard Worker    ffffffff81496df5 flush_to_ldisc
293*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108c80a process_one_work
294*387f9dfdSAndroid Build Coastguard Worker    ffffffff8108caeb worker_thread
295*387f9dfdSAndroid Build Coastguard Worker    ffffffff81092979 kthread
296*387f9dfdSAndroid Build Coastguard Worker    ffffffff8178940f ret_from_fork
297*387f9dfdSAndroid Build Coastguard Worker    waker:           kworker/u16:2
298*387f9dfdSAndroid Build Coastguard Worker        2843
299*387f9dfdSAndroid Build Coastguard Worker
300*387f9dfdSAndroid Build Coastguard Worker    target:          sshd
301*387f9dfdSAndroid Build Coastguard Worker    ffffffff812037b6 pollwake
302*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b5462 __wake_up_common
303*387f9dfdSAndroid Build Coastguard Worker    ffffffff810b58d5 __wake_up_sync_key
304*387f9dfdSAndroid Build Coastguard Worker    ffffffff816707ba sock_def_readable
305*387f9dfdSAndroid Build Coastguard Worker    ffffffff816d9f87 tcp_data_queue
306*387f9dfdSAndroid Build Coastguard Worker    ffffffff816dd465 tcp_rcv_established
307*387f9dfdSAndroid Build Coastguard Worker    ffffffff816e7ec5 tcp_v4_do_rcv
308*387f9dfdSAndroid Build Coastguard Worker    ffffffff816e8ff7 tcp_v4_rcv
309*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c3a84 ip_local_deliver_finish
310*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c3d80 ip_local_deliver
311*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c3762 ip_rcv_finish
312*387f9dfdSAndroid Build Coastguard Worker    ffffffff816c4062 ip_rcv
313*387f9dfdSAndroid Build Coastguard Worker    ffffffff816884be __netif_receive_skb_core
314*387f9dfdSAndroid Build Coastguard Worker    ffffffff81688928 __netif_receive_skb
315*387f9dfdSAndroid Build Coastguard Worker    ffffffff81688993 netif_receive_skb_internal
316*387f9dfdSAndroid Build Coastguard Worker    ffffffff816894c5 napi_gro_receive
317*387f9dfdSAndroid Build Coastguard Worker    ffffffff81593111 xennet_poll
318*387f9dfdSAndroid Build Coastguard Worker    ffffffff81688e0e net_rx_action
319*387f9dfdSAndroid Build Coastguard Worker    ffffffff8107932b __do_softirq
320*387f9dfdSAndroid Build Coastguard Worker    ffffffff810796b2 irq_exit
321*387f9dfdSAndroid Build Coastguard Worker    waker:           swapper/0
322*387f9dfdSAndroid Build Coastguard Worker        276103
323*387f9dfdSAndroid Build Coastguard Worker
324*387f9dfdSAndroid Build Coastguard WorkerDetaching...
325*387f9dfdSAndroid Build Coastguard Worker
326*387f9dfdSAndroid Build Coastguard Worker
327*387f9dfdSAndroid Build Coastguard WorkerA -f option will emit output using the "folded stacks" format, which can be
328*387f9dfdSAndroid Build Coastguard Workerread directly by flamegraph.pl from the FlameGraph open source software
329*387f9dfdSAndroid Build Coastguard Worker(https://github.com/brendangregg/FlameGraph). Eg:
330*387f9dfdSAndroid Build Coastguard Worker
331*387f9dfdSAndroid Build Coastguard Worker# ./wakeuptime -f 5
332*387f9dfdSAndroid Build Coastguard Workerrun;entry_SYSCALL_64_fastpath;sys_mmap;sys_mmap_pgoff;vm_mmap_pgoff;do_mmap;mmap_region;do_munmap;__split_vma.isra.35;vma_adjust;call_rwsem_wake;rwsem_wake;__rwsem_do_wake;run 1
333*387f9dfdSAndroid Build Coastguard Workerrun;page_fault;do_page_fault;__do_page_fault;handle_mm_fault;unlock_page;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;run 1
334*387f9dfdSAndroid Build Coastguard Workerchmod;page_fault;do_page_fault;__do_page_fault;handle_mm_fault;unlock_page;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;mkdir 2
335*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;search_binary_handler;load_script;search_binary_handler;load_elf_binary;flush_old_exec;mmput;exit_mmap;free_pgtables;unlink_file_vma;call_rwsem_wake;rwsem_wake;__rwsem_do_wake;supervise 2
336*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;search_binary_handler;load_script;search_binary_handler;load_elf_binary;clear_user;page_fault;do_page_fault;__do_page_fault;handle_mm_fault;unlock_page;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;run 2
337*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;search_binary_handler;load_elf_binary;flush_old_exec;mmput;exit_mmap;free_pgtables;unlink_file_vma;call_rwsem_wake;rwsem_wake;__rwsem_do_wake;run 3
338*387f9dfdSAndroid Build Coastguard Workermkdir;return_from_execve;sys_execve;do_execveat_common.isra.33;search_binary_handler;load_elf_binary;clear_user;page_fault;do_page_fault;__do_page_fault;handle_mm_fault;unlock_page;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;mkdir 3
339*387f9dfdSAndroid Build Coastguard Workermkdir;page_fault;do_page_fault;__do_page_fault;handle_mm_fault;unlock_page;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;mkdir 4
340*387f9dfdSAndroid Build Coastguard Workerrun;page_fault;do_page_fault;__do_page_fault;handle_mm_fault;unlock_page;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;mkdir 4
341*387f9dfdSAndroid Build Coastguard Workersupervise;entry_SYSCALL_64_fastpath;sys_clone;_do_fork;copy_process;call_rwsem_wake;rwsem_wake;__rwsem_do_wake;supervise 5
342*387f9dfdSAndroid Build Coastguard Workerrcuos/0;ddebug_tables;ret_from_fork;kthread;rcu_nocb_kthread;rcu_gp_kthread_wake;__wake_up;__wake_up_common;autoremove_wake_function;rcu_sched 10
343*387f9dfdSAndroid Build Coastguard Workerswapper/7;cpu_bringup_and_idle;cpu_startup_entry;rcu_idle_enter;rcu_eqs_enter;rcu_eqs_enter_common;wake_nocb_leader;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/6 12
344*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_start_kernel;x86_64_start_reservations;start_kernel;rest_init;cpu_startup_entry;rcu_idle_enter;rcu_eqs_enter;rcu_eqs_enter_common;wake_nocb_leader;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/0 16
345*387f9dfdSAndroid Build Coastguard Workerrcuos/6;ret_from_fork;kthread;rcu_nocb_kthread;rcu_gp_kthread_wake;__wake_up;__wake_up_common;autoremove_wake_function;rcu_sched 19
346*387f9dfdSAndroid Build Coastguard Workerrun;page_fault;do_page_fault;__do_page_fault;handle_mm_fault;unlock_page;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;run 25
347*387f9dfdSAndroid Build Coastguard Workerbash;entry_SYSCALL_64_fastpath;sys_write;vfs_write;__vfs_write;tty_write;n_tty_write;do_output_char;pty_write;tty_flip_buffer_push;queue_work_on;__queue_work;insert_work;kworker/u16:2 26
348*387f9dfdSAndroid Build Coastguard Workerswapper/4;cpu_bringup_and_idle;cpu_startup_entry;rcu_idle_enter;rcu_eqs_enter;rcu_eqs_enter_common;wake_nocb_leader;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/4 30
349*387f9dfdSAndroid Build Coastguard Workerpickup;entry_SYSCALL_64_fastpath;sys_write;vfs_write;__vfs_write;sock_write_iter;sock_sendmsg;unix_stream_sendmsg;sock_def_readable;__wake_up_sync_key;__wake_up_common;ep_poll_callback;__wake_up_locked;__wake_up_common;master 36
350*387f9dfdSAndroid Build Coastguard Workerswapper/1;cpu_bringup_and_idle;cpu_startup_entry;rcu_idle_enter;rcu_eqs_enter;rcu_eqs_enter_common;wake_nocb_leader;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/0 52
351*387f9dfdSAndroid Build Coastguard Workerchown;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;ext4_end_bio;ext4_finish_bio;end_page_writeback;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;supervise 189
352*387f9dfdSAndroid Build Coastguard Workersupervise;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;end_bio_bh_io_sync;journal_end_buffer_io_sync;wake_up_bit;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;supervise 371
353*387f9dfdSAndroid Build Coastguard Workersupervise;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;ext4_end_bio;ext4_finish_bio;end_page_writeback;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;supervise 3093
354*387f9dfdSAndroid Build Coastguard Workerchown;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 3985
355*387f9dfdSAndroid Build Coastguard Workersupervise;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 3997
356*387f9dfdSAndroid Build Coastguard Workersupervise;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;end_bio_bh_io_sync;journal_end_buffer_io_sync;unlock_buffer;wake_up_bit;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;jbd2/xvda1-8 4511
357*387f9dfdSAndroid Build Coastguard Workerchmod;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;ext4_end_bio;ext4_finish_bio;end_page_writeback;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;supervise 4646
358*387f9dfdSAndroid Build Coastguard Workerswapper/4;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 7971
359*387f9dfdSAndroid Build Coastguard Workerreadproctitle;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;end_bio_bh_io_sync;journal_end_buffer_io_sync;unlock_buffer;wake_up_bit;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;jbd2/xvda1-8 8249
360*387f9dfdSAndroid Build Coastguard Workerswapper/2;cpu_bringup_and_idle;cpu_startup_entry;rcu_idle_enter;rcu_eqs_enter;rcu_eqs_enter_common;wake_nocb_leader;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/2 12016
361*387f9dfdSAndroid Build Coastguard Workerrun;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;ext4_end_bio;ext4_finish_bio;end_page_writeback;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;supervise 13973
362*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;end_bio_bh_io_sync;journal_end_buffer_io_sync;wake_up_bit;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;supervise 15736
363*387f9dfdSAndroid Build Coastguard Workerrun;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 19916
364*387f9dfdSAndroid Build Coastguard Workerswapper/1;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 31877
365*387f9dfdSAndroid Build Coastguard Workermkdir;entry_SYSCALL_64_fastpath;sys_exit_group;do_group_exit;do_exit;do_notify_parent;__wake_up_parent;__wake_up_sync_key;__wake_up_common;child_wait_callback;run 39619
366*387f9dfdSAndroid Build Coastguard Workerswapper/5;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 39837
367*387f9dfdSAndroid Build Coastguard Workerchown;entry_SYSCALL_64_fastpath;sys_exit_group;do_group_exit;do_exit;do_notify_parent;__wake_up_parent;__wake_up_sync_key;__wake_up_common;child_wait_callback;run 42190
368*387f9dfdSAndroid Build Coastguard Workerchmod;entry_SYSCALL_64_fastpath;sys_exit_group;do_group_exit;do_exit;do_notify_parent;__wake_up_parent;__wake_up_sync_key;__wake_up_common;child_wait_callback;run 43486
369*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_edge_irq;handle_irq_event;handle_irq_event_percpu;blkif_interrupt;blk_mq_complete_request;__blk_mq_complete_request;blk_mq_end_request;blk_update_request;bio_endio;ext4_end_bio;ext4_finish_bio;end_page_writeback;__wake_up_bit;__wake_up;__wake_up_common;wake_bit_function;supervise 47810
370*387f9dfdSAndroid Build Coastguard Workerbash;entry_SYSCALL_64_fastpath;sys_write;vfs_write;__vfs_write;tty_write;n_tty_write;pty_write;tty_flip_buffer_push;queue_work_on;__queue_work;insert_work;kworker/u16:2 86794
371*387f9dfdSAndroid Build Coastguard Workervmstat;entry_SYSCALL_64_fastpath;sys_write;vfs_write;__vfs_write;tty_write;n_tty_write;pty_write;tty_flip_buffer_push;queue_work_on;__queue_work;insert_work;kworker/u16:2 210848
372*387f9dfdSAndroid Build Coastguard Workerswapper/0;irq_exit;__do_softirq;net_rx_action;xennet_poll;napi_gro_receive;netif_receive_skb_internal;__netif_receive_skb;__netif_receive_skb_core;ip_rcv;ip_rcv_finish;ip_local_deliver;ip_local_deliver_finish;tcp_v4_rcv;tcp_v4_do_rcv;tcp_rcv_established;tcp_data_queue;sock_def_readable;__wake_up_sync_key;__wake_up_common;pollwake;sshd 543295
373*387f9dfdSAndroid Build Coastguard Workerkworker/u16:2;ret_from_fork;kthread;worker_thread;process_one_work;flush_to_ldisc;n_tty_receive_buf2;n_tty_receive_buf_common;__wake_up;__wake_up_common;woken_wake_function;bash 543570
374*387f9dfdSAndroid Build Coastguard Workerswapper/7;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/u16:2 741234
375*387f9dfdSAndroid Build Coastguard Workersshd;entry_SYSCALL_64_fastpath;sys_write;vfs_write;__vfs_write;tty_write;n_tty_write;pty_write;tty_flip_buffer_push;queue_work_on;__queue_work;insert_work;kworker/u16:2 855436
376*387f9dfdSAndroid Build Coastguard Workerbash;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/7 942685
377*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 969059
378*387f9dfdSAndroid Build Coastguard Workerswapper/4;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;add_interrupt_randomness;credit_entropy_bits;queue_work_on;__queue_work;insert_work;kworker/4:0 999981
379*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;sleep 1000103
380*387f9dfdSAndroid Build Coastguard Workersleep;entry_SYSCALL_64_fastpath;sys_exit_group;do_group_exit;do_exit;do_notify_parent;__wake_up_parent;__wake_up_sync_key;__wake_up_common;child_wait_callback;bash 1001564
381*387f9dfdSAndroid Build Coastguard Workerswapper/3;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 1016980
382*387f9dfdSAndroid Build Coastguard Workermkdir;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 1019302
383*387f9dfdSAndroid Build Coastguard Workerchown;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 1019908
384*387f9dfdSAndroid Build Coastguard Workerswapper/7;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 1021074
385*387f9dfdSAndroid Build Coastguard Workerswapper/4;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 1021075
386*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/6 1030506
387*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/4 1032424
388*387f9dfdSAndroid Build Coastguard Workerswapper/6;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 1036908
389*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/1 1040207
390*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/5 1044756
391*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/3 1044986
392*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/2 1046347
393*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/7 1093598
394*387f9dfdSAndroid Build Coastguard Workerswapper/7;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;process_timeout;rcu_sched 1858510
395*387f9dfdSAndroid Build Coastguard Workersupervise;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 2041736
396*387f9dfdSAndroid Build Coastguard Workerswapper/6;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 2042028
397*387f9dfdSAndroid Build Coastguard Workerswapper/1;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 2042149
398*387f9dfdSAndroid Build Coastguard Workerswapper/2;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 2042152
399*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/6 2042698
400*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/0 2044085
401*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/0 2047386
402*387f9dfdSAndroid Build Coastguard Workerrun;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/7 2065637
403*387f9dfdSAndroid Build Coastguard Workerswapper/4;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/4:0 2999930
404*387f9dfdSAndroid Build Coastguard Workerswapper/6;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;snmpd 2999999
405*387f9dfdSAndroid Build Coastguard Workerswapper/1;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/u16:2 3010848
406*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/5 3050881
407*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/1 3051454
408*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/3 3054844
409*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/2 3059548
410*387f9dfdSAndroid Build Coastguard Workersupervise;return_from_execve;sys_execve;do_execveat_common.isra.33;sched_exec;stop_one_cpu;cpu_stop_queue_work;migration/4 3061480
411*387f9dfdSAndroid Build Coastguard Workerswapper/3;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 3062666
412*387f9dfdSAndroid Build Coastguard Workerswapper/5;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 3063222
413*387f9dfdSAndroid Build Coastguard Workerswapper/7;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;it_real_fn;kill_pid_info;group_send_sig_info;do_send_sig_info;send_signal;__send_signal;complete_signal;signal_wake_up_state;ntpd 3999835
414*387f9dfdSAndroid Build Coastguard Workerswapper/1;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/1:0 3999933
415*387f9dfdSAndroid Build Coastguard Workerswapper/6;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/6:0 3999938
416*387f9dfdSAndroid Build Coastguard Workerswapper/3;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/3:0 3999938
417*387f9dfdSAndroid Build Coastguard Workerswapper/7;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/7:2 3999939
418*387f9dfdSAndroid Build Coastguard Workerswapper/5;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/5:3 3999942
419*387f9dfdSAndroid Build Coastguard Workerswapper/2;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/2:1 3999946
420*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_do_hypervisor_callback;xen_evtchn_do_upcall;irq_exit;__do_softirq;run_timer_softirq;call_timer_fn;delayed_work_timer_fn;__queue_work;insert_work;kworker/0:1 3999953
421*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;tail 4000414
422*387f9dfdSAndroid Build Coastguard Workerswapper/4;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;vmstat 4000417
423*387f9dfdSAndroid Build Coastguard Workerchmod;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 4083231
424*387f9dfdSAndroid Build Coastguard Workerrun;entry_SYSCALL_64_fastpath;sys_write;vfs_write;__vfs_write;pipe_write;__wake_up_sync_key;__wake_up_common;autoremove_wake_function;readproctitle 4096457
425*387f9dfdSAndroid Build Coastguard Workerrcuos/4;ret_from_fork;kthread;rcu_nocb_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/5 4973072
426*387f9dfdSAndroid Build Coastguard Workerrcuos/0;ddebug_tables;ret_from_fork;kthread;rcu_nocb_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/1 4973898
427*387f9dfdSAndroid Build Coastguard Workerrcu_sched;ddebug_tables;ret_from_fork;kthread;rcu_gp_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/0 4976731
428*387f9dfdSAndroid Build Coastguard Workerrcu_sched;ddebug_tables;ret_from_fork;kthread;rcu_gp_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/4 4976755
429*387f9dfdSAndroid Build Coastguard Workerrcuos/2;ret_from_fork;kthread;rcu_nocb_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/3 4980207
430*387f9dfdSAndroid Build Coastguard Workerrcu_sched;ddebug_tables;ret_from_fork;kthread;rcu_gp_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/2 4980502
431*387f9dfdSAndroid Build Coastguard Workerrcuos/6;ret_from_fork;kthread;rcu_nocb_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/7 4981025
432*387f9dfdSAndroid Build Coastguard Workerrcu_sched;ddebug_tables;ret_from_fork;kthread;rcu_gp_kthread;__wake_up;__wake_up_common;autoremove_wake_function;rcuos/6 4983110
433*387f9dfdSAndroid Build Coastguard Workerkworker/u16:2;ret_from_fork;kthread;worker_thread;process_one_work;flush_to_ldisc;n_tty_receive_buf2;n_tty_receive_buf_common;__wake_up;__wake_up_common;pollwake;sshd 5004430
434*387f9dfdSAndroid Build Coastguard Workerswapper/6;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;wakeuptime 5005051
435*387f9dfdSAndroid Build Coastguard Workerrun;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 7144088
436*387f9dfdSAndroid Build Coastguard Workerswapper/0;xen_do_hypervisor_callback;xen_evtchn_do_upcall;__xen_evtchn_do_upcall;evtchn_2l_handle_events;generic_handle_irq;handle_percpu_irq;handle_irq_event_percpu;xen_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;hrtimer_wakeup;supervise 11229310
437*387f9dfdSAndroid Build Coastguard Worker
438*387f9dfdSAndroid Build Coastguard WorkerThe stack traces are shown as single lines, with functions separated by
439*387f9dfdSAndroid Build Coastguard Workersemicolons. The first entry is the waker task name, followed by the waker stack,
440*387f9dfdSAndroid Build Coastguard Workerand then last entry is the target task name. As a flame graph, this puts the
441*387f9dfdSAndroid Build Coastguard Workerwaker name on the bottom, followed by the waker stack, and then the target
442*387f9dfdSAndroid Build Coastguard Workertask name on top. The 2nd column is the total blocked time.
443*387f9dfdSAndroid Build Coastguard Worker
444*387f9dfdSAndroid Build Coastguard WorkerI'd save this output to a file, then move it to the system where you'll be
445*387f9dfdSAndroid Build Coastguard Workercreating your "wakeup time flame graphs".
446*387f9dfdSAndroid Build Coastguard Worker
447*387f9dfdSAndroid Build Coastguard Worker
448*387f9dfdSAndroid Build Coastguard WorkerUSAGE message:
449*387f9dfdSAndroid Build Coastguard Worker
450*387f9dfdSAndroid Build Coastguard Worker# ./wakeuptime -h
451*387f9dfdSAndroid Build Coastguard Workerusage: wakeuptime [-h] [-u] [-p PID] [-v] [-f]
452*387f9dfdSAndroid Build Coastguard Worker                  [--stack-storage-size STACK_STORAGE_SIZE]
453*387f9dfdSAndroid Build Coastguard Worker                  [-m MIN_BLOCK_TIME] [-M MAX_BLOCK_TIME]
454*387f9dfdSAndroid Build Coastguard Worker                  [duration]
455*387f9dfdSAndroid Build Coastguard Worker
456*387f9dfdSAndroid Build Coastguard WorkerSummarize sleep to wakeup time by waker kernel stack
457*387f9dfdSAndroid Build Coastguard Worker
458*387f9dfdSAndroid Build Coastguard Workerpositional arguments:
459*387f9dfdSAndroid Build Coastguard Worker  duration              duration of trace, in seconds
460*387f9dfdSAndroid Build Coastguard Worker
461*387f9dfdSAndroid Build Coastguard Workeroptional arguments:
462*387f9dfdSAndroid Build Coastguard Worker  -h, --help            show this help message and exit
463*387f9dfdSAndroid Build Coastguard Worker  -u, --useronly        user threads only (no kernel threads)
464*387f9dfdSAndroid Build Coastguard Worker  -p PID, --pid PID     trace this PID only
465*387f9dfdSAndroid Build Coastguard Worker  -v, --verbose         show raw addresses
466*387f9dfdSAndroid Build Coastguard Worker  -f, --folded          output folded format
467*387f9dfdSAndroid Build Coastguard Worker  --stack-storage-size STACK_STORAGE_SIZE
468*387f9dfdSAndroid Build Coastguard Worker                        the number of unique stack traces that can be stored
469*387f9dfdSAndroid Build Coastguard Worker                        and displayed (default 16384)
470*387f9dfdSAndroid Build Coastguard Worker  -m MIN_BLOCK_TIME, --min-block-time MIN_BLOCK_TIME
471*387f9dfdSAndroid Build Coastguard Worker                        the amount of time in microseconds over which we store
472*387f9dfdSAndroid Build Coastguard Worker                        traces (default 1)
473*387f9dfdSAndroid Build Coastguard Worker  -M MAX_BLOCK_TIME, --max-block-time MAX_BLOCK_TIME
474*387f9dfdSAndroid Build Coastguard Worker                        the amount of time in microseconds under which we
475*387f9dfdSAndroid Build Coastguard Worker                        store traces (default U64_MAX)
476*387f9dfdSAndroid Build Coastguard Workerexamples:
477*387f9dfdSAndroid Build Coastguard Worker    ./wakeuptime             # trace blocked time with waker stacks
478*387f9dfdSAndroid Build Coastguard Worker    ./wakeuptime 5           # trace for 5 seconds only
479*387f9dfdSAndroid Build Coastguard Worker    ./wakeuptime -f 5        # 5 seconds, and output in folded format
480*387f9dfdSAndroid Build Coastguard Worker    ./wakeuptime -u          # don't include kernel threads (user only)
481*387f9dfdSAndroid Build Coastguard Worker    ./wakeuptime -p 185      # trace for PID 185 only
482