diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/Makefile.am | 4 | ||||
-rw-r--r-- | contrib/bpftrace/Makefile.am | 3 | ||||
-rw-r--r-- | contrib/bpftrace/taskqlatency.bt | 54 | ||||
-rwxr-xr-x | contrib/bpftrace/zfs-trace.sh | 10 |
4 files changed, 69 insertions, 2 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 9a82f82ee..9f34fd835 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = bash_completion.d dracut initramfs pyzfs zcp -DIST_SUBDIRS = bash_completion.d dracut initramfs pyzfs zcp +SUBDIRS = bash_completion.d bpftrace dracut initramfs pyzfs zcp +DIST_SUBDIRS = bash_completion.d bpftrace dracut initramfs pyzfs zcp diff --git a/contrib/bpftrace/Makefile.am b/contrib/bpftrace/Makefile.am new file mode 100644 index 000000000..c4359e6c8 --- /dev/null +++ b/contrib/bpftrace/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = \ + $(top_srcdir)/contrib/bpftrace/taskqlatency.bt \ + $(top_srcdir)/contrib/bpftrace/zfs-trace.sh diff --git a/contrib/bpftrace/taskqlatency.bt b/contrib/bpftrace/taskqlatency.bt new file mode 100644 index 000000000..598f9882b --- /dev/null +++ b/contrib/bpftrace/taskqlatency.bt @@ -0,0 +1,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); +} diff --git a/contrib/bpftrace/zfs-trace.sh b/contrib/bpftrace/zfs-trace.sh new file mode 100755 index 000000000..13230b78c --- /dev/null +++ b/contrib/bpftrace/zfs-trace.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +ZVER=$(cat /sys/module/zfs/version | cut -f 1 -d '-') +KVER=$(uname -r) + +bpftrace \ + --include "/usr/src/zfs-$ZVER/$KVER/zfs_config.h" \ + -I "/usr/src/zfs-$ZVER/include" \ + -I "/usr/src/zfs-$ZVER/include/spl" \ + "$@" |