platform/upstream/bcc.git
2 years agolibbpf-tools: Add verbose option to filetop
Hengqi Chen [Sat, 25 Dec 2021 04:07:56 +0000 (12:07 +0800)]
libbpf-tools: Add verbose option to filetop

Support verbose mode and set custom libbpf print callback
in filetop.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agolibbpf-tools: Add verbose option to exitsnoop
Hengqi Chen [Sat, 25 Dec 2021 04:07:16 +0000 (12:07 +0800)]
libbpf-tools: Add verbose option to exitsnoop

Support verbose mode and set custom libbpf print callback
in exitsnoop.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agolibbpf-tools: Add verbose option to bindsnoop
Hengqi Chen [Sat, 25 Dec 2021 04:06:39 +0000 (12:06 +0800)]
libbpf-tools: Add verbose option to bindsnoop

Support verbose mode and set custom libbpf print callback
in bindsnoop.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agolibbpf-tools: Add verbose option to bashreadline
Hengqi Chen [Sat, 25 Dec 2021 04:05:54 +0000 (12:05 +0800)]
libbpf-tools: Add verbose option to bashreadline

Support verbose mode and set custom libbpf print callback
in bashreadline.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agoexclude static functions with prefix __SCT__ (#3772)
Achilles [Thu, 23 Dec 2021 18:59:59 +0000 (00:29 +0530)]
exclude static functions with prefix __SCT__ (#3772)

The kernel functions with prefix __SCT__ are for static calls. These static call functions are not in
/sys/kernel/debug/tracing/available_filter_functions and not in /sys/kernel/debug/kprobes/blacklist
either. Let us do filtering in get_kprobe_functions() to filter them out.

Co-authored-by: prameet.p <prameet.p@inba-prameet.p-210508>
2 years agodocker: Run tests on ubuntu-20.04 as well
Dave Marchevsky [Tue, 21 Dec 2021 04:05:16 +0000 (23:05 -0500)]
docker: Run tests on ubuntu-20.04 as well

Move bcc-test github action's `matrix.os` to indicate the OS to run in
the container, not the test runner itself (just pin the latter to
ubuntu-20.04).

Also, fixup some tests that were failing when trying to run on 20.04
manually.

2 years agodocker: Bump default LLVM used for tests to 11
Dave Marchevsky [Mon, 20 Dec 2021 22:47:11 +0000 (17:47 -0500)]
docker: Bump default LLVM used for tests to 11

This is another prep commit for running docker tests on both 18.04 and
20.04 versions of ubuntu. 20.04 doesn't have some LLVM 8 libs that the
docker build expects, so bump to 11.

Bumping to 11 causes test_disassembler to fail because it expects a map
w/ a certain format with FD 3, and the LLVM bump causes the map to be
FD 4. The purpose of the test is to ensure that the format of the
diassembled map is correct, not that it has a specific FD, so make some
small changes to the test so that it doesn't care what the FD number is.

2 years agodocker + tests: Run tests using python3, refactor Dockerfile
Dave Marchevsky [Mon, 20 Dec 2021 20:23:37 +0000 (15:23 -0500)]
docker + tests: Run tests using python3, refactor Dockerfile

In #3707, I added ubuntu-20.04 to the list of OS's bcc-test uses to run
tests. I expected that this would result in the tests running on both
18.04 and 20.04. Unfortunately this change was effectively a no-op as
the tests are run in a Docker container and the os field in bcc-test.yml
dictates the type/version of the _host_ OS, not the container's OS.

So it's not necessary to run on both, just run on 20.04. It will be
necessary to modify Dockerfile.test to use both 18.04 and 20.04. To
prepare for this, move all python tests to use python3 interpreter, as
20.04 doesn't have python2 pip readily available.

Also, refactor Dockerfile.tests a bit so that it's possible to provide
ubuntu version and shortname as build input.

This commit does not result in the docker test container working/running
both 18.04 and 20.04, rather lays groundwork for future commits to do
so.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
2 years agoMerge pull request #3761 from anakryiko/libbpf-tools-modernize
Dave Marchevsky [Mon, 20 Dec 2021 21:53:55 +0000 (16:53 -0500)]
Merge pull request #3761 from anakryiko/libbpf-tools-modernize

libbpf-tools: modernize all tools to libbpf 1.0 mode

2 years agolibbpf-tools: remove now unnecessary bump_memlock_rlimit()
Andrii Nakryiko [Fri, 17 Dec 2021 22:24:37 +0000 (14:24 -0800)]
libbpf-tools: remove now unnecessary bump_memlock_rlimit()

libbpf will now automatically decide whether it's necessary, and if yes,
will do it on behalf of the application.

All the subsequet tools should make sure to set:

```
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
```

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update vfsstat for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update vfsstat for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update tcprtt for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update tcprtt for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update tcpconnlat for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update tcpconnlat for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update tcpconnect for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update tcpconnect for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update syscount for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update syscount for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update statsnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update statsnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update solisten for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update solisten for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update softirqs for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update softirqs for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update runqslower for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update runqslower for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update runqlen for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update runqlen for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update runqlat for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update runqlat for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update readahead for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update readahead for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update opensnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:30 +0000 (14:32 -0800)]
libbpf-tools: update opensnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update offcputime for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:29 +0000 (14:32 -0800)]
libbpf-tools: update offcputime for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update numamove for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:29 +0000 (14:32 -0800)]
libbpf-tools: update numamove for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update mountsnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:29 +0000 (14:32 -0800)]
libbpf-tools: update mountsnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update llcstat for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:29 +0000 (14:32 -0800)]
libbpf-tools: update llcstat for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update ksnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:29 +0000 (14:32 -0800)]
libbpf-tools: update ksnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update hardirqs for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:29 +0000 (14:32 -0800)]
libbpf-tools: update hardirqs for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update gethostlatency for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:32:29 +0000 (14:32 -0800)]
libbpf-tools: update gethostlatency for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update funclatency for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:23:49 +0000 (14:23 -0800)]
libbpf-tools: update funclatency for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update fsslower for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:23:29 +0000 (14:23 -0800)]
libbpf-tools: update fsslower for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update fsdist for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:23:14 +0000 (14:23 -0800)]
libbpf-tools: update fsdist for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update filetop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:23:01 +0000 (14:23 -0800)]
libbpf-tools: update filetop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update filelife for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:22:48 +0000 (14:22 -0800)]
libbpf-tools: update filelife for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update exitsnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 20:22:07 +0000 (12:22 -0800)]
libbpf-tools: update exitsnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update execsnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:22:09 +0000 (14:22 -0800)]
libbpf-tools: update execsnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update cpudist for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:21:44 +0000 (14:21 -0800)]
libbpf-tools: update cpudist for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update drsnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:21:25 +0000 (14:21 -0800)]
libbpf-tools: update drsnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: fix cpufreq.bpf.c and update cpufreq for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:20:32 +0000 (14:20 -0800)]
libbpf-tools: fix cpufreq.bpf.c and update cpufreq for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Also fix cachestat.bpf.c by adding a BPF assembly trick to ensure that
BPF verifier sees proper value bounds for cpu ID.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update cachestat for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:20:08 +0000 (14:20 -0800)]
libbpf-tools: update cachestat for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update bitesize for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:19:43 +0000 (14:19 -0800)]
libbpf-tools: update bitesize for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update biostacks for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:19:26 +0000 (14:19 -0800)]
libbpf-tools: update biostacks for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update biosnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:19:03 +0000 (14:19 -0800)]
libbpf-tools: update biosnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update biopattern for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:18:48 +0000 (14:18 -0800)]
libbpf-tools: update biopattern for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update biolatency for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:17:46 +0000 (14:17 -0800)]
libbpf-tools: update biolatency for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update bindsnoop for libbpf 1.0
Andrii Nakryiko [Fri, 17 Dec 2021 22:16:32 +0000 (14:16 -0800)]
libbpf-tools: update bindsnoop for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update bashreadline for libbpf 1.0
Andrii Nakryiko [Mon, 20 Dec 2021 21:17:19 +0000 (13:17 -0800)]
libbpf-tools: update bashreadline for libbpf 1.0

