• Home
Name Date Size #Lines LOC

..--

android/03-May-2024-187119

arm64/03-May-2024-221,088194,822

bin/03-May-2024-

powerpc/03-May-2024-246,896225,148

x86/03-May-2024-254,884225,498

.gitignoreD03-May-2024526 5150

Android.bpD03-May-202411.8 KiB573502

MakefileD03-May-20243.2 KiB142117

README.mdD03-May-20244.6 KiB9576

bashreadline.bpf.cD03-May-2024910 3927

bashreadline.cD03-May-20245 KiB223178

bashreadline.hD03-May-2024256 148

bindsnoop.bpf.cD03-May-20243.5 KiB132109

bindsnoop.cD03-May-20246 KiB257220

bindsnoop.hD03-May-2024522 3226

biolatency.bpf.cD03-May-20243.6 KiB153116

biolatency.cD03-May-20248.9 KiB363320

biolatency.hD03-May-2024391 2315

biopattern.bpf.cD03-May-20241.2 KiB4637

biopattern.cD03-May-20245.4 KiB240205

biopattern.hD03-May-2024245 1510

biosnoop.bpf.cD03-May-20244.5 KiB195155

biosnoop.cD03-May-20248.3 KiB346300

biosnoop.hD03-May-2024465 2720

biostacks.bpf.cD03-May-20242.7 KiB11595

biostacks.cD03-May-20245.6 KiB224194

biostacks.hD03-May-2024505 2820

bitesize.bpf.cD03-May-20242 KiB8665

bitesize.cD03-May-20245.4 KiB242205

bitesize.hD03-May-2024404 2315

bits.bpf.hD03-May-2024638 3223

blk_types.hD03-May-20244.1 KiB12773

cachestat.bpf.cD03-May-2024891 4132

cachestat.cD03-May-20245.4 KiB237193

core_fixes.bpf.hD03-May-2024674 3015

cpudist.bpf.cD03-May-20242.2 KiB10084

cpudist.cD03-May-20246 KiB271232

cpudist.hD03-May-2024238 149

cpufreq.bpf.cD03-May-20241.6 KiB7257

cpufreq.cD03-May-20245.8 KiB256213

cpufreq.hD03-May-2024334 2014

drsnoop.bpf.cD03-May-20242.1 KiB9574

drsnoop.cD03-May-20245.7 KiB248211

drsnoop.hD03-May-2024268 1611

drsnoop_example.txtD03-May-20242.3 KiB7251

errno_helpers.cD03-May-20245.5 KiB233210

errno_helpers.hD03-May-2024186 84

execsnoop.bpf.cD03-May-20243.1 KiB130105

execsnoop.cD03-May-20247.6 KiB345296

execsnoop.hD03-May-2024646 2722

exitsnoop.bpf.cD03-May-20241.4 KiB5241

exitsnoop.cD03-May-20245 KiB223183

exitsnoop.hD03-May-2024304 1914

filelife.bpf.cD03-May-20241.9 KiB8163

filelife.cD03-May-20244 KiB178145

filelife.hD03-May-2024288 1611

filetop.bpf.cD03-May-20242.4 KiB9378

filetop.cD03-May-20247.2 KiB324280

filetop.hD03-May-2024465 3427

fsdist.bpf.cD03-May-20243.2 KiB192154

fsdist.cD03-May-202411.9 KiB442370

fsdist.hD03-May-2024257 2115

fsslower.bpf.cD03-May-20244.5 KiB209170

fsslower.cD03-May-202412 KiB456376

fsslower.hD03-May-2024407 2822

funclatency.bpf.cD03-May-20241.3 KiB7255

funclatency.cD03-May-20248 KiB349295

funclatency.hD03-May-2024155 128

gethostlatency.bpf.cD03-May-20241.7 KiB7658

gethostlatency.cD03-May-20246.7 KiB289240

gethostlatency.hD03-May-2024284 1611

hardirqs.bpf.cD03-May-20241.8 KiB9474

hardirqs.cD03-May-20246 KiB266226

hardirqs.hD03-May-2024243 1711

kernel.configD03-May-2024125.1 KiB4,8154,556

klockstat.bpf.cD03-May-20246.2 KiB280204

klockstat.cD03-May-202414.5 KiB591516

