blob: 9039ab33a7b0ca44a34edec543da954d61344cfa [file] [log] [blame]
Brendan Gregg3e55ae22015-09-10 12:11:35 -07001.TH funccount 8 "2015-08-18" "USER COMMANDS"
2.SH NAME
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -07003funccount \- Count function, tracepoint, and USDT probe calls matching a pattern. Uses Linux eBPF/bcc.
Brendan Gregg3e55ae22015-09-10 12:11:35 -07004.SH SYNOPSIS
Paul Chaignon72cbc7d2018-01-28 13:30:39 +01005.B funccount [\-h] [\-p PID] [\-i INTERVAL] [\-d DURATION] [\-T] [\-r] [\-D] pattern
Brendan Gregg3e55ae22015-09-10 12:11:35 -07006.SH DESCRIPTION
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -07007This tool is a quick way to determine which functions are being called,
Brendan Gregg3e55ae22015-09-10 12:11:35 -07008and at what rate. It uses in-kernel eBPF maps to count function calls.
9
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -070010WARNING: This uses dynamic tracing of (what can be many) functions, an
Brendan Gregg3e55ae22015-09-10 12:11:35 -070011activity that has had issues on some kernel versions (risk of panics or
12freezes). Test, and know what you are doing, before use.
13
14Since this uses BPF, only the root user can use this tool.
15.SH REQUIREMENTS
16CONFIG_BPF and bcc.
17.SH OPTIONS
18pattern
19Search pattern. Supports "*" wildcards. See EXAMPLES. You can also use \-r for regular expressions.
Brendan Gregg5cbcde22015-09-21 11:52:52 -070020.TP
Brendan Gregg3e55ae22015-09-10 12:11:35 -070021\-h
22Print usage message.
23.TP
24\-p PID
25Trace this process ID only.
26.TP
27\-i INTERVAL
28Print output every interval seconds.
29.TP
Brendan Greggb03d9eb2017-08-23 15:00:30 -070030\-d DURATION
31Total duration of trace in seconds.
32.TP
Brendan Gregg3e55ae22015-09-10 12:11:35 -070033\-T
34Include timestamps on output.
35.TP
36\-r
37Use regular expressions for the search pattern.
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -070038.TP
Paul Chaignon72cbc7d2018-01-28 13:30:39 +010039\-D
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -070040Print the BPF program before starting (for debugging purposes).
Brendan Gregg3e55ae22015-09-10 12:11:35 -070041.SH EXAMPLES
42.TP
43Count kernel functions beginning with "vfs_", until Ctrl-C is hit:
44#
45.B funccount 'vfs_*'
46.TP
47Count kernel functions beginning with "tcp_send", until Ctrl-C is hit:
48#
49.B funccount 'tcp_send*'
50.TP
51Print kernel functions beginning with "vfs_", every second:
52#
53.B funccount \-i 1 'vfs_*'
54.TP
Brendan Greggb03d9eb2017-08-23 15:00:30 -070055Print kernel functions beginning with "vfs_", for ten seconds only:
56#
57.B funccount \-d 10 'vfs_*'
58.TP
Brendan Gregg3e55ae22015-09-10 12:11:35 -070059Match kernel functions beginning with "vfs_", using regular expressions:
60#
61.B funccount \-r '^vfs_.*'
62.TP
63Count vfs calls for process ID 181 only:
64#
65.B funccount \-p 181 'vfs_*'
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -070066.TP
67Count calls to the sched_fork tracepoint, indicating a fork() performed:
68#
69.B funccount t:sched:sched_fork
70.TP
71Count all GC USDT probes in the Node process:
72#
73.B funccount -p 185 u:node:gc*
74.TP
75Count all malloc() calls in libc:
76#
77.B funccount c:malloc
Brendan Gregg3e55ae22015-09-10 12:11:35 -070078.SH FIELDS
79.TP
Brendan Gregg3e55ae22015-09-10 12:11:35 -070080FUNC
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -070081Function name
Brendan Gregg3e55ae22015-09-10 12:11:35 -070082.TP
83COUNT
84Number of calls while tracing
85.SH OVERHEAD
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -070086This traces functions and maintains in-kernel counts, which
87are asynchronously copied to user-space. While the rate of calls
Brendan Gregg3e55ae22015-09-10 12:11:35 -070088be very high (>1M/sec), this is a relatively efficient way to trace these
89events, and so the overhead is expected to be small for normal workloads.
Brendan Greggaa93d9f2015-09-21 11:52:21 -070090Measure in a test environment before use.
Brendan Gregg3e55ae22015-09-10 12:11:35 -070091.SH SOURCE
92This is from bcc.
93.IP
94https://github.com/iovisor/bcc
95.PP
96Also look in the bcc distribution for a companion _examples.txt file containing
97example usage, output, and commentary for this tool.
98.SH OS
99Linux
100.SH STABILITY
101Unstable - in development.
102.SH AUTHOR
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -0700103Brendan Gregg, Sasha Goldshtein
Brendan Gregg3e55ae22015-09-10 12:11:35 -0700104.SH SEE ALSO
Sasha Goldshteinff3b9f32016-10-08 07:01:21 -0700105stackcount(8)
106funclatency(8)
Brendan Gregg3e55ae22015-09-10 12:11:35 -0700107vfscount(8)