funccount-bpfcc: Count functions, tracepoints, and USDT probes
funccount-bpfcc [-h] [-p PID] [-i INTERVAL] [-d DURATION] [-T] [-r] [-D] [-c CPU] pattern
What it does
Count functions, tracepoints, and USDT probes. Part of the bcc tools (bpfcc-tools 0.35.0 on Ubuntu, installed as /usr/sbin/funccount-bpfcc; upstream and other distributions call it funccount). It loads an eBPF program, so it needs root.
Options you will use
pattern- search expression for events
-p, --pid PID- trace this PID only
-i, --interval INTERVAL- summary interval, seconds
-d, --duration DURATION- total duration of trace, seconds
-T, --timestamp- include timestamp on output
-r, --regexp- use regular expressions. Default is "*" wildcards only.
-D, --debug- print BPF program before starting (for debugging purposes)
-c, --cpu CPU- trace this CPU only
Examples
$ sudo funccount-bpfcc 'vfs_*'count kernel fns starting with "vfs"
$ sudo funccount-bpfcc -r '^vfs.*'same as above, using regular expressions
$ sudo funccount-bpfcc -Ti 5 'vfs_*'output every 5 seconds, with timestamps
$ sudo funccount-bpfcc -d 10 'vfs_*'trace for 10 seconds only
$ sudo funccount-bpfcc -p 185 'vfs_*'count vfs calls for PID 181 only
$ sudo funccount-bpfcc t:sched:sched_forkcount calls to the sched_fork tracepoint
$ sudo funccount-bpfcc -p 185 u:node:gc*count all GC USDT probes in node, PID 185
$ sudo funccount-bpfcc c:malloccount all malloc() calls in libc
Gotchas
- Kernel functions by pattern (kprobes), t:category:name tracepoints, u:lib:func uprobes. Count before you trace.
- As a normal user it fails with "could not open bpf map: ..., error: Operation not permitted" (unprivileged BPF is off on Ubuntu).
Try funccount-bpfcc in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.