aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/bpftrace/taskqlatency.bt
blob: 598f9882b30d249b43afdb92287e5dd815ddccc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <sys/taskq.h>

kprobe:trace_zfs_taskq_ent__birth
{
        $tqent = (struct taskq_ent *)arg0;

        $tqent_id = $tqent->tqent_id;
        $tq_name = str($tqent->tqent_taskq->tq_name);

        @birth[$tq_name, $tqent_id] = nsecs;
}

kprobe:trace_zfs_taskq_ent__start
{
        $tqent = (struct taskq_ent *)arg0;

        @tqent_id[tid] = $tqent->tqent_id;
        @tq_name[tid] = str($tqent->tqent_taskq->tq_name);

        @start[@tq_name[tid], @tqent_id[tid]] = nsecs;
}

kprobe:trace_zfs_taskq_ent__start
/ @birth[@tq_name[tid], @tqent_id[tid]] /
{
        @queue_lat_us[@tq_name[tid]] =
                hist((nsecs - @birth[@tq_name[tid], @tqent_id[tid]])/1000);
        delete(@birth[@tq_name[tid], @tqent_id[tid]]);
}

kprobe:trace_zfs_taskq_ent__finish
/ @start[@tq_name[tid], @tqent_id[tid]] /
{
        $tqent = (struct taskq_ent *)arg0;

        @exec_lat_us[@tq_name[tid], ksym($tqent->tqent_func)] =
                hist((nsecs - @start[@tq_name[tid], @tqent_id[tid]])/1000);
        delete(@start[@tq_name[tid], @tqent_id[tid]]);
}

kprobe:trace_zfs_taskq_ent__finish
{
        delete(@tq_name[tid]);
        delete(@tqent_id[tid]);
}

END
{
        clear(@birth);
        clear(@start);

        clear(@tq_name);
        clear(@tqent_id);
}