1*387f9dfdSAndroid Build Coastguard Worker 2*387f9dfdSAndroid Build Coastguard Worker# BPF Compiler Collection (BCC) 3*387f9dfdSAndroid Build Coastguard Worker 4*387f9dfdSAndroid Build Coastguard WorkerBCC is a toolkit for creating efficient kernel tracing and manipulation 5*387f9dfdSAndroid Build Coastguard Workerprograms, and includes several useful tools and examples. It makes use of 6*387f9dfdSAndroid Build Coastguard Workerextended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature 7*387f9dfdSAndroid Build Coastguard Workerthat was first added to Linux 3.15. Much of what BCC uses requires Linux 4.1 8*387f9dfdSAndroid Build Coastguard Workerand above. 9*387f9dfdSAndroid Build Coastguard Worker 10*387f9dfdSAndroid Build Coastguard WorkereBPF was [described by](https://lkml.org/lkml/2015/4/14/232) Ingo Molnár as: 11*387f9dfdSAndroid Build Coastguard Worker 12*387f9dfdSAndroid Build Coastguard Worker> One of the more interesting features in this cycle is the ability to attach eBPF programs (user-defined, sandboxed bytecode executed by the kernel) to kprobes. This allows user-defined instrumentation on a live kernel image that can never crash, hang or interfere with the kernel negatively. 13*387f9dfdSAndroid Build Coastguard Worker 14*387f9dfdSAndroid Build Coastguard WorkerBCC makes BPF programs easier to write, with kernel instrumentation in C 15*387f9dfdSAndroid Build Coastguard Worker(and includes a C wrapper around LLVM), and front-ends in Python and lua. 16*387f9dfdSAndroid Build Coastguard WorkerIt is suited for many tasks, including performance analysis and network 17*387f9dfdSAndroid Build Coastguard Workertraffic control. 18*387f9dfdSAndroid Build Coastguard Worker 19*387f9dfdSAndroid Build Coastguard Worker## Screenshot 20*387f9dfdSAndroid Build Coastguard Worker 21*387f9dfdSAndroid Build Coastguard WorkerThis example traces a disk I/O kernel function, and populates an in-kernel 22*387f9dfdSAndroid Build Coastguard Workerpower-of-2 histogram of the I/O size. For efficiency, only the histogram 23*387f9dfdSAndroid Build Coastguard Workersummary is returned to user-level. 24*387f9dfdSAndroid Build Coastguard Worker 25*387f9dfdSAndroid Build Coastguard Worker```Shell 26*387f9dfdSAndroid Build Coastguard Worker# ./bitehist.py 27*387f9dfdSAndroid Build Coastguard WorkerTracing... Hit Ctrl-C to end. 28*387f9dfdSAndroid Build Coastguard Worker^C 29*387f9dfdSAndroid Build Coastguard Worker kbytes : count distribution 30*387f9dfdSAndroid Build Coastguard Worker 0 -> 1 : 3 | | 31*387f9dfdSAndroid Build Coastguard Worker 2 -> 3 : 0 | | 32*387f9dfdSAndroid Build Coastguard Worker 4 -> 7 : 211 |********** | 33*387f9dfdSAndroid Build Coastguard Worker 8 -> 15 : 0 | | 34*387f9dfdSAndroid Build Coastguard Worker 16 -> 31 : 0 | | 35*387f9dfdSAndroid Build Coastguard Worker 32 -> 63 : 0 | | 36*387f9dfdSAndroid Build Coastguard Worker 64 -> 127 : 1 | | 37*387f9dfdSAndroid Build Coastguard Worker 128 -> 255 : 800 |**************************************| 38*387f9dfdSAndroid Build Coastguard Worker``` 39*387f9dfdSAndroid Build Coastguard Worker 40*387f9dfdSAndroid Build Coastguard WorkerThe above output shows a bimodal distribution, where the largest mode of 41*387f9dfdSAndroid Build Coastguard Worker800 I/O was between 128 and 255 Kbytes in size. 42*387f9dfdSAndroid Build Coastguard Worker 43*387f9dfdSAndroid Build Coastguard WorkerSee the source: [bitehist.py](examples/tracing/bitehist.py). What this traces, 44*387f9dfdSAndroid Build Coastguard Workerwhat this stores, and how the data is presented, can be entirely customized. 45*387f9dfdSAndroid Build Coastguard WorkerThis shows only some of many possible capabilities. 46*387f9dfdSAndroid Build Coastguard Worker 47*387f9dfdSAndroid Build Coastguard Worker## Installing 48*387f9dfdSAndroid Build Coastguard Worker 49*387f9dfdSAndroid Build Coastguard WorkerSee [INSTALL.md](INSTALL.md) for installation steps on your platform. 50*387f9dfdSAndroid Build Coastguard Worker 51*387f9dfdSAndroid Build Coastguard Worker## FAQ 52*387f9dfdSAndroid Build Coastguard Worker 53*387f9dfdSAndroid Build Coastguard WorkerSee [FAQ.txt](FAQ.txt) for the most common troubleshoot questions. 54*387f9dfdSAndroid Build Coastguard Worker 55*387f9dfdSAndroid Build Coastguard Worker## Reference guide 56*387f9dfdSAndroid Build Coastguard Worker 57*387f9dfdSAndroid Build Coastguard WorkerSee [docs/reference_guide.md](docs/reference_guide.md) for the reference guide to the bcc and bcc/BPF APIs. 58*387f9dfdSAndroid Build Coastguard Worker 59*387f9dfdSAndroid Build Coastguard Worker## Contents 60*387f9dfdSAndroid Build Coastguard Worker 61*387f9dfdSAndroid Build Coastguard WorkerSome of these are single files that contain both C and Python, others have a 62*387f9dfdSAndroid Build Coastguard Workerpair of .c and .py files, and some are directories of files. 63*387f9dfdSAndroid Build Coastguard Worker 64*387f9dfdSAndroid Build Coastguard Worker### Tracing 65*387f9dfdSAndroid Build Coastguard Worker 66*387f9dfdSAndroid Build Coastguard Worker#### Examples: 67*387f9dfdSAndroid Build Coastguard Worker 68*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[bitehist.py](examples/tracing/bitehist.py): Block I/O size histogram. [Examples](examples/tracing/bitehist_example.txt). 69*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[disksnoop.py](examples/tracing/disksnoop.py): Trace block device I/O latency. [Examples](examples/tracing/disksnoop_example.txt). 70*387f9dfdSAndroid Build Coastguard Worker- examples/[hello_world.py](examples/hello_world.py): Prints "Hello, World!" for new processes. 71*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[mysqld_query.py](examples/tracing/mysqld_query.py): Trace MySQL server queries using USDT probes. [Examples](examples/tracing/mysqld_query_example.txt). 72*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[nodejs_http_server.py](examples/tracing/nodejs_http_server.py): Trace Node.js HTTP server requests using USDT probes. [Examples](examples/tracing/nodejs_http_server_example.txt). 73*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[stacksnoop](examples/tracing/stacksnoop.py): Trace a kernel function and print all kernel stack traces. [Examples](examples/tracing/stacksnoop_example.txt). 74*387f9dfdSAndroid Build Coastguard Worker- tools/[statsnoop](tools/statsnoop.py): Trace stat() syscalls. [Examples](tools/statsnoop_example.txt). 75*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[task_switch.py](examples/tracing/task_switch.py): Count task switches with from and to PIDs. 76*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[tcpv4connect.py](examples/tracing/tcpv4connect.py): Trace TCP IPv4 active connections. [Examples](examples/tracing/tcpv4connect_example.txt). 77*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[trace_fields.py](examples/tracing/trace_fields.py): Simple example of printing fields from traced events. 78*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[undump.py](examples/tracing/undump.py): Dump UNIX socket packets. [Examples](examples/tracing/undump_example.txt) 79*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[urandomread.py](examples/tracing/urandomread.py): A kernel tracepoint example, which traces random:urandom_read. [Examples](examples/tracing/urandomread_example.txt). 80*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[vfsreadlat.py](examples/tracing/vfsreadlat.py) examples/tracing/[vfsreadlat.c](examples/tracing/vfsreadlat.c): VFS read latency distribution. [Examples](examples/tracing/vfsreadlat_example.txt). 81*387f9dfdSAndroid Build Coastguard Worker- examples/tracing/[kvm_hypercall.py](examples/tracing/kvm_hypercall.py): Conditional static kernel tracepoints for KVM entry, exit and hypercall [Examples](examples/tracing/kvm_hypercall.txt). 82*387f9dfdSAndroid Build Coastguard Worker 83*387f9dfdSAndroid Build Coastguard Worker#### Tools: 84*387f9dfdSAndroid Build Coastguard Worker<center><a href="images/bcc_tracing_tools_2019.png"><img src="images/bcc_tracing_tools_2019.png" border=0 width=700></a></center> 85*387f9dfdSAndroid Build Coastguard Worker 86*387f9dfdSAndroid Build Coastguard Worker 87*387f9dfdSAndroid Build Coastguard Worker- tools/[argdist](tools/argdist.py): Display function parameter values as a histogram or frequency count. [Examples](tools/argdist_example.txt). 88*387f9dfdSAndroid Build Coastguard Worker- tools/[bashreadline](tools/bashreadline.py): Print entered bash commands system wide. [Examples](tools/bashreadline_example.txt). 89*387f9dfdSAndroid Build Coastguard Worker- tools/[bindsnoop](tools/bindsnoop.py): Trace IPv4 and IPv6 bind() system calls (bind()). [Examples](tools/bindsnoop_example.txt). 90*387f9dfdSAndroid Build Coastguard Worker- tools/[biolatency](tools/biolatency.py): Summarize block device I/O latency as a histogram. [Examples](tools/biolatency_example.txt). 91*387f9dfdSAndroid Build Coastguard Worker- tools/[biotop](tools/biotop.py): Top for disks: Summarize block device I/O by process. [Examples](tools/biotop_example.txt). 92*387f9dfdSAndroid Build Coastguard Worker- tools/[biopattern](tools/biopattern.py): Identify random/sequential disk access patterns. [Examples](tools/biopattern_example.txt). 93*387f9dfdSAndroid Build Coastguard Worker- tools/[biosnoop](tools/biosnoop.py): Trace block device I/O with PID and latency. [Examples](tools/biosnoop_example.txt). 94*387f9dfdSAndroid Build Coastguard Worker- tools/[bitesize](tools/bitesize.py): Show per process I/O size histogram. [Examples](tools/bitesize_example.txt). 95*387f9dfdSAndroid Build Coastguard Worker- tools/[bpflist](tools/bpflist.py): Display processes with active BPF programs and maps. [Examples](tools/bpflist_example.txt). 96*387f9dfdSAndroid Build Coastguard Worker- tools/[btrfsdist](tools/btrfsdist.py): Summarize btrfs operation latency distribution as a histogram. [Examples](tools/btrfsdist_example.txt). 97*387f9dfdSAndroid Build Coastguard Worker- tools/[btrfsslower](tools/btrfsslower.py): Trace slow btrfs operations. [Examples](tools/btrfsslower_example.txt). 98*387f9dfdSAndroid Build Coastguard Worker- tools/[capable](tools/capable.py): Trace security capability checks. [Examples](tools/capable_example.txt). 99*387f9dfdSAndroid Build Coastguard Worker- tools/[cachestat](tools/cachestat.py): Trace page cache hit/miss ratio. [Examples](tools/cachestat_example.txt). 100*387f9dfdSAndroid Build Coastguard Worker- tools/[cachetop](tools/cachetop.py): Trace page cache hit/miss ratio by processes. [Examples](tools/cachetop_example.txt). 101*387f9dfdSAndroid Build Coastguard Worker- tools/[compactsnoop](tools/compactsnoop.py): Trace compact zone events with PID and latency. [Examples](tools/compactsnoop_example.txt). 102*387f9dfdSAndroid Build Coastguard Worker- tools/[cpudist](tools/cpudist.py): Summarize on- and off-CPU time per task as a histogram. [Examples](tools/cpudist_example.txt) 103*387f9dfdSAndroid Build Coastguard Worker- tools/[cpuunclaimed](tools/cpuunclaimed.py): Sample CPU run queues and calculate unclaimed idle CPU. [Examples](tools/cpuunclaimed_example.txt) 104*387f9dfdSAndroid Build Coastguard Worker- tools/[criticalstat](tools/criticalstat.py): Trace and report long atomic critical sections in the kernel. [Examples](tools/criticalstat_example.txt) 105*387f9dfdSAndroid Build Coastguard Worker- tools/[dbslower](tools/dbslower.py): Trace MySQL/PostgreSQL queries slower than a threshold. [Examples](tools/dbslower_example.txt). 106*387f9dfdSAndroid Build Coastguard Worker- tools/[dbstat](tools/dbstat.py): Summarize MySQL/PostgreSQL query latency as a histogram. [Examples](tools/dbstat_example.txt). 107*387f9dfdSAndroid Build Coastguard Worker- tools/[dcsnoop](tools/dcsnoop.py): Trace directory entry cache (dcache) lookups. [Examples](tools/dcsnoop_example.txt). 108*387f9dfdSAndroid Build Coastguard Worker- tools/[dcstat](tools/dcstat.py): Directory entry cache (dcache) stats. [Examples](tools/dcstat_example.txt). 109*387f9dfdSAndroid Build Coastguard Worker- tools/[deadlock](tools/deadlock.py): Detect potential deadlocks on a running process. [Examples](tools/deadlock_example.txt). 110*387f9dfdSAndroid Build Coastguard Worker- tools/[dirtop](tools/dirtop.py): File reads and writes by directory. Top for directories. [Examples](tools/dirtop_example.txt). 111*387f9dfdSAndroid Build Coastguard Worker- tools/[drsnoop](tools/drsnoop.py): Trace direct reclaim events with PID and latency. [Examples](tools/drsnoop_example.txt). 112*387f9dfdSAndroid Build Coastguard Worker- tools/[execsnoop](tools/execsnoop.py): Trace new processes via exec() syscalls. [Examples](tools/execsnoop_example.txt). 113*387f9dfdSAndroid Build Coastguard Worker- tools/[exitsnoop](tools/exitsnoop.py): Trace process termination (exit and fatal signals). [Examples](tools/exitsnoop_example.txt). 114*387f9dfdSAndroid Build Coastguard Worker- tools/[ext4dist](tools/ext4dist.py): Summarize ext4 operation latency distribution as a histogram. [Examples](tools/ext4dist_example.txt). 115*387f9dfdSAndroid Build Coastguard Worker- tools/[ext4slower](tools/ext4slower.py): Trace slow ext4 operations. [Examples](tools/ext4slower_example.txt). 116*387f9dfdSAndroid Build Coastguard Worker- tools/[filelife](tools/filelife.py): Trace the lifespan of short-lived files. [Examples](tools/filelife_example.txt). 117*387f9dfdSAndroid Build Coastguard Worker- tools/[filegone](tools/filegone.py): Trace why file gone (deleted or renamed). [Examples](tools/filegone_example.txt). 118*387f9dfdSAndroid Build Coastguard Worker- tools/[fileslower](tools/fileslower.py): Trace slow synchronous file reads and writes. [Examples](tools/fileslower_example.txt). 119*387f9dfdSAndroid Build Coastguard Worker- tools/[filetop](tools/filetop.py): File reads and writes by filename and process. Top for files. [Examples](tools/filetop_example.txt). 120*387f9dfdSAndroid Build Coastguard Worker- tools/[funccount](tools/funccount.py): Count kernel function calls. [Examples](tools/funccount_example.txt). 121*387f9dfdSAndroid Build Coastguard Worker- tools/[funcinterval](tools/funcinterval.py): Time interval between the same function as a histogram. [Examples](tools/funcinterval_example.txt). 122*387f9dfdSAndroid Build Coastguard Worker- tools/[funclatency](tools/funclatency.py): Time functions and show their latency distribution. [Examples](tools/funclatency_example.txt). 123*387f9dfdSAndroid Build Coastguard Worker- tools/[funcslower](tools/funcslower.py): Trace slow kernel or user function calls. [Examples](tools/funcslower_example.txt). 124*387f9dfdSAndroid Build Coastguard Worker- tools/[gethostlatency](tools/gethostlatency.py): Show latency for getaddrinfo/gethostbyname[2] calls. [Examples](tools/gethostlatency_example.txt). 125*387f9dfdSAndroid Build Coastguard Worker- tools/[hardirqs](tools/hardirqs.py): Measure hard IRQ (hard interrupt) event time. [Examples](tools/hardirqs_example.txt). 126*387f9dfdSAndroid Build Coastguard Worker- tools/[inject](tools/inject.py): Targeted error injection with call chain and predicates [Examples](tools/inject_example.txt). 127*387f9dfdSAndroid Build Coastguard Worker- tools/[killsnoop](tools/killsnoop.py): Trace signals issued by the kill() syscall. [Examples](tools/killsnoop_example.txt). 128*387f9dfdSAndroid Build Coastguard Worker- tools/[klockstat](tools/klockstat.py): Traces kernel mutex lock events and display locks statistics. [Examples](tools/klockstat_example.txt). 129*387f9dfdSAndroid Build Coastguard Worker- tools/[kvmexit](tools/kvmexit.py): Display the exit_reason and its statistics of each vm exit. [Examples](tools/kvmexit_example.txt). 130*387f9dfdSAndroid Build Coastguard Worker- tools/[llcstat](tools/llcstat.py): Summarize CPU cache references and misses by process. [Examples](tools/llcstat_example.txt). 131*387f9dfdSAndroid Build Coastguard Worker- tools/[mdflush](tools/mdflush.py): Trace md flush events. [Examples](tools/mdflush_example.txt). 132*387f9dfdSAndroid Build Coastguard Worker- tools/[memleak](tools/memleak.py): Display outstanding memory allocations to find memory leaks. [Examples](tools/memleak_example.txt). 133*387f9dfdSAndroid Build Coastguard Worker- tools/[mountsnoop](tools/mountsnoop.py): Trace mount and umount syscalls system-wide. [Examples](tools/mountsnoop_example.txt). 134*387f9dfdSAndroid Build Coastguard Worker- tools/[mysqld_qslower](tools/mysqld_qslower.py): Trace MySQL server queries slower than a threshold. [Examples](tools/mysqld_qslower_example.txt). 135*387f9dfdSAndroid Build Coastguard Worker- tools/[netqtop](tools/netqtop.py) tools/[netqtop.c](tools/netqtop.c): Trace and display packets distribution on NIC queues. [Examples](tools/netqtop_example.txt). 136*387f9dfdSAndroid Build Coastguard Worker- tools/[nfsslower](tools/nfsslower.py): Trace slow NFS operations. [Examples](tools/nfsslower_example.txt). 137*387f9dfdSAndroid Build Coastguard Worker- tools/[nfsdist](tools/nfsdist.py): Summarize NFS operation latency distribution as a histogram. [Examples](tools/nfsdist_example.txt). 138*387f9dfdSAndroid Build Coastguard Worker- tools/[offcputime](tools/offcputime.py): Summarize off-CPU time by kernel stack trace. [Examples](tools/offcputime_example.txt). 139*387f9dfdSAndroid Build Coastguard Worker- tools/[offwaketime](tools/offwaketime.py): Summarize blocked time by kernel off-CPU stack and waker stack. [Examples](tools/offwaketime_example.txt). 140*387f9dfdSAndroid Build Coastguard Worker- tools/[oomkill](tools/oomkill.py): Trace the out-of-memory (OOM) killer. [Examples](tools/oomkill_example.txt). 141*387f9dfdSAndroid Build Coastguard Worker- tools/[opensnoop](tools/opensnoop.py): Trace open() syscalls. [Examples](tools/opensnoop_example.txt). 142*387f9dfdSAndroid Build Coastguard Worker- tools/[pidpersec](tools/pidpersec.py): Count new processes (via fork). [Examples](tools/pidpersec_example.txt). 143*387f9dfdSAndroid Build Coastguard Worker- tools/[ppchcalls](tools/ppchcalls.py): Summarize ppc hcall counts and latencies. [Examples](tools/ppchcalls_example.txt). 144*387f9dfdSAndroid Build Coastguard Worker- tools/[profile](tools/profile.py): Profile CPU usage by sampling stack traces at a timed interval. [Examples](tools/profile_example.txt). 145*387f9dfdSAndroid Build Coastguard Worker- tools/[readahead](tools/readahead.py): Show performance of read-ahead cache [Examples](tools/readahead_example.txt). 146*387f9dfdSAndroid Build Coastguard Worker- tools/[rdmaucma](tools/rdmaucma.py): Trace RDMA Userspace Connection Manager Access events. [Examples](tools/rdmaucma_example.txt). 147*387f9dfdSAndroid Build Coastguard Worker- tools/[reset-trace](tools/reset-trace.sh): Reset the state of tracing. Maintenance tool only. [Examples](tools/reset-trace_example.txt). 148*387f9dfdSAndroid Build Coastguard Worker- tools/[runqlat](tools/runqlat.py): Run queue (scheduler) latency as a histogram. [Examples](tools/runqlat_example.txt). 149*387f9dfdSAndroid Build Coastguard Worker- tools/[runqlen](tools/runqlen.py): Run queue length as a histogram. [Examples](tools/runqlen_example.txt). 150*387f9dfdSAndroid Build Coastguard Worker- tools/[runqslower](tools/runqslower.py): Trace long process scheduling delays. [Examples](tools/runqslower_example.txt). 151*387f9dfdSAndroid Build Coastguard Worker- tools/[shmsnoop](tools/shmsnoop.py): Trace System V shared memory syscalls. [Examples](tools/shmsnoop_example.txt). 152*387f9dfdSAndroid Build Coastguard Worker- tools/[sofdsnoop](tools/sofdsnoop.py): Trace FDs passed through unix sockets. [Examples](tools/sofdsnoop_example.txt). 153*387f9dfdSAndroid Build Coastguard Worker- tools/[slabratetop](tools/slabratetop.py): Kernel SLAB/SLUB memory cache allocation rate top. [Examples](tools/slabratetop_example.txt). 154*387f9dfdSAndroid Build Coastguard Worker- tools/[softirqs](tools/softirqs.py): Measure soft IRQ (soft interrupt) event time. [Examples](tools/softirqs_example.txt). 155*387f9dfdSAndroid Build Coastguard Worker- tools/[solisten](tools/solisten.py): Trace TCP socket listen. [Examples](tools/solisten_example.txt). 156*387f9dfdSAndroid Build Coastguard Worker- tools/[sslsniff](tools/sslsniff.py): Sniff OpenSSL written and readed data. [Examples](tools/sslsniff_example.txt). 157*387f9dfdSAndroid Build Coastguard Worker- tools/[stackcount](tools/stackcount.py): Count kernel function calls and their stack traces. [Examples](tools/stackcount_example.txt). 158*387f9dfdSAndroid Build Coastguard Worker- tools/[syncsnoop](tools/syncsnoop.py): Trace sync() syscall. [Examples](tools/syncsnoop_example.txt). 159*387f9dfdSAndroid Build Coastguard Worker- tools/[syscount](tools/syscount.py): Summarize syscall counts and latencies. [Examples](tools/syscount_example.txt). 160*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpaccept](tools/tcpaccept.py): Trace TCP passive connections (accept()). [Examples](tools/tcpaccept_example.txt). 161*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpconnect](tools/tcpconnect.py): Trace TCP active connections (connect()). [Examples](tools/tcpconnect_example.txt). 162*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpconnlat](tools/tcpconnlat.py): Trace TCP active connection latency (connect()). [Examples](tools/tcpconnlat_example.txt). 163*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpdrop](tools/tcpdrop.py): Trace kernel-based TCP packet drops with details. [Examples](tools/tcpdrop_example.txt). 164*387f9dfdSAndroid Build Coastguard Worker- tools/[tcplife](tools/tcplife.py): Trace TCP sessions and summarize lifespan. [Examples](tools/tcplife_example.txt). 165*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpretrans](tools/tcpretrans.py): Trace TCP retransmits and TLPs. [Examples](tools/tcpretrans_example.txt). 166*387f9dfdSAndroid Build Coastguard Worker- tools/[tcprtt](tools/tcprtt.py): Trace TCP round trip time. [Examples](tools/tcprtt_example.txt). 167*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpstates](tools/tcpstates.py): Trace TCP session state changes with durations. [Examples](tools/tcpstates_example.txt). 168*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpsubnet](tools/tcpsubnet.py): Summarize and aggregate TCP send by subnet. [Examples](tools/tcpsubnet_example.txt). 169*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpsynbl](tools/tcpsynbl.py): Show TCP SYN backlog. [Examples](tools/tcpsynbl_example.txt). 170*387f9dfdSAndroid Build Coastguard Worker- tools/[tcptop](tools/tcptop.py): Summarize TCP send/recv throughput by host. Top for TCP. [Examples](tools/tcptop_example.txt). 171*387f9dfdSAndroid Build Coastguard Worker- tools/[tcptracer](tools/tcptracer.py): Trace TCP established connections (connect(), accept(), close()). [Examples](tools/tcptracer_example.txt). 172*387f9dfdSAndroid Build Coastguard Worker- tools/[tcpcong](tools/tcpcong.py): Trace TCP socket congestion control status duration. [Examples](tools/tcpcong_example.txt). 173*387f9dfdSAndroid Build Coastguard Worker- tools/[threadsnoop](tools/threadsnoop.py): List new thread creation. [Examples](tools/threadsnoop_example.txt). 174*387f9dfdSAndroid Build Coastguard Worker- tools/[tplist](tools/tplist.py): Display kernel tracepoints or USDT probes and their formats. [Examples](tools/tplist_example.txt). 175*387f9dfdSAndroid Build Coastguard Worker- tools/[trace](tools/trace.py): Trace arbitrary functions, with filters. [Examples](tools/trace_example.txt). 176*387f9dfdSAndroid Build Coastguard Worker- tools/[ttysnoop](tools/ttysnoop.py): Watch live output from a tty or pts device. [Examples](tools/ttysnoop_example.txt). 177*387f9dfdSAndroid Build Coastguard Worker- tools/[ucalls](tools/lib/ucalls.py): Summarize method calls or Linux syscalls in high-level languages. [Examples](tools/lib/ucalls_example.txt). 178*387f9dfdSAndroid Build Coastguard Worker- tools/[uflow](tools/lib/uflow.py): Print a method flow graph in high-level languages. [Examples](tools/lib/uflow_example.txt). 179*387f9dfdSAndroid Build Coastguard Worker- tools/[ugc](tools/lib/ugc.py): Trace garbage collection events in high-level languages. [Examples](tools/lib/ugc_example.txt). 180*387f9dfdSAndroid Build Coastguard Worker- tools/[uobjnew](tools/lib/uobjnew.py): Summarize object allocation events by object type and number of bytes allocated. [Examples](tools/lib/uobjnew_example.txt). 181*387f9dfdSAndroid Build Coastguard Worker- tools/[ustat](tools/lib/ustat.py): Collect events such as GCs, thread creations, object allocations, exceptions and more in high-level languages. [Examples](tools/lib/ustat_example.txt). 182*387f9dfdSAndroid Build Coastguard Worker- tools/[uthreads](tools/lib/uthreads.py): Trace thread creation events in Java and raw pthreads. [Examples](tools/lib/uthreads_example.txt). 183*387f9dfdSAndroid Build Coastguard Worker- tools/[vfscount](tools/vfscount.py): Count VFS calls. [Examples](tools/vfscount_example.txt). 184*387f9dfdSAndroid Build Coastguard Worker- tools/[vfsstat](tools/vfsstat.py): Count some VFS calls, with column output. [Examples](tools/vfsstat_example.txt). 185*387f9dfdSAndroid Build Coastguard Worker- tools/[virtiostat](tools/virtiostat.py): Show VIRTIO device IO statistics. [Examples](tools/virtiostat_example.txt). 186*387f9dfdSAndroid Build Coastguard Worker- tools/[wakeuptime](tools/wakeuptime.py): Summarize sleep to wakeup time by waker kernel stack. [Examples](tools/wakeuptime_example.txt). 187*387f9dfdSAndroid Build Coastguard Worker- tools/[xfsdist](tools/xfsdist.py): Summarize XFS operation latency distribution as a histogram. [Examples](tools/xfsdist_example.txt). 188*387f9dfdSAndroid Build Coastguard Worker- tools/[xfsslower](tools/xfsslower.py): Trace slow XFS operations. [Examples](tools/xfsslower_example.txt). 189*387f9dfdSAndroid Build Coastguard Worker- tools/[zfsdist](tools/zfsdist.py): Summarize ZFS operation latency distribution as a histogram. [Examples](tools/zfsdist_example.txt). 190*387f9dfdSAndroid Build Coastguard Worker- tools/[zfsslower](tools/zfsslower.py): Trace slow ZFS operations. [Examples](tools/zfsslower_example.txt). 191*387f9dfdSAndroid Build Coastguard Worker 192*387f9dfdSAndroid Build Coastguard Worker### Networking 193*387f9dfdSAndroid Build Coastguard Worker 194*387f9dfdSAndroid Build Coastguard WorkerExamples: 195*387f9dfdSAndroid Build Coastguard Worker 196*387f9dfdSAndroid Build Coastguard Worker- examples/networking/[distributed_bridge/](examples/networking/distributed_bridge): Distributed bridge example. 197*387f9dfdSAndroid Build Coastguard Worker- examples/networking/[http_filter/](examples/networking/http_filter): Simple HTTP filter example. 198*387f9dfdSAndroid Build Coastguard Worker- examples/networking/[simple_tc.py](examples/networking/simple_tc.py): Simple traffic control example. 199*387f9dfdSAndroid Build Coastguard Worker- examples/networking/[simulation.py](examples/networking/simulation.py): Simulation helper. 200*387f9dfdSAndroid Build Coastguard Worker- examples/networking/neighbor_sharing/[tc_neighbor_sharing.py](examples/networking/neighbor_sharing/tc_neighbor_sharing.py) examples/networking/neighbor_sharing/[tc_neighbor_sharing.c](examples/networking/neighbor_sharing/tc_neighbor_sharing.c): Per-IP classification and rate limiting. 201*387f9dfdSAndroid Build Coastguard Worker- examples/networking/[tunnel_monitor/](examples/networking/tunnel_monitor): Efficiently monitor traffic flows. 202*387f9dfdSAndroid Build Coastguard Worker- examples/networking/vlan_learning/[vlan_learning.py](examples/networking/vlan_learning/vlan_learning.py) examples/[vlan_learning.c](examples/networking/vlan_learning/vlan_learning.c): Demux Ethernet traffic into worker veth+namespaces. 203*387f9dfdSAndroid Build Coastguard Worker 204*387f9dfdSAndroid Build Coastguard Worker### BPF Introspection: 205*387f9dfdSAndroid Build Coastguard Worker 206*387f9dfdSAndroid Build Coastguard WorkerTools that help to introspect BPF programs. 207*387f9dfdSAndroid Build Coastguard Worker 208*387f9dfdSAndroid Build Coastguard Worker- introspection/[bps.c](introspection/bps.c): List all BPF programs loaded into the kernel. 'ps' for BPF programs. [Examples](introspection/bps_example.txt). 209*387f9dfdSAndroid Build Coastguard Worker 210*387f9dfdSAndroid Build Coastguard Worker## Motivation 211*387f9dfdSAndroid Build Coastguard Worker 212*387f9dfdSAndroid Build Coastguard WorkerBPF guarantees that the programs loaded into the kernel cannot crash, and 213*387f9dfdSAndroid Build Coastguard Workercannot run forever, but yet BPF is general purpose enough to perform many 214*387f9dfdSAndroid Build Coastguard Workerarbitrary types of computation. Currently, it is possible to write a program in 215*387f9dfdSAndroid Build Coastguard WorkerC that will compile into a valid BPF program, yet it is vastly easier to 216*387f9dfdSAndroid Build Coastguard Workerwrite a C program that will compile into invalid BPF (C is like that). The user 217*387f9dfdSAndroid Build Coastguard Workerwon't know until trying to run the program whether it was valid or not. 218*387f9dfdSAndroid Build Coastguard Worker 219*387f9dfdSAndroid Build Coastguard WorkerWith a BPF-specific frontend, one should be able to write in a language and 220*387f9dfdSAndroid Build Coastguard Workerreceive feedback from the compiler on the validity as it pertains to a BPF 221*387f9dfdSAndroid Build Coastguard Workerbackend. This toolkit aims to provide a frontend that can only create valid BPF 222*387f9dfdSAndroid Build Coastguard Workerprograms while still harnessing its full flexibility. 223*387f9dfdSAndroid Build Coastguard Worker 224*387f9dfdSAndroid Build Coastguard WorkerFurthermore, current integrations with BPF have a kludgy workflow, sometimes 225*387f9dfdSAndroid Build Coastguard Workerinvolving compiling directly in a linux kernel source tree. This toolchain aims 226*387f9dfdSAndroid Build Coastguard Workerto minimize the time that a developer spends getting BPF compiled, and instead 227*387f9dfdSAndroid Build Coastguard Workerfocus on the applications that can be written and the problems that can be 228*387f9dfdSAndroid Build Coastguard Workersolved with BPF. 229*387f9dfdSAndroid Build Coastguard Worker 230*387f9dfdSAndroid Build Coastguard WorkerThe features of this toolkit include: 231*387f9dfdSAndroid Build Coastguard Worker* End-to-end BPF workflow in a shared library 232*387f9dfdSAndroid Build Coastguard Worker * A modified C language for BPF backends 233*387f9dfdSAndroid Build Coastguard Worker * Integration with llvm-bpf backend for JIT 234*387f9dfdSAndroid Build Coastguard Worker * Dynamic (un)loading of JITed programs 235*387f9dfdSAndroid Build Coastguard Worker * Support for BPF kernel hooks: socket filters, tc classifiers, 236*387f9dfdSAndroid Build Coastguard Worker tc actions, and kprobes 237*387f9dfdSAndroid Build Coastguard Worker* Bindings for Python 238*387f9dfdSAndroid Build Coastguard Worker* Examples for socket filters, tc classifiers, and kprobes 239*387f9dfdSAndroid Build Coastguard Worker* Self-contained tools for tracing a running system 240*387f9dfdSAndroid Build Coastguard Worker 241*387f9dfdSAndroid Build Coastguard WorkerIn the future, more bindings besides python will likely be supported. Feel free 242*387f9dfdSAndroid Build Coastguard Workerto add support for the language of your choice and send a pull request! 243*387f9dfdSAndroid Build Coastguard Worker 244*387f9dfdSAndroid Build Coastguard Worker## Tutorials 245*387f9dfdSAndroid Build Coastguard Worker 246*387f9dfdSAndroid Build Coastguard Worker- [docs/tutorial.md](docs/tutorial.md): Using bcc tools to solve performance, troubleshooting, and networking issues. 247*387f9dfdSAndroid Build Coastguard Worker- [docs/tutorial_bcc_python_developer.md](docs/tutorial_bcc_python_developer.md): Developing new bcc programs using the Python interface. 248*387f9dfdSAndroid Build Coastguard Worker 249*387f9dfdSAndroid Build Coastguard Worker### Networking 250*387f9dfdSAndroid Build Coastguard Worker 251*387f9dfdSAndroid Build Coastguard WorkerAt Red Hat Summit 2015, BCC was presented as part of a [session on BPF](http://www.devnation.org/#7784f1f7513e8542e4db519e79ff5eec). 252*387f9dfdSAndroid Build Coastguard WorkerA multi-host vxlan environment is simulated and a BPF program used to monitor 253*387f9dfdSAndroid Build Coastguard Workerone of the physical interfaces. The BPF program keeps statistics on the inner 254*387f9dfdSAndroid Build Coastguard Workerand outer IP addresses traversing the interface, and the userspace component 255*387f9dfdSAndroid Build Coastguard Workerturns those statistics into a graph showing the traffic distribution at 256*387f9dfdSAndroid Build Coastguard Workermultiple granularities. See the code [here](examples/networking/tunnel_monitor). 257*387f9dfdSAndroid Build Coastguard Worker 258*387f9dfdSAndroid Build Coastguard Worker## Contributing 259*387f9dfdSAndroid Build Coastguard Worker 260*387f9dfdSAndroid Build Coastguard WorkerAlready pumped up to commit some code? Here are some resources to join the 261*387f9dfdSAndroid Build Coastguard Workerdiscussions in the [IOVisor](https://www.iovisor.org/) community and see 262*387f9dfdSAndroid Build Coastguard Workerwhat you want to work on. 263*387f9dfdSAndroid Build Coastguard Worker 264*387f9dfdSAndroid Build Coastguard Worker* _Mailing List:_ https://lists.iovisor.org/mailman/listinfo/iovisor-dev 265*387f9dfdSAndroid Build Coastguard Worker* _IRC:_ #iovisor at irc.oftc.net 266*387f9dfdSAndroid Build Coastguard Worker* _BCC Issue Tracker:_ [Github Issues](https://github.com/iovisor/bcc/issues) 267*387f9dfdSAndroid Build Coastguard Worker* _A guide for contributing scripts:_ [CONTRIBUTING-SCRIPTS.md](CONTRIBUTING-SCRIPTS.md) 268*387f9dfdSAndroid Build Coastguard Worker 269*387f9dfdSAndroid Build Coastguard Worker## External links 270*387f9dfdSAndroid Build Coastguard Worker 271*387f9dfdSAndroid Build Coastguard WorkerLooking for more information on BCC and how it's being used? You can find links to other BCC content on the web in [LINKS.md](LINKS.md). 272