klockstat.hD03-May-2024448 2217

ksnoop.bpf.cD03-May-202412.5 KiB461313

ksnoop.cD03-May-202424 KiB1,013862

ksnoop.hD03-May-20242.9 KiB12489

llcstat.bpf.cD03-May-20241.1 KiB5242

llcstat.cD03-May-20245.6 KiB238204

llcstat.hD03-May-2024220 149

map_helpers.cD03-May-20242.2 KiB10784

map_helpers.hD03-May-2024328 126

maps.bpf.hD03-May-2024556 2718

mountsnoop.bpf.cD03-May-20243.4 KiB138115

mountsnoop.cD03-May-20247.2 KiB319272

mountsnoop.hD03-May-2024614 4134

numamove.bpf.cD03-May-20241 KiB5039

numamove.cD03-May-20242.7 KiB12098

offcputime.bpf.cD03-May-20242.8 KiB11295

offcputime.cD03-May-20249.1 KiB341302

offcputime.hD03-May-2024304 2014

oomkill.bpf.cD03-May-2024899 3123

oomkill.cD03-May-20243.6 KiB166135

oomkill.hD03-May-2024266 1611

opensnoop.bpf.cD03-May-20243.1 KiB130101

opensnoop.cD03-May-20247.4 KiB316262

opensnoop.hD03-May-2024420 2619

readahead.bpf.cD03-May-20241.9 KiB9070

readahead.cD03-May-20243.7 KiB166131

readahead.hD03-May-2024221 149

runqlat.bpf.cD03-May-20242.8 KiB132106

runqlat.cD03-May-20245.8 KiB253217

runqlat.hD03-May-2024241 149

runqlen.bpf.cD03-May-20241.1 KiB4932

runqlen.cD03-May-20246.7 KiB303258

runqlen.hD03-May-2024212 138

runqslower.bpf.cD03-May-20242.4 KiB10573

runqslower.cD03-May-20245.1 KiB218186

runqslower.hD03-May-2024283 1611

runqslower_example.txtD03-May-20241.9 KiB5540

softirqs.bpf.cD03-May-20241.3 KiB6854

softirqs.cD03-May-20245.5 KiB260217

softirqs.hD03-May-2024192 127

solisten.bpf.cD03-May-20242.5 KiB10282

solisten.cD03-May-20244.9 KiB213173

solisten.hD03-May-2024278 1813

stat.hD03-May-2024767 2821

statsnoop.bpf.cD03-May-20242.2 KiB9574

statsnoop.cD03-May-20244.4 KiB197164

statsnoop.hD03-May-2024285 1712

syscall_helpers.cD03-May-202411.3 KiB529486

syscall_helpers.hD03-May-2024313 138

syscount.bpf.cD03-May-20242.5 KiB10379

syscount.cD03-May-202411 KiB473403

syscount.hD03-May-2024274 1710

tcpconnect.bpf.cD03-May-20245.1 KiB221177

tcpconnect.cD03-May-20249.6 KiB420365

tcpconnect.hD03-May-2024690 4432

tcpconnlat.bpf.cD03-May-20242.5 KiB10989

tcpconnlat.cD03-May-20245.8 KiB237201

tcpconnlat.hD03-May-2024392 2721

tcprtt.bpf.cD03-May-20243.1 KiB128114

tcprtt.cD03-May-20247.1 KiB302264

tcprtt.hD03-May-2024214 149

tcpsynbl.bpf.cD03-May-20241.4 KiB6752

tcpsynbl.cD03-May-20245.5 KiB251210

tcpsynbl.hD03-May-2024192 127

trace_helpers.cD03-May-202421.9 KiB1,120915

trace_helpers.hD03-May-20242.9 KiB9850

uprobe_helpers.cD03-May-20246.4 KiB290227

uprobe_helpers.hD03-May-2024649 1913

vfsstat.bpf.cD03-May-20241.3 KiB7961

vfsstat.cD03-May-20244.7 KiB206176

vfsstat.hD03-May-2024224 1611

README.md

1Useful links
2------------
3
4- [BPF Portability and CO-RE](https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html)
5- [HOWTO: BCC to libbpf conversion](https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html)
6- [Tips & tricks for writing libbpf-tools](https://en.pingcap.com/blog/tips-and-tricks-for-writing-linux-bpf-applications-with-libbpf)
7
8Building
9-------
10
11To build libbpf-based tools, simply run `make`. This will build all the listed
12tools/applications. All the build artifacts, by default, go into .output
13subdirectory to keep source code and build artifacts completely separate. The
14only exception is resulting tool binaries, which are put in a current
15directory. `make clean` will clean up all the build artifacts, including
16generated binaries.
17
18Given that the libbpf package might not be available across wide variety of
19distributions, all libbpf-based tools are linked statically against a version
20of libbpf that BCC links against (from submodule under src/cc/libbpf). This
21results in binaries with minimal amount of dependencies (libc, libelf, and
22libz are linked dynamically, though, given their widespread availability).
23If your build fails because the libbpf submodule is outdated, try running `git
24submodule update --init --recursive`.
25
26Tools are expected to follow a simple naming convention:
27  - <tool>.c contains userspace C code of a tool.
28  - <tool>.bpf.c contains BPF C code, which gets compiled into BPF ELF file.
29    This ELF file is used to generate BPF skeleton <tool>.skel.h, which is
30    subsequently is included from <tool>.c.
31  - <tool>.h can optionally contain any types and constants, shared by both
32    BPF and userspace sides of a tool.
33
34For such cases, simply adding <tool> name to Makefile's APPS variable will
35ensure this tool is built alongside others.
36
37For more complicated applications, some extra Makefile rules might need to be
38created. For such cases, it is advised to put application into a dedicated
39subdirectory and link it from main Makefile.
40
41vmlinux.h generation
42-------------------
43
44vmlinux.h contains all kernel types, both exported and internal-only. BPF
45CO-RE-based applications are expected to include this file in their BPF
46program C source code to avoid dependency on kernel headers package.
47
48For more reproducible builds, vmlinux.h header file is pre-generated and
49checked in along the other sources. This is done to avoid dependency on
50specific user/build server's kernel configuration, because vmlinux.h
51generation depends on having a kernel with BTF type information built-in
52(which is enabled by `CONFIG_DEBUG_INFO_BTF=y` Kconfig option See below).
53
54vmlinux.h is generated from upstream Linux version at particular minor
55version tag. E.g., `vmlinux_505.h` is generated from v5.5 tag. Exact set of
56types available in compiled kernel depends on configuration used to compile
57it. To generate present vmlinux.h header, default configuration was used, with
58only extra `CONFIG_DEBUG_INFO_BTF=y` option enabled.
59
60Given different kernel version can have incompatible type definitions, it
61might be important to use vmlinux.h of a specific kernel version as a "base"
62version of header. To that extent, all vmlinux.h headers are versioned by
63appending <MAJOR><MINOR> suffix to a file name. There is always a symbolic
64link vmlinux.h, that points to whichever version is deemed to be default
65(usually, latest).
66
67bpftool
68-------
69
70bpftool is a universal tool used for inspection of BPF resources, as well as
71providing various extra BPF-related facilities, like code-generation of BPF
72program skeletons. The latter functionality is heavily used by these tools to
73load and interact with BPF programs.
74
75Given bpftool package can't yet be expected to be available widely across many
76distributions, bpftool binary is checked in into BCC repository in bin/
77subdirectory. Once bpftool package is more widely available, this can be
78changed in favor of using pre-packaged version of bpftool.
79
80
81Re-compiling your Kernel with CONFIG_DEBUG_INFO_BTF=y
82-----------------------------------------------------
83libbpf probes to see if your sys fs exports the file `/sys/kernel/btf/vmlinux` (from Kernel 5.5+) or if you have the ELF version in your system [`code`](https://github.com/libbpf/libbpf/blob/master/src/btf.c)
84Please note the ELF file could exist without the BTF info in it. Your Kconfig should contain the options below
85
861. Compile options
87```code
88CONFIG_DEBUG_INFO_BTF=y
89CONFIG_DEBUG_INFO=y
90```
912. Also, make sure that you have pahole 1.13 (or preferably 1.16+) during the
92kernel build (it comes from dwarves package). Without it, BTF won't be
93generated, and on older kernels you'd get only warning, but still would
94build kernel successfully
95