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