Switch to libbpf 1.0 mode and adapt libbpf API usage
accordingly.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agolibbpf-tools: update bpftool
Andrii Nakryiko [Fri, 17 Dec 2021 22:15:30 +0000 (14:15 -0800)]
libbpf-tools: update bpftool

We need up-to-date bpftool to support skeletons with multiple BPF programs per
SEC().

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2 years agosync with latest libbpf repo
Yonghong Song [Mon, 20 Dec 2021 01:41:48 +0000 (17:41 -0800)]
sync with latest libbpf repo

sync upto the following commit:
  96268bf0c2b7 sync: latest libbpf changes from kernel

Signed-off-by: Yonghong Song <yhs@fb.com>
2 years agotools: tcptop: Get command name from BPF code. (#3760)
eiffel-fl [Sat, 18 Dec 2021 18:21:13 +0000 (19:21 +0100)]
tools: tcptop: Get command name from BPF code. (#3760)

Before this commit, command name was taken from PID using /proc/PID/comm.
But this method was not reliable as it does not work all the time.
So, this commit takes command name from BPF code using bpf_get_current_comm()
helper like it is done for biotop.

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
2 years agoReplace !StatusTuple::code() with StatusTuple::ok() in src/cc/api/BPFTable.h (#3751)
yzhao [Sat, 18 Dec 2021 18:17:46 +0000 (10:17 -0800)]
Replace !StatusTuple::code() with StatusTuple::ok() in src/cc/api/BPFTable.h (#3751)

Replace !StatusTuple::code() with StatusTuple::ok() in src/cc/api/BPFTable.h

2 years agoImplement bashreadline with libbpf.
Kui-Feng Lee [Wed, 15 Dec 2021 23:57:17 +0000 (15:57 -0800)]
Implement bashreadline with libbpf.

Bashreadline will print user inputs, returning from readline, of every
instance of bash shell.  Readline is in bash itself, linked
statically, for some devices, while others may link to libreadline.so.
This implementation finds the symbol in bash if possible. Or, it tries
to find libreadline.so using ldd if the symbol is not in bash.

Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
2 years agotools: Remove unused struct id_t definition in tcpstates
Hengqi Chen [Sat, 18 Dec 2021 14:01:40 +0000 (22:01 +0800)]
tools: Remove unused struct id_t definition in tcpstates

The tool tcpstates contains a struct id_t definition but not
referenced, remove it.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agodocs: Fix BPF_HISTGRAM typo in reference guide
Tommi Rantala [Sat, 18 Dec 2021 16:08:07 +0000 (18:08 +0200)]
docs: Fix BPF_HISTGRAM typo in reference guide

Fix typo in reference guide, should be BPF_HISTOGRAM.

2 years agoRemove P4 language support.
Dave Marchevsky [Fri, 17 Dec 2021 08:59:26 +0000 (03:59 -0500)]
Remove P4 language support.

Remove support for compiling P4 programs (see #3682 for explanation).

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
2 years agoRemove B language support
Dave Marchevsky [Fri, 17 Dec 2021 07:54:49 +0000 (02:54 -0500)]
Remove B language support

Remove support for compiling B programs (see #3682 for explanation).

There may be some vestigial logic in other files that needs to be
cleanded up for simplicity - bpf_module.cc most likely - but that can be
addressed in followup commits.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
2 years agoUpdate INSTALL.md (#3758)
bighunter513 [Thu, 16 Dec 2021 17:55:20 +0000 (01:55 +0800)]
Update INSTALL.md (#3758)

add INSTALL from source for CentOS 8.5 scripts

2 years agotest_tools_smoke.py: Helpful fail msg for timeout cmd's ret code
Dave Marchevsky [Wed, 15 Dec 2021 17:28:11 +0000 (12:28 -0500)]
test_tools_smoke.py: Helpful fail msg for timeout cmd's ret code

The test_tools_smoke script uses bash's 'timeout' command to run bcc
tools for a limited duration, sending a HUP after 5s and a KILL 5s after
that. Currently, when a tool exits in an unexpected way (e.g. we
expected a HUP to be required, but the tool required a KILL), the test
failure message isn't very descriptive.

This adds a more human-readable explanation of what's going on.

2 years agoMerge pull request #3748 from chenhengqi/fix-bcc-bio-tools
Dave Marchevsky [Wed, 15 Dec 2021 17:45:15 +0000 (12:45 -0500)]
Merge pull request #3748 from chenhengqi/fix-bcc-bio-tools

tools: Fix BCC bio tools with recent kernel change

2 years agoReplace StatusTuple::code() != 0 with !StatusTuple.ok() in examples/
Yaxiong Zhao [Mon, 13 Dec 2021 20:24:04 +0000 (12:24 -0800)]
Replace StatusTuple::code() != 0 with !StatusTuple.ok() in examples/

2 years agoReplace StatusTuple::code() with StatusTuple::ok() in tests/
Yaxiong Zhao [Mon, 13 Dec 2021 18:57:25 +0000 (10:57 -0800)]
Replace StatusTuple::code() with StatusTuple::ok() in tests/

2 years agoSupport tracing of processes under cgroup path
Chethan Suresh [Fri, 10 Dec 2021 04:47:59 +0000 (10:17 +0530)]
Support tracing of processes under cgroup path

- Using bpf_current_task_under_cgroup() we can check whether the probe
  is being run in the context of a given subset of the cgroup2 hierarchy.
- Support cgroup path '-c' args to get the cgroup2 path
  and filter based on the cgroup2 path fd using bpf_current_task_under_cgroup()

Signed-off-by: Chethan Suresh <Chethan.Suresh@sony.com>
2 years agoFix format
Yaxiong Zhao [Sat, 11 Dec 2021 05:36:46 +0000 (21:36 -0800)]
Fix format

2 years ago!StatusTuple::ok() replaced StatusTuple::code() != 0
Yaxiong Zhao [Wed, 8 Dec 2021 20:04:59 +0000 (12:04 -0800)]
!StatusTuple::ok() replaced StatusTuple::code() != 0

This is done with the shell command:
```
sed -i 's|\([A-Z_a-z]\+\).code() != 0|!\1.ok()|' $(grep '\.code() != 0' src -rl)
```

2 years agouse probe_limt from env
congwu [Sat, 4 Dec 2021 06:38:15 +0000 (14:38 +0800)]
use probe_limt from env

2 years agotools: Fix BCC bio tools with recent kernel change
Hengqi Chen [Sat, 11 Dec 2021 09:36:17 +0000 (17:36 +0800)]
tools: Fix BCC bio tools with recent kernel change

Several BCC bio tools are broken due to kernel change ([0]).
blk_account_io_{start, done} were renamed to __blk_account_io_{start, done},
and the symbols gone from /proc/kallsyms. Fix them by checking symbol existence.

  [0]: https://github.com/torvalds/linux/commit/be6bfe36db1795babe9d92178a47b2e02193cb0f

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agoAdd --uid option to filter by user ID (#3743)
evilpan [Fri, 10 Dec 2021 16:58:51 +0000 (00:58 +0800)]
Add --uid option to filter by user ID (#3743)

* Add --uid option to filter by user ID
* update examples and man page of the trace tool

2 years agohardirqs: fix issue if irq is triggered while idle task (tid=0)
Ism Hong [Wed, 8 Dec 2021 02:17:20 +0000 (10:17 +0800)]
hardirqs: fix issue if irq is triggered while idle task (tid=0)

Currently, hardirqs use tid as key to store information while tracepoint
irq_handler_entry. It works fine if irq is triggered while normal task
running, but there is a chance causing overwrite issue while irq is
triggered while idle task (a.k.a swapper/x, tid=0) running on multi-core
system.

Let's say there are two irq event trigger simultaneously on both CPU
core, irq A @ core #0, irq B @ core #1, and system load is pretty light,
so BPF program will get tid=0 since current task is swapper/x for both cpu
core. In this case, the information of first irq event stored in map could
be overwritten by incoming second irq event.

Use tid and cpu_id together to make sure the key is unique for each
event in this corner case.

Please check more detail at merge request #2804, #3733.

2 years agohardirqs: fix duplicated count for shared IRQ
Ism Hong [Mon, 6 Dec 2021 03:28:34 +0000 (11:28 +0800)]
hardirqs: fix duplicated count for shared IRQ

Currently, hardirqs will count interrupt event simply while tracepoint
irq:irq_handler_entry triggered, it's fine for system without shared IRQ
event, but it will cause wrong interrupt count result for system with
shared IRQ, because kernel will interate all irq handlers belong to this
IRQ descriptor.

Take an example for system with shared IRQ below.

root@localhost:/# cat /proc/interrupts
           CPU0
 13:     385248     GICv3  39 Level     DDOMAIN ISR, gdma
 ...
 23:      61532     GICv3  38 Level     VGIP ISR, OnlineMeasure ISR

DDOMAIN IRQ and gdma shared the IRQ 13, VGIP ISR and OnlineMeasure
shared the IRQ 23, and use 'hardirqs -C' to measure the count of these
interrupt event.

root@localhost:/# hardirqs -C 10 1
Tracing hard irq events... Hit Ctrl-C to end.

HARDIRQ                    TOTAL_count
OnlineMeasure ISR                  300
VGIP ISR                           300
gdma                              2103
DDOMAIN ISR                       2103
eth0                              6677

hardirqs reported the same interrupt count for shared IRQ
'OnlineMeasure ISR/VGIP ISR' and 'gdma/DDOMAIN ISR'.

We should check the ret field of tracepoint irq:irq_hanlder_exit is
IRQ_HANDLED or IRQ_WAKE_THREAD to make sure the current event is belong
to this interrupt handler. For simplifying, just check `args->ret !=
IRQ_NONE`.

In the meantimes, the same changes should be applied to interrupt time
measurement.

The fixed hardirqs will show below output.

(bcc)root@localhost:/# ./hardirqs -C 10 1
Tracing hard irq events... Hit Ctrl-C to end.

HARDIRQ                    TOTAL_count
OnlineMeasure ISR                    1
VGIP ISR                           294
gdma                              1168
DDOMAIN ISR                       1476
eth0                              5210

2 years agofix llvm compilation failure
Yonghong Song [Mon, 6 Dec 2021 17:05:08 +0000 (09:05 -0800)]
fix llvm compilation failure

Fix issue #3734

llvm upstream commit
  89eb85ac6eab [IRBuilder] Remove deprecated methods
deprecated some functions which are used by bcc.
Let us follow the above commit to use the underlying
implementation instead.

Note that I didn't create a common header for the newer
functions since b language support will be removed in
the near future.

Signed-off-by: Yonghong Song <yhs@fb.com>
2 years agosync with latest libbpf repo
Yonghong Song [Mon, 6 Dec 2021 15:48:52 +0000 (07:48 -0800)]
sync with latest libbpf repo

Sync with latest libbpf repo (libbpf 0.6.0 + one more commit below).
  93e89b34740c ci: upgrade s390x runner to v2.285.0

Signed-off-by: Yonghong Song <yhs@fb.com>
2 years agoMerge pull request #3728 from chendotjs/tcpconnlat-lport
Dave Marchevsky [Wed, 1 Dec 2021 18:08:17 +0000 (13:08 -0500)]
Merge pull request #3728 from chendotjs/tcpconnlat-lport

libbpf-tools: add option to include 'LPORT' in tcpconnlat

2 years agoUpdate for Ubuntu 21.x build dependencies (#3727)
DavadDi [Tue, 30 Nov 2021 06:22:14 +0000 (14:22 +0800)]
Update for Ubuntu 21.x build dependencies (#3727)

Add Ubuntu 21.x build dependencies

2 years agolibbpf-tools: add option to include 'LPORT' in tcpconnlat
chendotjs [Tue, 30 Nov 2021 03:56:03 +0000 (03:56 +0000)]
libbpf-tools: add option to include 'LPORT' in tcpconnlat

Signed-off-by: chendotjs <chendotjs@gmail.com>
2 years agoMerge pull request #3726 from chendotjs/tcprtt-ordering
Dave Marchevsky [Tue, 30 Nov 2021 02:14:14 +0000 (21:14 -0500)]
Merge pull request #3726 from chendotjs/tcprtt-ordering

libbpf-tools: fix local/remote address byte ordering in tcprtt

2 years agolibbpf-tools: fix local/remote address byte ordering in tcprtt
chendotjs [Mon, 29 Nov 2021 08:51:53 +0000 (08:51 +0000)]
libbpf-tools: fix local/remote address byte ordering in tcprtt

Since inet_aton() converts IPv4 numbers-and-dots notation to binary in network byte order, there is
no need to do htonl() again.

Signed-off-by: chendotjs <chendotjs@gmail.com>
2 years agobcc: remove trailing semicolon of macro
Jacky_Yin [Wed, 24 Nov 2021 07:56:23 +0000 (15:56 +0800)]
bcc: remove trailing semicolon of macro

The trailing semicolon of a do-while style macro will cause
a if-else condition without braces failed to compile.
Meanwhile, also align with other do-while style macros.

2 years agotools: improve sslsniff (send buffer & filtering)
Slava Bacherikov [Sun, 21 Nov 2021 13:31:49 +0000 (15:31 +0200)]
tools: improve sslsniff (send buffer & filtering)

This makes few improvements:
    * This can send much larger data payload and also adds
      --max-buffer-size CLI option which allow changing this param.
    * Fixes dealing with non ASCII protocols, previously struct was
      defined as array of chars which made python ctypes treat it as
      NULL terminated string and it prevents from displaying any data
      past the null byte (which is very common for http2).
    * Adds more filtering and displaying options (--print-uid,
      --print-tid, --uid <uid>)

This also deals correctly with rare cases when bpf_probe_read_user fails
(so buffer should be empty and should not be displayed).

2 years agotools/hardirqs: Using TP_DATA_LOC_READ_STR to read string field
Hengqi Chen [Mon, 22 Nov 2021 13:54:51 +0000 (21:54 +0800)]
tools/hardirqs: Using TP_DATA_LOC_READ_STR to read string field

Fixes #3720.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agobcc: Use bpf_probe_read_str to read tracepoint data_loc field
Hengqi Chen [Mon, 22 Nov 2021 13:49:03 +0000 (21:49 +0800)]
bcc: Use bpf_probe_read_str to read tracepoint data_loc field

The data_loc field (defined as __string in kernel source) should
be treated as string NOT a fixed-size array, add a new macro
TP_DATA_LOC_READ_STR which use bpf_probe_read_str to reflect this.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agosimplify AL2 Linux package install command
quiver [Sun, 21 Nov 2021 08:57:33 +0000 (09:57 +0100)]
simplify AL2 Linux package install command

By just running `$ sudo amazon-linux-extras install BCC`, dependencies are install.

```
$ sudo amazon-linux-extras install BCC
...

==================================================================================================================================================================
 Package                                       Arch                      Version                                 Repository                                  Size
==================================================================================================================================================================
Installing:
 bcc                                           x86_64                    0.18.0-1.amzn2.0.3                      amzn2-core                                  28 M
Installing for dependencies:
 bcc-tools                                     x86_64                    0.18.0-1.amzn2.0.3                      amzn2-core                                 557 k
 clang-libs                                    x86_64                    11.1.0-1.amzn2.0.2                      amzn2-core                                  22 M
 clang-resource-filesystem                     x86_64                    11.1.0-1.amzn2.0.2                      amzn2-core                                  17 k
 cpp10                                         x86_64                    10.3.1-1.amzn2.0.1                      amzn2-core                                 9.5 M
 elfutils-libelf-devel                         x86_64                    0.176-2.amzn2                           amzn2-core                                  40 k
 gcc10                                         x86_64                    10.3.1-1.amzn2.0.1                      amzn2-core                                  38 M
 gcc10-binutils                                x86_64                    2.35-21.amzn2.0.1                       amzn2-core                                 2.9 M
 gcc10-binutils-gold                           x86_64                    2.35-21.amzn2.0.1                       amzn2-core                                 795 k
 glibc-devel                                   x86_64                    2.26-56.amzn2                           amzn2-core                                 994 k
 glibc-headers                                 x86_64                    2.26-56.amzn2                           amzn2-core                                 514 k
 isl                                           x86_64                    0.16.1-6.amzn2                          amzn2-core                                 833 k
 kernel-devel                                  x86_64                    5.10.75-79.358.amzn2                    amzn2extra-kernel-5.10                      16 M
 kernel-headers                                x86_64                    5.10.75-79.358.amzn2                    amzn2extra-kernel-5.10                     1.3 M
 libbpf                                        x86_64                    0.3.0-2.amzn2.0.3                       amzn2-core                                 102 k
 libmpc                                        x86_64                    1.0.1-3.amzn2.0.2                       amzn2-core                                  52 k
 libzstd                                       x86_64                    1.3.3-1.amzn2.0.1                       amzn2-core                                 203 k
 llvm-libs                                     x86_64                    11.1.0-1.amzn2.0.2                      amzn2-core                                  22 M
 mpfr                                          x86_64                    3.1.1-4.amzn2.0.2                       amzn2-core                                 208 k
 python3-bcc                                   noarch                    0.18.0-1.amzn2.0.3                      amzn2-core                                  86 k
 python3-netaddr                               noarch                    0.7.18-3.amzn2.0.2                      amzn2-core                                 1.3 M
 zlib-devel                                    x86_64                    1.2.7-18.amzn2                          amzn2-core                                  50 k
...
```

2 years agoCreate examples/tracing/undump.py examples text file (#3714)
rtoax [Fri, 19 Nov 2021 17:09:47 +0000 (01:09 +0800)]
Create examples/tracing/undump.py examples text file (#3714)

Create examples/tracing/undump.py examples text file and update permission (+x) for undump.py.

2 years agoEnable CMP0074 to allow `${pkg}_ROOT`, especially for LLVM_ROOT (#3713)
FUJI Goro [Fri, 19 Nov 2021 04:40:01 +0000 (13:40 +0900)]
Enable CMP0074 to allow `${pkg}_ROOT`, especially for LLVM_ROOT (#3713)

set CMP0074 to allow the use of `LLVM_ROOT` env var

2 years agoMark test_call1.py mayFail
Yonghong Song [Thu, 18 Nov 2021 00:57:20 +0000 (16:57 -0800)]
Mark test_call1.py mayFail

The test send a udp packet to test tailcalls.
The test may fail due to udp packet loss.
Let us mark the test as mayFail.

Signed-off-by: Yonghong Song <yhs@fb.com>
2 years agoadd batch methods into libbpf.h
hsqStephenZhang [Thu, 18 Nov 2021 00:19:38 +0000 (00:19 +0000)]
add batch methods into libbpf.h

2 years agoSync with latest libbpf repo
Yonghong Song [Wed, 17 Nov 2021 23:57:02 +0000 (15:57 -0800)]
Sync with latest libbpf repo

Sync with latest libbpf repo upto commit:
   94a49850c5ee Makefile: enforce gnu89 standard

Signed-off-by: Yonghong Song <yhs@fb.com>
2 years agoMerge pull request #3707 from iovisor/davemarchevsky-patch-4
Dave Marchevsky [Wed, 17 Nov 2021 04:48:34 +0000 (23:48 -0500)]
Merge pull request #3707 from iovisor/davemarchevsky-patch-4

add ubuntu-20.04 to bcc-test.yml

2 years agoGH Actions: run bcc-test and publish workflows on push to master branch too
Dave Marchevsky [Wed, 17 Nov 2021 03:01:59 +0000 (22:01 -0500)]
GH Actions: run bcc-test and publish workflows on push to master branch too

2 years agopython tests: mayFail py_smoke_tests' ttysnoop test on gh actions for now
Dave Marchevsky [Wed, 17 Nov 2021 02:34:57 +0000 (21:34 -0500)]
python tests: mayFail py_smoke_tests' ttysnoop test on gh actions for now

2 years agotests: Don't run py test_rlimit test on newer kernels
Dave Marchevsky [Wed, 17 Nov 2021 00:50:32 +0000 (19:50 -0500)]
tests: Don't run py test_rlimit test on newer kernels

Since commit d5299b67dd59 ("bpf: Memcg-based memory accounting for bpf
maps"), memory locked by bpf maps is no longer counted against rlimit.

Ubuntu 20.04's 5.11 kernel has this commit, so we should skip this test
there. When we add future distros to github actions it may be necessary
to modify the version check here.

2 years agomark 'test sk_storage map' mayfail
Dave Marchevsky [Tue, 16 Nov 2021 04:40:39 +0000 (23:40 -0500)]
mark 'test sk_storage map' mayfail

it wasn't running on ubuntu-18.04 test runner b/c of the kernel version check and is failing now as I try to add ubuntu-20.04 test runner

Will investigate separately from GH actions changes

2 years agoadd ubuntu-20.04 to bcc-test.yml
Dave Marchevsky [Tue, 16 Nov 2021 01:31:14 +0000 (20:31 -0500)]
add ubuntu-20.04 to bcc-test.yml

resending

2 years agoMerge pull request #3708 from davemarchevsky/davemarchevsky/gh-actions-1
Dave Marchevsky [Wed, 17 Nov 2021 02:32:35 +0000 (21:32 -0500)]
Merge pull request #3708 from davemarchevsky/davemarchevsky/gh-actions-1

gh actions: run test and publish actions on pull_request, not push

2 years agogh actions: run test and publish actions on pull_request, not push
Dave Marchevsky [Wed, 17 Nov 2021 02:07:28 +0000 (21:07 -0500)]
gh actions: run test and publish actions on pull_request, not push

2 years agoupdate debian changelog for release v0.23.0 v0.23.0
Yonghong Song [Mon, 15 Nov 2021 18:02:24 +0000 (10:02 -0800)]
update debian changelog for release v0.23.0

  * Support for kernel up to 5.15
  * bcc tools: update for kvmexit.py, tcpv4connect.py, cachetop.py, cachestat.py, etc.
  * libbpf tools: update for update for mountsnoop, ksnoop, gethostlatency, etc.
  * fix renaming of task_struct->state
  * get pid namespace properly for a number of tools
  * initial work for more libbpf utilization (less section names)
  * doc update, bug fixes and other tools improvement

Signed-off-by: Yonghong Song <yhs@fb.com>
2 years agodocs: correct typos in BPF.XDP in reference guide
Liz Rice [Mon, 15 Nov 2021 16:43:51 +0000 (16:43 +0000)]
docs: correct typos in BPF.XDP in reference guide

2 years agoAdd comment to sorting function
Eddie Elizondo [Mon, 15 Nov 2021 15:34:43 +0000 (10:34 -0500)]
Add comment to sorting function

2 years agoGuarantee strict weak order in Probe::finalize_locations
Eddie Elizondo [Mon, 15 Nov 2021 06:12:07 +0000 (01:12 -0500)]
Guarantee strict weak order in Probe::finalize_locations

2 years agoFix garbled java class name problem of uobjnew.py
denghui.ddh [Tue, 9 Nov 2021 13:11:40 +0000 (21:11 +0800)]
Fix garbled java class name problem of uobjnew.py

After this fix, the output may look like this:
NAME/TYPE                      # ALLOCS      # BYTES
[B                                    1         1016
[D                                    1         8016