xref: /freebsd/sys/contrib/openzfs/contrib/bpftrace/taskqlatency.bt (revision 18054d0220cfc8df9c9568c437bd6fbb59d53c3c)
1#include <sys/taskq.h>
2
3kprobe:trace_zfs_taskq_ent__birth
4{
5        $tqent = (struct taskq_ent *)arg0;
6
7        $tqent_id = $tqent->tqent_id;
8        $tq_name = str($tqent->tqent_taskq->tq_name);
9
10        @birth[$tq_name, $tqent_id] = nsecs;
11}
12
13kprobe:trace_zfs_taskq_ent__start
14{
15        $tqent = (struct taskq_ent *)arg0;
16
17        @tqent_id[tid] = $tqent->tqent_id;
18        @tq_name[tid] = str($tqent->tqent_taskq->tq_name);
19
20        @start[@tq_name[tid], @tqent_id[tid]] = nsecs;
21}
22
23kprobe:trace_zfs_taskq_ent__start
24/ @birth[@tq_name[tid], @tqent_id[tid]] /
25{
26        @queue_lat_us[@tq_name[tid]] =
27                hist((nsecs - @birth[@tq_name[tid], @tqent_id[tid]])/1000);
28        delete(@birth[@tq_name[tid], @tqent_id[tid]]);
29}
30
31kprobe:trace_zfs_taskq_ent__finish
32/ @start[@tq_name[tid], @tqent_id[tid]] /
33{
34        $tqent = (struct taskq_ent *)arg0;
35
36        @exec_lat_us[@tq_name[tid], ksym($tqent->tqent_func)] =
37                hist((nsecs - @start[@tq_name[tid], @tqent_id[tid]])/1000);
38        delete(@start[@tq_name[tid], @tqent_id[tid]]);
39}
40
41kprobe:trace_zfs_taskq_ent__finish
42{
43        delete(@tq_name[tid]);
44        delete(@tqent_id[tid]);
45}
46
47END
48{
49        clear(@birth);
50        clear(@start);
51
52        clear(@tq_name);
53        clear(@tqent_id);
54}
55