• Home
Name Date Size #Lines LOC

..--

android/06-Sep-2024-187119

arm64/06-Sep-2024-295,098260,314

blazesym/06-Sep-2024-

bpftool/06-Sep-2024-

loongarch/06-Sep-2024-236,816210,496

powerpc/06-Sep-2024-258,598232,856

riscv/06-Sep-2024-293,700257,336

x86/06-Sep-2024-268,584237,444

.gitignoreD06-Sep-2024681 6665

Android.bpD06-Sep-202414.9 KiB715625

MakefileD06-Sep-20245.7 KiB246202

Makefile.btfgenD06-Sep-20241.3 KiB4128

README.mdD06-Sep-20245.6 KiB12297

bashreadline.bpf.cD06-Sep-2024910 3927

bashreadline.cD06-Sep-20245.3 KiB237190

bashreadline.hD06-Sep-2024256 148

bindsnoop.bpf.cD06-Sep-20244 KiB152124

bindsnoop.cD06-Sep-20247 KiB298257

bindsnoop.hD06-Sep-2024522 3226

biolatency.bpf.cD06-Sep-20244.2 KiB187141

biolatency.cD06-Sep-20249 KiB360316

biolatency.hD06-Sep-2024391 2315

biopattern.bpf.cD06-Sep-20241.5 KiB5848

biopattern.cD06-Sep-20245.7 KiB248212

biopattern.hD06-Sep-2024245 1510

biosnoop.bpf.cD06-Sep-20244.8 KiB205163

biosnoop.cD06-Sep-20248.8 KiB370318

biosnoop.hD06-Sep-2024465 2720

biostacks.bpf.cD06-Sep-20243 KiB134111

biostacks.cD06-Sep-20246.2 KiB248212

biostacks.hD06-Sep-2024505 2820

biotop.bpf.cD06-Sep-20243.1 KiB143108

biotop.cD06-Sep-20249.9 KiB471391

biotop.hD06-Sep-2024655 3926

bitesize.bpf.cD06-Sep-20241.9 KiB8665

bitesize.cD06-Sep-20245.3 KiB241204

bitesize.hD06-Sep-2024404 2315

bits.bpf.hD06-Sep-2024638 3223

blk_types.hD06-Sep-20244.1 KiB12773

btf_helpers.cD06-Sep-20244.8 KiB248196

btf_helpers.hD06-Sep-2024277 126

cachestat.bpf.cD06-Sep-20241.9 KiB9175

cachestat.cD06-Sep-20247.7 KiB282230

capable.bpf.cD06-Sep-20243.6 KiB163123

capable.cD06-Sep-202410.7 KiB416362

capable.hD06-Sep-2024463 3323

compat.bpf.hD06-Sep-20241 KiB4632

compat.cD06-Sep-20242.3 KiB11695

compat.hD06-Sep-20241.1 KiB4733

core_fixes.bpf.hD06-Sep-20247.6 KiB253133

cpudist.bpf.cD06-Sep-20242.8 KiB122102

cpudist.cD06-Sep-20246.9 KiB304262

cpudist.hD06-Sep-2024238 149

cpufreq.bpf.cD06-Sep-20241.9 KiB8668

cpufreq.cD06-Sep-20246.7 KiB292243

cpufreq.hD06-Sep-2024334 2014

drsnoop.bpf.cD06-Sep-20242.6 KiB11792

drsnoop.cD06-Sep-20246 KiB255217

drsnoop.hD06-Sep-2024268 1611

drsnoop_example.txtD06-Sep-20242.3 KiB7251

errno_helpers.cD06-Sep-20245.5 KiB233210

errno_helpers.hD06-Sep-2024186 84

execsnoop.bpf.cD06-Sep-20243.5 KiB149119

execsnoop.cD06-Sep-20248.5 KiB381329

execsnoop.hD06-Sep-2024646 2722

exitsnoop.bpf.cD06-Sep-20241.7 KiB6350

exitsnoop.cD06-Sep-20246 KiB264220

exitsnoop.hD06-Sep-2024304 1914

filelife.bpf.cD06-Sep-20243.5 KiB13487

filelife.cD06-Sep-20244.5 KiB191154

filelife.hD06-Sep-2024288 1611

filetop.bpf.cD06-Sep-20242.4 KiB9378

filetop.cD06-Sep-20247.4 KiB332287

filetop.hD06-Sep-2024465 3427

fsdist.bpf.cD06-Sep-20243.2 KiB194156

fsdist.cD06-Sep-202412.2 KiB450377

fsdist.hD06-Sep-2024269 2115

fsslower.bpf.cD06-Sep-20244.6 KiB209170

fsslower.cD06-Sep-202412.3 KiB464383

fsslower.hD06-Sep-2024417 2822

funclatency.bpf.cD06-Sep-20241.9 KiB10886

funclatency.cD06-Sep-202410.3 KiB438370

funclatency.hD06-Sep-2024155 128

gethostlatency.bpf.cD06-Sep-20241.7 KiB7658

gethostlatency.cD06-Sep-20247 KiB299249

gethostlatency.hD06-Sep-2024284 1611

hardirqs.bpf.cD06-Sep-20242.8 KiB131104

hardirqs.cD06-Sep-20246.6 KiB289245

hardirqs.hD06-Sep-2024243 1711

javagc.bpf.cD06-Sep-20241.6 KiB8266

javagc.cD06-Sep-20245.6 KiB244200

javagc.hD06-Sep-2024219 138

kernel.configD06-Sep-2024125.1 KiB4,8154,556

klockstat.bpf.cD06-Sep-202415.1 KiB743579

klockstat.cD06-Sep-202421.8 KiB789686

klockstat.hD06-Sep-2024499 2419

ksnoop.bpf.cD06-Sep-202412.6 KiB461313

ksnoop.cD06-Sep-202423.9 KiB1,009858

ksnoop.hD06-Sep-20242.9 KiB12489

llcstat.bpf.cD06-Sep-20241.2 KiB5946

llcstat.cD06-Sep-20246.3 KiB270232

llcstat.hD06-Sep-2024284 2014

map_helpers.cD06-Sep-20242.2 KiB10784

map_helpers.hD06-Sep-2024328 126

maps.bpf.hD06-Sep-20241.4 KiB4318

mdflush.bpf.cD06-Sep-20241.3 KiB4738

mdflush.cD06-Sep-20243.5 KiB163127

mdflush.hD06-Sep-2024302 1610

memleak.bpf.cD06-Sep-20249.4 KiB460357

memleak.cD06-Sep-202427.1 KiB1,069818

memleak.hD06-Sep-2024332 2217

mountsnoop.bpf.cD06-Sep-20243.1 KiB128105

mountsnoop.cD06-Sep-20247.4 KiB334284

mountsnoop.hD06-Sep-2024614 4134

numamove.bpf.cD06-Sep-20241.4 KiB7156

numamove.cD06-Sep-20243.3 KiB135109

offcputime.bpf.cD06-Sep-20242.8 KiB11396

offcputime.cD06-Sep-20249.8 KiB366326

offcputime.hD06-Sep-2024304 2014

oomkill.bpf.cD06-Sep-2024846 3022

oomkill.cD06-Sep-20244.1 KiB188152

oomkill.hD06-Sep-2024266 1611

opensnoop.bpf.cD06-Sep-20243.3 KiB137106

opensnoop.cD06-Sep-20249 KiB398339

opensnoop.hD06-Sep-2024439 2720

readahead.bpf.cD06-Sep-20241.8 KiB8868

readahead.cD06-Sep-20243.7 KiB165130

readahead.hD06-Sep-2024221 149

runqlat.bpf.cD06-Sep-20244 KiB178142

runqlat.cD06-Sep-20246.9 KiB291252

runqlat.hD06-Sep-2024241 149

runqlen.bpf.cD06-Sep-20241.2 KiB5336

runqlen.cD06-Sep-20247.1 KiB318272

runqlen.hD06-Sep-2024212 138

runqslower.bpf.cD06-Sep-20242.8 KiB11889

runqslower.cD06-Sep-20245.5 KiB227194

runqslower.hD06-Sep-2024283 1611

runqslower_example.txtD06-Sep-20241.9 KiB5540

sigsnoop.bpf.cD06-Sep-20243.2 KiB146115

sigsnoop.cD06-Sep-20246.1 KiB265224

sigsnoop.hD06-Sep-2024283 1711

sigsnoop_example.txtD06-Sep-20241.6 KiB4633

slabratetop.bpf.cD06-Sep-20241.3 KiB5440

slabratetop.cD06-Sep-20246.7 KiB307263

slabratetop.hD06-Sep-2024247 149

softirqs.bpf.cD06-Sep-20241.7 KiB8971

softirqs.cD06-Sep-20246.1 KiB281237

softirqs.hD06-Sep-2024192 127

solisten.bpf.cD06-Sep-20242.5 KiB10282

solisten.cD06-Sep-20245.1 KiB222181

solisten.hD06-Sep-2024278 1813

stat.hD06-Sep-2024767 2821

statsnoop.bpf.cD06-Sep-20243.2 KiB131104

statsnoop.cD06-Sep-20245.7 KiB227192

statsnoop.hD06-Sep-2024285 1712

syscall_helpers.cD06-Sep-202418.5 KiB852809

syscall_helpers.hD06-Sep-2024313 138

syscount.bpf.cD06-Sep-20242.8 KiB11689

syscount.cD06-Sep-202412 KiB511438

syscount.hD06-Sep-2024274 1710

tcpconnect.bpf.cD06-Sep-20245.3 KiB227182

tcpconnect.cD06-Sep-202410.4 KiB460401

tcpconnect.hD06-Sep-2024732 4735

tcpconnlat.bpf.cD06-Sep-20243.2 KiB141115

tcpconnlat.cD06-Sep-20246.5 KiB249212

tcpconnlat.hD06-Sep-2024392 2721

tcplife.bpf.cD06-Sep-20243.9 KiB153131

tcplife.cD06-Sep-20245.9 KiB248206

tcplife.hD06-Sep-2024455 2922

tcppktlat.bpf.cD06-Sep-20243.6 KiB143117

tcppktlat.cD06-Sep-20246.6 KiB268236

tcppktlat.hD06-Sep-2024321 2015

tcppktlat_example.txtD06-Sep-20243.3 KiB7154

tcprtt.bpf.cD06-Sep-20244.2 KiB157118

tcprtt.cD06-Sep-20248.8 KiB342298

tcprtt.hD06-Sep-2024293 2014

tcpstates.bpf.cD06-Sep-20242.7 KiB10382

tcpstates.cD06-Sep-20247.4 KiB297256

tcpstates.hD06-Sep-2024419 2418

tcpsynbl.bpf.cD06-Sep-20241.4 KiB6752

tcpsynbl.cD06-Sep-20245.7 KiB260217

tcpsynbl.hD06-Sep-2024192 127

tcptop.bpf.cD06-Sep-20243.2 KiB12892

tcptop.cD06-Sep-20249.5 KiB427356

tcptop.hD06-Sep-2024358 2317

tcptracer.bpf.cD06-Sep-20247.6 KiB336251

tcptracer.cD06-Sep-20246.9 KiB315270

tcptracer.hD06-Sep-2024733 4329

trace_helpers.cD06-Sep-202424.3 KiB1,2351,007

trace_helpers.hD06-Sep-20243.2 KiB10556

uprobe_helpers.cD06-Sep-20246.5 KiB295233

uprobe_helpers.hD06-Sep-2024649 1913

vfsstat.bpf.cD06-Sep-20241.3 KiB7961

vfsstat.cD06-Sep-20244.9 KiB215183

vfsstat.hD06-Sep-2024224 1611

wakeuptime.bpf.cD06-Sep-20242.2 KiB9876

wakeuptime.cD06-Sep-20247 KiB274239

wakeuptime.hD06-Sep-2024281 1610

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
96Running in kernels without CONFIG_DEBUG_INFO_BTF=y
97--------------------------------------------------
98
99It's possible to run some tools in kernels that don't expose
100`/sys/kernel/btf/vmlinux`. For those cases,
101[BTFGen](https://lore.kernel.org/bpf/20220215225856.671072-1-mauricio@kinvolk.io)
102and [BTFHub](https://github.com/aquasecurity/btfhub) can be used to
103generate small BTF files for the most popular Linux distributions that
104are shipped with the tools in order to provide the needed information to
105perform the CO-RE relocations when loading the eBPF programs.
106
107If you haven't cloned the
108[btfhub-archive](https://github.com/aquasecurity/btfhub) repository, you
109can run make and it'll clone it for you into the `$HOME/.local/share`
110directory:
111
112```bash
113make ENABLE_MIN_CORE_BTFS=1 -j$(nproc)
114```
115
116If you have a local copy of such repository, you can pass it's location
117to avoid cloning it again:
118
119```bash
120make ENABLE_MIN_CORE_BTFS=1 BTF_HUB_ARCHIVE=<path_to_btfhub-archive> -j$(nproc)
121```
122