platform/upstream/bcc.git
2 years agoAdd davemarchevsky to CODEOWNERS for everything
Dave Marchevsky [Sun, 9 Jan 2022 22:14:26 +0000 (17:14 -0500)]
Add davemarchevsky to CODEOWNERS for everything

I can't figure out how to get emailed for all PRs, and I'm doing reviews for the whole repo, so add self to codeowners everywhere.

2 years agoMerge pull request #3801 from chenhengqi/issue-3793
Dave Marchevsky [Sun, 9 Jan 2022 09:52:47 +0000 (04:52 -0500)]
Merge pull request #3801 from chenhengqi/issue-3793

bcc: Allow specify wakeup_events for perf buffer

2 years agolibbpf-tools: README how to update libbpf submodule
Liz Rice [Fri, 7 Jan 2022 14:51:36 +0000 (14:51 +0000)]
libbpf-tools: README how to update libbpf submodule

An outdated libbpf submodule can cause the libbpf-tools `make` to fail. Adding note to the README on how to update it.

2 years agoreallocarray: eliminate compilation warnings (#3798)
Rong Tao [Sat, 8 Jan 2022 19:36:00 +0000 (03:36 +0800)]
reallocarray: eliminate compilation warnings (#3798)

there are compile warnings below for klockstat.

```bash
  CC       klockstat.o
klockstat.c: In function ‘print_stats’:
klockstat.c:396:12: warning: implicit declaration of function ‘reallocarray’; did you mean ‘realloc’? [-Wimplicit-function-declaration]
    stats = reallocarray(stats, stats_sz, sizeof(void *));
            ^~~~~~~~~~~~
            realloc
klockstat.c:396:10: warning: assignment to ‘struct stack_stat **’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
    stats = reallocarray(stats, stats_sz, sizeof(void *));
          ^
  BINARY   klockstat
```

Defining _GNU_SOURCE fixed the problem.

2 years agobcc: Allow specify wakeup_events for perf buffer
Hengqi Chen [Sat, 8 Jan 2022 14:47:54 +0000 (22:47 +0800)]
bcc: Allow specify wakeup_events for perf buffer

This commit adds a new option `wakeup_events` to the open_perf_buffer API.
This provides an alternative to solve #3793.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years agoMerge pull request #3794 from etep/vdso-detection-fix
Dave Marchevsky [Fri, 7 Jan 2022 20:36:43 +0000 (15:36 -0500)]
Merge pull request #3794 from etep/vdso-detection-fix

bcc_syms.cc: bug fix; identify VDSO using 'name' vs. 'path'

2 years agobcc_syms.cc: bug fix; identify VDSO using 'name' vs. 'path' (use of path incorrectly...
Pete Stevenson [Thu, 6 Jan 2022 23:09:54 +0000 (15:09 -0800)]
bcc_syms.cc: bug fix; identify VDSO using 'name' vs. 'path' (use of path incorrectly compares /proc/<pid>/root[vdso] with [vdso]).

Signed-off-by: Pete Stevenson <jps@pixielabs.ai>
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