Skip to content

Commit 7e71ead

Browse files
committed
Merge remote-tracking branch 'upstream/master' into merge
2 parents e18046f + 3f138ce commit 7e71ead

File tree

278 files changed

+7348
-5249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+7348
-5249
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "src/cc/libbpf"]
2+
path = src/cc/libbpf
3+
url = https://github.com/libbpf/libbpf.git

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ endif()
99

1010
enable_testing()
1111

12+
# populate submodules (libbpf)
13+
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/cc/libbpf/src)
14+
execute_process(COMMAND git submodule update --init --recursive
15+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
16+
endif()
17+
1218
include(cmake/GetGitRevisionDescription.cmake)
1319
include(cmake/version.cmake)
1420
include(CMakeDependentOption)

CONTRIBUTING-SCRIPTS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _(Written by Brendan Gregg.)_
99
bcc has 2 types of scripts, in different directories:
1010

1111
- **/examples**: intended as short examples of bcc & eBPF code. You should focus on keeping it short, neat, and documented (code comments). A submission can just be the example code.
12-
- **/tools**: intended as production safe performance and troubleshooting tools. You should focus on it being useful, tested, low overhead, documented (incl. all caveats), and easy to use. A submission should involve 4 changes: the tool, a man page, an example file, and an addition to README.md. Follow [my lead](https://github.com/brendangregg/bcc/commit/9fa156273b395cfc5505f0fff5d6b7b1396f7daa), and see the checklist below. These will be run in mission critical environments as root, so if spending hours testing isn't for you, please submit your idea as an issue instead, or chat with us on irc.
12+
- **/tools**: intended as production safe performance and troubleshooting tools. You should focus on it being useful, tested, low overhead, documented (incl. all caveats), and easy to use. A submission should involve 4 changes: the tool, a man page, an example file, and an addition to README.md. Follow [my lead](https://github.com/brendangregg/bcc/commit/9fa156273b395cfc5505f0fff5d6b7b1396f7daa), and see the checklist below. These are run in mission critical environments as root (tech companies, financial institutions, government agencies), so if spending hours testing isn't for you, please submit your idea as an issue instead, or chat with us on irc.
1313

1414
More detail for each below.
1515

@@ -31,7 +31,9 @@ A checklist for bcc tool development:
3131
1. **Measure the overhead of the tool**. If you are running a micro-benchmark, how much slower is it with the tool running. Is more CPU consumed? Try to determine the worst case: run the micro-benchmark so that CPU headroom is exhausted, and then run the bcc tool. Can overhead be lowered?
3232
1. **Test again, and stress test**. You want to discover and fix all the bad things before others hit them.
3333
1. **Consider command line options**. Should it have -p for filtering on a PID? -T for timestamps? -i for interval? See other tools for examples, and copy the style: the usage message should list example usage at the end. Remember to keep the tool doing one thing and doing it well. Also, if there's one option that seems to be the common case, perhaps it should just be the first argument and not need a switch (no -X). A special case of this is *stat tools, like iostat/vmstat/etc, where the convention is [interval [count]].
34-
1. **Concise, intuitive, self-explanatory output**. The default output should meet the common need concisely. Leave much less useful fields and data to be shown with options: -v for verbose, etc. Consider including a startup message that's self-explanatory, eg "Tracing block I/O. Output every 1 seconds. Ctrl-C to end.". Also, try hard to keep the output less than 80 characters wide, especially the default output of the tool. That way, the output not only fits on the smallest reasonable terminal, it also fits well in slide decks, blog posts, articles, and printed material, all of which help education and adoption. Publishers of technical books often have templates they require books to conform to: it may not be an option to shrink or narrow the font to fit your output.
34+
1. **Concise, intuitive, self-explanatory output**. The default output should meet the common need concisely. Leave much less useful fields and data to be shown with options: -v for verbose, etc. Consider including a startup message that's self-explanatory, eg "Tracing block I/O. Output every 1 seconds. Ctrl-C to end.".
35+
1. **Default output <80 chars wide**. Try hard to keep the output less than 80 characters wide, especially the default output of the tool. That way, the output not only fits on the smallest reasonable terminal, it also fits well in slide decks, blog posts, articles, and printed material, all of which help education and adoption. Publishers of technical books often have templates they require books to conform to: it may not be an option to shrink or narrow the font to fit your output.
36+
1. **Short tool name**. Follow the style of the other tools, which follow the style of other /usr/bin utilities. They are short and easy to type. No underscores.
3537
1. **Use pep8 to check Python style**: pep8 --show-source --ignore=E123,E125,E126,E127,E128,E302 filename . Note that it misses some things, like consistent usage, so you'll still need to double check your script.
3638
1. **Make sure your script is Python3-ready**: Adding `from __future__ import absolute_import, division, print_function, unicode_literals` helps make your script Python3-ready.
3739
1. **Write an _example.txt file**. Copy the style in tools/biolatency_example.txt: start with an intro sentence, then have examples, and finish with the USAGE message. Explain everything: the first example should explain what we are seeing, even if this seems obvious. For some people it won't be obvious. Also explain why we are running the tool: what problems it's solving. It can take a long time (hours) to come up with good examples, but it's worth it. These will get copied around (eg, presentations, articles).

INSTALL.md

Lines changed: 99 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
- [Gentoo](#gentoo---portage)
99
- [openSUSE](#opensuse---binary)
1010
- [RHEL](#rhel---binary)
11+
- [Amazon Linux 1](#Amazon-Linux-1---Binary)
1112
* [Source](#source)
1213
- [Debian](#debian---source)
1314
- [Ubuntu](#ubuntu---source)
1415
- [Fedora](#fedora---source)
1516
- [openSUSE](#opensuse---source)
17+
- [Centos](#centos---source)
1618
- [Amazon Linux](#amazon-linux---source)
1719
* [Older Instructions](#older-instructions)
1820

@@ -30,7 +32,10 @@ CONFIG_NET_CLS_BPF=m
3032
# [optional, for tc actions]
3133
CONFIG_NET_ACT_BPF=m
3234
CONFIG_BPF_JIT=y
35+
# [for Linux kernel versions 4.1 through 4.6]
3336
CONFIG_HAVE_BPF_JIT=y
37+
# [for Linux kernel versions 4.7 and later]
38+
CONFIG_HAVE_EBPF_JIT=y
3439
# [optional, for kprobes]
3540
CONFIG_BPF_EVENTS=y
3641
```
@@ -54,7 +59,32 @@ Kernel compile flags can usually be checked by looking at `/proc/config.gz` or
5459

5560
The stable and the nightly packages are built for Ubuntu Xenial (16.04), Ubuntu Artful (17.10) and Ubuntu Bionic (18.04). The steps are very straightforward, no need to upgrade the kernel or compile from source!
5661

57-
**Stable and Signed Packages**
62+
**Ubuntu Packages**
63+
64+
As of Ubuntu Bionic (18.04), versions of bcc are available in the standard Ubuntu
65+
multiverse repository. The Ubuntu packages have slightly different names: where iovisor
66+
packages use `bcc` in the name (e.g. `bcc-tools`), Ubuntu packages use `bpfcc` (e.g.
67+
`bpfcc-tools`). Source packages and the binary packages produced from them can be
68+
found at [packages.ubuntu.com](https://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=bpfcc&searchon=sourcenames).
69+
70+
```bash
71+
sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
72+
```
73+
74+
The tools are installed in `/sbin` (`/usr/sbin` in Ubuntu 18.04) with a `-bpfcc` extension. Try running `sudo opensnoop-bpfcc`.
75+
76+
**_Note_**: the Ubuntu packages have different names but the package contents, in most cases, conflict
77+
and as such _cannot_ be installed alongside upstream packages. Should one choose to use
78+
Ubuntu's packages instead of the upstream iovisor packages (or vice-versa), the
79+
conflicting packages will need to be removed.
80+
81+
The iovisor packages _do_ declare they provide the Ubuntu packages and as such may be
82+
used to satisfy dependencies. For example, should one attempt to install package `foo`
83+
which declares a dependency on `libbpfcc` while the upstream `libbcc` package is installed,
84+
`foo` should install without trouble as `libbcc` declares that it provides `libbpfcc`.
85+
That said, one should always test such a configuration in case of version incompatibilities.
86+
87+
**Upstream Stable and Signed Packages**
5888

5989
```bash
6090
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4052245BD4284CDD
@@ -64,7 +94,7 @@ sudo apt-get install bcc-tools libbcc-examples linux-headers-$(uname -r)
6494
```
6595
(replace `xenial` with `artful` or `bionic` as appropriate). Tools will be installed under /usr/share/bcc/tools.
6696

67-
**Nightly Packages**
97+
**Upstream Nightly Packages**
6898

6999
```bash
70100
echo "deb [trusted=yes] https://repo.iovisor.org/apt/xenial xenial-nightly main" | sudo tee /etc/apt/sources.list.d/iovisor.list
@@ -73,16 +103,6 @@ sudo apt-get install bcc-tools libbcc-examples linux-headers-$(uname -r)
73103
```
74104
(replace `xenial` with `artful` or `bionic` as appropriate)
75105

76-
**Ubuntu Packages**
77-
78-
The previous commands will install the latest bcc from the iovisor repositories. It is also available from the standard Ubuntu multiverse repository, under the package name `bpfcc-tools`.
79-
80-
```bash
81-
sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
82-
```
83-
84-
The tools are installed in /sbin with a -bpfcc extension. Try running `sudo opensnoop-bpfcc`.
85-
86106
## Fedora - Binary
87107

88108
Ensure that you are running a 4.2+ kernel with `uname -r`. If not, install a 4.2+ kernel from
@@ -164,6 +184,23 @@ For RHEL 7.6, bcc is already included in the official yum repository as bcc-tool
164184
yum install bcc-tools
165185
```
166186

187+
## Amazon Linux 1 - Binary
188+
Use case 1. Install BCC for latest kernel available in repo:
189+
Tested on Amazon Linux AMI release 2018.03 (kernel 4.14.88-72.73.amzn1.x86_64)
190+
```
191+
sudo yum update kernel
192+
sudo yum install bcc
193+
sudo reboot
194+
```
195+
196+
Use case 2. Install BCC for your AMI's default kernel (no reboot required):
197+
Tested on Amazon Linux AMI release 2018.03 (kernel 4.14.77-70.59.amzn1.x86_64)
198+
```
199+
sudo yum install kernel-headers-$(uname -r | cut -d'.' -f1-5)
200+
sudo yum install kernel-devel-$(uname -r | cut -d'.' -f1-5)
201+
sudo yum install bcc
202+
```
203+
167204
# Source
168205

169206
## Debian - Source
@@ -355,13 +392,62 @@ sudo make install
355392
popd
356393
```
357394

395+
## Centos - Source
396+
397+
For Centos 7.6 only
398+
399+
### Install build dependencies
400+
401+
```
402+
sudo yum install -y epel-release
403+
sudo yum update -y
404+
sudo yum groupinstall -y "Development tools"
405+
sudo yum install -y elfutils-libelf-devel cmake3
406+
sudo yum install -y luajit luajit-devel # for Lua support
407+
```
408+
409+
### Install and compile LLVM
410+
411+
```
412+
curl -LO http://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz
413+
curl -LO http://releases.llvm.org/7.0.1/cfe-7.0.1.src.tar.xz
414+
tar -xf cfe-7.0.1.src.tar.xz
415+
tar -xf llvm-7.0.1.src.tar.xz
416+
417+
mkdir clang-build
418+
mkdir llvm-build
419+
420+
cd llvm-build
421+
cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
422+
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../llvm-7.0.1.src
423+
make
424+
sudo make install
425+
426+
cd ../clang-build
427+
cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
428+
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../cfe-7.0.1.src
429+
make
430+
sudo make install
431+
cd ..
432+
```
433+
434+
### Install and compile BCC
435+
436+
```
437+
git clone https://github.com/iovisor/bcc.git
438+
mkdir bcc/build; cd bcc/build
439+
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
440+
make
441+
sudo make install
442+
```
443+
358444
## Amazon Linux - Source
359445

360446
Tested on Amazon Linux AMI release 2018.03 (kernel 4.14.47-56.37.amzn1.x86_64)
361447

362448
### Install packages required for building
363449
```
364-
# enable epel to get iperf, luajit, luajit-devel, cmake3 (cmake3 is required to support c++11)
450+
# enable epel to get iperf, luajit, luajit-devel, cmake3 (cmake3 is required to support c++11)
365451
sudo yum-config-manager --enable epel
366452
367453
sudo yum install -y bison cmake3 ethtool flex git iperf libstdc++-static python-netaddr gcc gcc-c++ make zlib-devel elfutils-libelf-devel

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ pair of .c and .py files, and some are directories of files.
102102
- tools/[dbstat](tools/dbstat.py): Summarize MySQL/PostgreSQL query latency as a histogram. [Examples](tools/dbstat_example.txt).
103103
- tools/[dcsnoop](tools/dcsnoop.py): Trace directory entry cache (dcache) lookups. [Examples](tools/dcsnoop_example.txt).
104104
- tools/[dcstat](tools/dcstat.py): Directory entry cache (dcache) stats. [Examples](tools/dcstat_example.txt).
105-
- tools/[deadlock_detector](tools/deadlock_detector.py): Detect potential deadlocks on a running process. [Examples](tools/deadlock_detector_example.txt).
105+
- tools/[deadlock](tools/deadlock.py): Detect potential deadlocks on a running process. [Examples](tools/deadlock_example.txt).
106+
- tools/[drsnoop](tools/drsnoop.py): Trace direct reclaim events with PID and latency. [Examples](tools/drsnoop_example.txt).
106107
- tools/[execsnoop](tools/execsnoop.py): Trace new processes via exec() syscalls. [Examples](tools/execsnoop_example.txt).
107108
- tools/[ext4dist](tools/ext4dist.py): Summarize ext4 operation latency distribution as a histogram. [Examples](tools/ext4dist_example.txt).
108109
- tools/[ext4slower](tools/ext4slower.py): Trace slow ext4 operations. [Examples](tools/ext4slower_example.txt).
@@ -118,8 +119,9 @@ pair of .c and .py files, and some are directories of files.
118119
- tools/[killsnoop](tools/killsnoop.py): Trace signals issued by the kill() syscall. [Examples](tools/killsnoop_example.txt).
119120
- tools/[llcstat](tools/llcstat.py): Summarize CPU cache references and misses by process. [Examples](tools/llcstat_example.txt).
120121
- tools/[mdflush](tools/mdflush.py): Trace md flush events. [Examples](tools/mdflush_example.txt).
121-
- tools/[mysqld_qslower](tools/mysqld_qslower.py): Trace MySQL server queries slower than a threshold. [Examples](tools/mysqld_qslower_example.txt).
122122
- tools/[memleak](tools/memleak.py): Display outstanding memory allocations to find memory leaks. [Examples](tools/memleak_example.txt).
123+
- tools/[mountsnoop](tools/mountsnoop.py): Trace mount and umount syscalls system-wide. [Examples](tools/mountsnoop_example.txt).
124+
- tools/[mysqld_qslower](tools/mysqld_qslower.py): Trace MySQL server queries slower than a threshold. [Examples](tools/mysqld_qslower_example.txt).
123125
- tools/[nfsslower](tools/nfsslower.py): Trace slow NFS operations. [Examples](tools/nfsslower_example.txt).
124126
- tools/[nfsdist](tools/nfsdist.py): Summarize NFS operation latency distribution as a histogram. [Examples](tools/nfsdist_example.txt).
125127
- tools/[offcputime](tools/offcputime.py): Summarize off-CPU time by kernel stack trace. [Examples](tools/offcputime_example.txt).

SPECS/bcc.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ popd
8888
%install
8989
pushd build
9090
make install/strip DESTDIR=%{buildroot}
91+
# mangle shebangs
92+
find %{buildroot}/usr/share/bcc/{tools,examples} -type f -exec \
93+
sed -i -e '1 s|^#!/usr/bin/python$|#!'%{__python}'|' \
94+
-e '1 s|^#!/usr/bin/env python$|#!'%{__python}'|' {} \;
9195

9296
%package -n libbcc
9397
Summary: Shared Library for BPF Compiler Collection (BCC)

cmake/FindCompilerFlag.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ else()
1515
endif()
1616
set(CMAKE_REQUIRED_FLAGS "${_backup_c_flags}")
1717
endif()
18+
19+
# check whether reallocarray availability
20+
# this is used to satisfy reallocarray usage under src/cc/libbpf/
21+
CHECK_CXX_SOURCE_COMPILES(
22+
"
23+
#define _GNU_SOURCE
24+
#include <stdlib.h>
25+
26+
int main(void)
27+
{
28+
return !!reallocarray(NULL, 1, 1);
29+
}
30+
" HAVE_REALLOCARRAY_SUPPORT)

debian/changelog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
bcc (0.9.0-1) unstable; urgency=low
2+
3+
* Adds support for BTF
4+
* Uses libbpf common library to wrap syscall API
5+
* Many bugfixes and new tools
6+
7+
-- Brenden Blanco <bblanco@gmail.com> Thu, 07 Mar 2019 17:00:00 +0000
8+
19
bcc (0.8.0-1) unstable; urgency=low
210

311
* Support for kernel up to 5.0

debian/control

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Homepage: https://github.com/iovisor/bcc
1616

1717
Package: libbcc
1818
Architecture: all
19+
Provides: libbpfcc, libbpfcc-dev
20+
Conflicts: libbpfcc, libbpfcc-dev
1921
Depends: libc6, libstdc++6, libelf1
2022
Description: Shared Library for BPF Compiler Collection (BCC)
2123
Shared Library for BPF Compiler Collection to control BPF programs
@@ -28,20 +30,28 @@ Description: Examples for BPF Compiler Collection (BCC)
2830

2931
Package: python-bcc
3032
Architecture: all
33+
Provides: python-bpfcc
34+
Conflicts: python-bpfcc
3135
Depends: libbcc (= ${binary:Version}), python, binutils
3236
Description: Python wrappers for BPF Compiler Collection (BCC)
3337

3438
Package: python3-bcc
3539
Architecture: all
40+
Provides: python3-bpfcc
41+
Conflicts: python3-bpfcc
3642
Depends: libbcc (= ${binary:Version}), python3, binutils
3743
Description: Python3 wrappers for BPF Compiler Collection (BCC)
3844

3945
Package: bcc-tools
4046
Architecture: all
47+
Provides: bpfcc-tools
48+
Conflicts: bpfcc-tools
4149
Depends: python-bcc (= ${binary:Version})
4250
Description: Command line tools for BPF Compiler Collection (BCC)
4351

4452
Package: bcc-lua
4553
Architecture: all
54+
Provides: bpfcc-lua
55+
Conflicts: bpfcc-lua
4656
Depends: libbcc (= ${binary:Version})
4757
Description: Standalone tool to run BCC tracers written in Lua

0 commit comments

Comments
 (0)