Skip to content

Instantly share code, notes, and snippets.

@iAnatoly
Created March 24, 2021 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iAnatoly/90ea93f48419270e309180b207141e2e to your computer and use it in GitHub Desktop.
Save iAnatoly/90ea93f48419270e309180b207141e2e to your computer and use it in GitHub Desktop.
bpftrace oneliners
# see https://github.com/iovisor/bpftrace/blob/master/docs/tutorial_one_liners.md
# histogram for udp_recvmsg timing
sudo bpftrace -e 'kprobe:udp_recvmsg { @start[tid] = nsecs; } kretprobe:udp_recvmsg /@start[tid]/ { @ns[comm] = hist(nsecs - @start[tid]); delete(@start[tid]); }'
# histogram for retval of udp_recvmsg (which is message size in bytes)
sudo bpftrace -e 'kretprobe:udp_recvmsg { @bytes[comm] = hist(retval); }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment