platform/upstream/bcc.git
2 years agoMerge pull request #3796 from davemarchevsky/davemarchevsky_klockstat_fixups
Dave Marchevsky [Fri, 7 Jan 2022 03:50:32 +0000 (22:50 -0500)]
Merge pull request #3796 from davemarchevsky/davemarchevsky_klockstat_fixups

libbpf-tools/klockstat: no more rlimit bumping + add comment

2 years agolibbpf-tools/klockstat: no more rlimit bumping + add comment
Dave Marchevsky [Fri, 7 Jan 2022 03:19:36 +0000 (22:19 -0500)]
libbpf-tools/klockstat: no more rlimit bumping + add comment

The PR adding the libbpf-tools port of klockstat was sitting in a
mergeable state for some time. Meanwhile, libbpf stopped exposing
rlimit_memlock bumping API and now does the rlimit bump automatically if
necessary. So remove the bump_rlimit_memlock call and set libbpf strict
mode for this tool.

Also, add a comment (from @brho's PR summary in #3688) detailing the
differences in default behavior between the libbpf-tools and bcc-python
versions.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
2 years agoMerge pull request #3795 from Rtoax/patch-7
Dave Marchevsky [Fri, 7 Jan 2022 02:36:12 +0000 (21:36 -0500)]
Merge pull request #3795 from Rtoax/patch-7

`-4` is better

2 years ago`-4` is better
Rong Tao [Fri, 7 Jan 2022 02:34:40 +0000 (10:34 +0800)]
`-4` is better

2 years agoMerge pull request #3688 from brho/master
Dave Marchevsky [Thu, 6 Jan 2022 20:27:02 +0000 (15:27 -0500)]
Merge pull request #3688 from brho/master

libbpf-tools: add klockstat

2 years agolibbpf-tools: fix dev_t type issue
Wei Fu [Tue, 28 Dec 2021 15:21:20 +0000 (23:21 +0800)]
libbpf-tools: fix dev_t type issue

The vmlinux.h uses u32 to define dev_t. But the user-space process uses
<sys/types.h> which uses 8 bytes for dev_t. When the libbpf uses mapped
memory to update .rodata, it might override other variable's value. We
should use u32 to fix it.

And also fix `biosnoop -d $dev-name` issue.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2 years agobcc: Replace deprecated libbpf APIs
Hengqi Chen [Wed, 5 Jan 2022 15:30:40 +0000 (23:30 +0800)]
bcc: Replace deprecated libbpf APIs

Several libbpf APIs used by BCC are deprecated, which causes
annoying compilation warnings. Update BCC to use the replacement
APIs. The code is mainly borrowed from libbpf itself.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agobcc/docs: fix broken links in reference guide (#3789)
Hengqi Chen [Wed, 5 Jan 2022 16:13:51 +0000 (00:13 +0800)]
bcc/docs: fix broken links in reference guide (#3789)

fix broken links in reference guide

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agoexamples: Add local storage examples
Hengqi Chen [Tue, 4 Jan 2022 16:02:49 +0000 (00:02 +0800)]
examples: Add local storage examples

Add examples to demostrate BPF_{INODE, TASK}_STORAGE usage.

$ sudo ./task_storage.py
b'              nc-668442  [000] d..21 1221279.139354: bpf_trace_printk: inet_listen entry: store timestamp 1221271907116757'
b'              nc-668442  [000] d..21 1221279.139375: bpf_trace_printk: inet_listen exit: cost 26us'

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agobcc: support BPF_MAP_TYPE_{INODE, TASK}_STORAGE maps
Hengqi Chen [Tue, 4 Jan 2022 16:00:39 +0000 (00:00 +0800)]
bcc: support BPF_MAP_TYPE_{INODE, TASK}_STORAGE maps

Add support for BPF_MAP_TYPE_{INODE, TASK}_STORAGE in BCC.
Like sk local storage, this commit allows creating inode/task
local storage using BPF_{INODE, TASK}_STORAGE macros, and
manipulating maps using map.{inode, task}_storage_get() and
map.{inode, task}_storage_delete() helpers.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agoVendor deprecated btf_ext APIs and structs
Dave Marchevsky [Wed, 29 Dec 2021 23:48:39 +0000 (18:48 -0500)]
Vendor deprecated btf_ext APIs and structs

Some btf_ext-related APIs in libbpf are being deprecated because they
make incorrect assumptions. They're being used only by bcc currently, so
vendor them before they get deleted.

After / as part of #3660, may need to revisit the incorrect assumptions
being made here.

The functions and structs were ripped directly from libbpf with minimal
changes:
  * Change void* arithmetic to uint8_t
  * __u32 -> uint32_t and similar
  * Add a wrapping namespace
  * `rec_size` functions were not needed - just grab the rec_size
directly since type is no longer opaque to bcc

2 years agobcc: Fix array type handling due to llvm changes
Hengqi Chen [Mon, 3 Jan 2022 13:36:48 +0000 (21:36 +0800)]
bcc: Fix array type handling due to llvm changes

The llvm commit aee49255074f ([0]) changes array type
from `int [4]` to `int[4]` (with space removed), which
breaks the assumption in BCC. This commit fixes this
issue and adds a comment to the related code. While at
it, also remove execution permission of file `table.py`.

  [0]: https://github.com/llvm/llvm-project/commit/aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agolibbpf-tools: fix fentry prog in tcprtt (#3757)
chendotjs [Tue, 4 Jan 2022 19:26:15 +0000 (03:26 +0800)]
libbpf-tools: fix fentry prog in tcprtt (#3757)

This commit fixes judgement if tcp_rcv_established fentry exists and
fentry prog by introducing BPF_CORE_READ.

Signed-off-by: chendotjs <chendotjs@gmail.com>
2 years agoMerge pull request #3779 from davemarchevsky/davemarchevsky_build_libbpf_tools
Dave Marchevsky [Sat, 1 Jan 2022 21:37:40 +0000 (16:37 -0500)]
Merge pull request #3779 from davemarchevsky/davemarchevsky_build_libbpf_tools

Build libbpf tools as part of fedora test run

2 years agoBuild libbpf-tools as part of test workflow on fedora
Dave Marchevsky [Thu, 30 Dec 2021 21:08:44 +0000 (16:08 -0500)]
Build libbpf-tools as part of test workflow on fedora

2 years agoMerge pull request #3778 from davemarchevsky/davemarchevsky_fedora_tests
Dave Marchevsky [Wed, 29 Dec 2021 19:37:07 +0000 (14:37 -0500)]
Merge pull request #3778 from davemarchevsky/davemarchevsky_fedora_tests

add fedora docker tests + move dockerfiles to a new dir

2 years agoadd fedora docker tests + move dockerfiles to a new dir
Dave Marchevsky [Wed, 29 Dec 2021 03:45:22 +0000 (22:45 -0500)]
add fedora docker tests + move dockerfiles to a new dir

Dockerfiles are cluttering up the main repo dir, so move them to a
newly-created 'docker' dir.

Add a fedora dockerfile and use it in bcc-test workflow.

2 years agoMerge pull request #3773 from chenhengqi/support-verbose-mode
Dave Marchevsky [Wed, 29 Dec 2021 07:10:21 +0000 (02:10 -0500)]
Merge pull request #3773 from chenhengqi/support-verbose-mode

libbpf-tools: Support verbose mode and set custom libbpf print callback

2 years agoMerge pull request #3765 from bveldhoen/usdt_sample_update
Dave Marchevsky [Wed, 29 Dec 2021 04:33:29 +0000 (23:33 -0500)]
Merge pull request #3765 from bveldhoen/usdt_sample_update

Updated usdt_sample for ubuntu 21.10 (and python3)

2 years agoMerge pull request #3774 from MdSalih/docs-fixup-cpudist-example-by-pid
Dave Marchevsky [Wed, 29 Dec 2021 04:32:08 +0000 (23:32 -0500)]
Merge pull request #3774 from MdSalih/docs-fixup-cpudist-example-by-pid

docs: Fixup cpudist pid example in man page

2 years agodocs: Fixup cpudist pid example in man page
Mohammad Noor [Mon, 27 Dec 2021 19:27:20 +0000 (19:27 +0000)]
docs: Fixup cpudist pid example in man page

-P prints all by process id
-p prints specific process id

also fixed port num in example

2 years agolibbpf-tools: Make custom libbpf callback function static
Hengqi Chen [Sat, 25 Dec 2021 04:29:07 +0000 (12:29 +0800)]
libbpf-tools: Make custom libbpf callback function static

Update all tools to make libbpf_print_fn function static. While
at it, also keep the function signature in a single line since
they fit in a 100-character line.

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
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 agoUpdated usdt_sample for ubuntu 21.10 (and python3)
Bram Veldhoen [Tue, 14 Dec 2021 07:39:45 +0000 (08:39 +0100)]
Updated usdt_sample for ubuntu 21.10 (and python3)

* Updated readme for Ubuntu 21.10 and python3.
* Readability improvements.
* Using atomic_increment (thus requires bcc 0.21+).
* Using/tested probes created using systemtap (dtrace), next to the
probes created with macros in the folly header.
* Also tested while building usdt_sample with clang.
* Some (modern) cmake changes.
* Added script to execute build and sample python scripts.

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 agolibbpf-tools: add klockstat
Barret Rhoden [Tue, 2 Nov 2021 21:05:35 +0000 (17:05 -0400)]
libbpf-tools: add klockstat

This is a port of BCC's klockstat.  Differences from BCC:
- can specify a lock by ksym name, using -L
- tracks whichever task had the max time for acquire and hold, outputted
when -s > 1 (otherwise it's cluttered).
- does not reset stats each interval by default.  Can request with -R.

-------------
Usage: klockstat [-hRT] [-p PID] [-t TID] [-c FUNC] [-L LOCK] [-n NR_LOCKS]
                 [-s NR_STACKS] [-S SORT] [-d DURATION] [-i INTERVAL]

  -p, --pid=PID              Filter by process ID
  -t, --tid=TID              Filter by thread ID
  -c, --caller=FUNC          Filter by caller string prefix
  -L, --lock=LOCK            Filter by specific ksym lock name
  -n, --locks=NR_LOCKS       Number of locks to print
  -s, --stacks=NR_STACKS     Number of stack entries to print per lock
  -S, --sort=SORT            Sort by field:
                               acq_[max|total|count]
                               hld_[max|total|count]
  -d, --duration=SECONDS     Duration to trace
  -i, --interval=SECONDS     Print interval
  -R, --reset                Reset stats each interval
  -T, --timestamp            Print timestamp

  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Examples:
  klockstat                     # trace system wide until ctrl-c
  klockstat -d 5                # trace for 5 seconds
  klockstat -i 5                # print stats every 5 seconds
  klockstat -p 181              # trace process 181 only
  klockstat -t 181              # trace thread 181 only
  klockstat -c pipe_            # print only for lock callers with 'pipe_'
                                # prefix
  klockstat -L cgroup_mutex     # trace the cgroup_mutex lock only
  klockstat -S acq_count        # sort lock acquired results by acquire count
  klockstat -S hld_total        # sort lock held results by total held time
  klockstat -S acq_count,hld_total  # combination of above
  klockstat -n 3                # display top 3 locks
  klockstat -s 6                # display 6 stack entries per lock

-------------

Signed-off-by: Barret Rhoden <brho@google.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