Skip to contentSkip to conversation

bcc and bpftrace

PATCH In review Mat Martineau 2 participants 5 messages Jan 20, 2024 – Apr 4, 2024

lore
Share & tools
lore
#0 lore raw

v7 cover bcc and bpftrace

Hello -

I found the unmerged patches from late 2020 that add the bcc and bpftrace packages in patchwork:

https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

There were 5 patches in v6 of this series. Two were applied (LLVM BPF backend and libbpf), and I'm not sure the luajit-related changes are needed - please correct me if I'm mistaken here!

I've ported the commits adding the bcc and bpftrace packages to the latest buildroot tree, and addressed some of the review comments in v6. It looks like some of the original contributor's contact information has changed so please let me know if any of the tags in the commit messages need to be updated.

Jugurtha BELKALEM (1):
package/bcc: new package

Qais Yousef (1):
package/bpftrace: new package

 DEVELOPERS                     |  6 ++++
 package/Config.in              |  2 ++
 package/bcc/Config.in          | 44 +++++++++++++++++++++++++++
 package/bcc/bcc.hash           |  3 ++
 package/bcc/bcc.mk             | 43 +++++++++++++++++++++++++++
 package/bpftrace/Config.in     | 54 ++++++++++++++++++++++++++++++++++
 package/bpftrace/bpftrace.hash |  3 ++
 package/bpftrace/bpftrace.mk   | 24 +++++++++++++++
 8 files changed, 179 insertions(+)
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk
 create mode 100644 package/bpftrace/Config.in
 create mode 100644 package/bpftrace/bpftrace.hash
 create mode 100644 package/bpftrace/bpftrace.mk
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v7 1/2 package/bcc: new package

From: Jugurtha BELKALEM <[email protected]>

bcc is a front-end tool for eBPF:
https://github.com/iovisor/bcc/blob/master/README.md
eBPF is the most powerful Linux tracer, and bcc allows writing eBPF scripts in C and PYTHON3.

bcc can help to troubleshoot issues quickly on embedded systems (as long as Linux kernel version >= 4.1).

bcc can also make it easy to create observabilty tools, SDN configuration, ddos mitigation, intrusion detection and secure containers. More information is available at: https://ebpf.io/

BCC can be tested on the target :

$ mount -t debugfs none /sys/kernel/debug
$ cd /usr/share/bcc/tools
$ ./execsnoop

v7 changes:
- Ported to current buildroot
- Updated to latest bcc (0.29.1)
- Add zip host dependency
- Use PY_SKIP_DEB_LAYOUT instead of applying patch
- Don't install examples in target filesystem
- Use upstream tarball with submodule included
- Use busybox tar based on v6 feedback
- Fix formatting issues
- Propagate config dependencies
- Remove patch to control luajit config, bcc handles automatically

---
 DEVELOPERS            |  2 ++
 package/Config.in     |  1 +
 package/bcc/Config.in | 44 +++++++++++++++++++++++++++++++++++++++++++
 package/bcc/bcc.hash  |  3 +++
 package/bcc/bcc.mk    | 43 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 93 insertions(+)
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk
DEVELOPERS +2 -0
index f5b04937b611..0af50f1f848d 100644
@@ -1672,6 +1672,7 @@ N:	Joshua Henderson <[email protected]>
 F:	package/qt5/qt5wayland/
 
 N:	Jugurtha BELKALEM <[email protected]>
+F:	package/bcc/
 F:	package/python-aiofiles/
 F:	package/python-crayons/
 F:	package/python-cycler/
@@ -2603,6 +2604,7 @@ F:	board/qemu/
 F:	configs/qemu_*
 F:	package/alure/
 F:	package/aubio/
+F:	package/bcc/
 F:	package/binutils/
 F:	package/bullet/
 F:	package/clinfo/
package/Config.in +1 -0
index 5b8b15fa5400..662c935a1f1c 100644
@@ -87,6 +87,7 @@ endmenu
 
 menu "Debugging, profiling and benchmark"
 	source "package/babeltrace2/Config.in"
+	source "package/bcc/Config.in"
 	source "package/blktrace/Config.in"
 	source "package/bonnie/Config.in"
 	source "package/bpftool/Config.in"
package/bcc/Config.in new file +44 -0

44 lines not on this page · raw message

package/bcc/bcc.hash new file +3 -0
new file mode 100644
index 000000000000..b37e125b1ac7
@@ -0,0 +1,3 @@
+# locally calculated
+sha256  321575fa94f3274040379dd2d4535217f45099f4240b58a4dfc171aa8c78402f  bcc-src-with-submodule.tar.gz
+sha256  b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1  LICENSE.txt
package/bcc/bcc.mk new file +43 -0

43 lines not on this page · raw message

Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH v7 2/2 package/bpftrace: new package

In reply to Mat Martineau

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.1 and later).

Only tested on x86_64.

v7 changes:
- Ported to current buildroot release
- Update to bpftrace 0.19.1
- Add libcereal dependency
- Use new configure option for USE_SYSTEM_BPF_BCC
- Update dependencies
- Use BUILD_SHARED_LIBS=OFF instead of patching cmake files
- Don't install tool docs in target filesystem
- Propagate config dependencies

squashme: bpftrace: more review fixups

---
 DEVELOPERS                     |  4 +++
 package/Config.in              |  1 +
 package/bpftrace/Config.in     | 54 ++++++++++++++++++++++++++++++++++
 package/bpftrace/bpftrace.hash |  3 ++
 package/bpftrace/bpftrace.mk   | 24 +++++++++++++++
 5 files changed, 86 insertions(+)
 create mode 100644 package/bpftrace/Config.in
 create mode 100644 package/bpftrace/bpftrace.hash
 create mode 100644 package/bpftrace/bpftrace.mk
DEVELOPERS +4 -0
index 0af50f1f848d..2218b13f1121 100644
@@ -2505,6 +2505,9 @@ F:	package/synergy/
 N:	Prabhu Sannachi <[email protected]>
 F:	package/redis-plus-plus/
 
+N:	Qais Yousef <[email protected]>
+F:	package/bpftrace/
+
 N:	Rafal Susz <[email protected]>
 F:	board/avnet/s6lx9_microboard/
 F:	configs/s6lx9_microboard_defconfig
@@ -2606,6 +2609,7 @@ F:	package/alure/
 F:	package/aubio/
 F:	package/bcc/
 F:	package/binutils/
+F:	package/bpftrace/
 F:	package/bullet/
 F:	package/clinfo/
 F:	package/efl/
package/Config.in +1 -0
index 662c935a1f1c..1fc983dfd8aa 100644
@@ -91,6 +91,7 @@ menu "Debugging, profiling and benchmark"
 	source "package/blktrace/Config.in"
 	source "package/bonnie/Config.in"
 	source "package/bpftool/Config.in"
+	source "package/bpftrace/Config.in"
 	source "package/cache-calibrator/Config.in"
 	source "package/clinfo/Config.in"
 	source "package/clpeak/Config.in"
package/bpftrace/Config.in new file +54 -0

54 lines not on this page · raw message

package/bpftrace/bpftrace.hash new file +3 -0
new file mode 100644
index 000000000000..c2ecc927da35
@@ -0,0 +1,3 @@
+# locally calculated
+sha256  b520340f28ce4d6f2fb2355f1675b6801ff8498ed9e8bff14abbbf6baff5a08e  bpftrace-0.19.1.tar.gz
+sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
package/bpftrace/bpftrace.mk new file +24 -0
new file mode 100644
index 000000000000..072cee4ae72e
@@ -0,0 +1,24 @@
+################################################################################
+#
+# bpftrace
+#
+################################################################################
+
+BPFTRACE_VERSION = 0.19.1
+BPFTRACE_SITE = $(call github,iovisor,bpftrace,v$(BPFTRACE_VERSION))
+BPFTRACE_LICENSE = Apache-2.0
+BPFTRACE_LICENSE_FILES = LICENSE
+BPFTRACE_DEPENDENCIES = host-bison host-flex bcc libbpf cereal bzip2 xz elfutils llvm
+
+# libbfd, libopcodes
+ifeq ($(BR2_PACKAGE_BINUTILS),y)
+BPFTRACE_DEPENDENCIES += binutils
+endif
+
+BPFTRACE_CONF_OPTS += -DENABLE_MAN:BOOL=OFF \
+	-DUSE_SYSTEM_BPF_BCC:BOOL=ON \
+	-DBUILD_SHARED_LIBS:BOOL=OFF \
+	-DBUILD_TESTING:BOOL=OFF \
+	-DINSTALL_TOOL_DOCS:BOOL=OFF
+
+$(eval $(cmake-package))
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH v7 2/2] package/bpftrace: new package

Quoted 7 lines · Mat Martineau

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.1 and later).

Only tested on x86_64.

Quoted 9 lines

v7 changes:
- Ported to current buildroot release
- Update to bpftrace 0.19.1
- Add libcereal dependency
- Use new configure option for USE_SYSTEM_BPF_BCC
- Update dependencies
- Use BUILD_SHARED_LIBS=OFF instead of patching cmake files
- Don't install tool docs in target filesystem
- Propagate config dependencies

This shouldn't be in the commit message, it should be below the --- line.

Quoted 8 lines

squashme: bpftrace: more review fixups

And this shouldn't be there :-)

I applied both to master with this fixed up and a few more things.

[snip]

Quoted 6 lines
package/bpftrace/Config.in new file +0 -0
new file mode 100644
index 000000000000..e8afa37b6e63

package/bpftrace/Config.in line 10

Quoted 10 lines
package/bpftrace/Config.in new file +10 -0
@@ -0,0 +1,54 @@
+config BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
+	bool
+	default y if BR2_aarch64 || BR2_aarch64_be
+	default y if BR2_x86_64
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+
+config BR2_PACKAGE_BPFTRACE
+	bool "bpftrace"
+	depends on BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS # bcc

This is already in BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS so removed.

package/bpftrace/Config.in line 13

Quoted 3 lines
package/bpftrace/Config.in new file +3 -0
+	depends on BR2_TOOLCHAIN_USES_GLIBC # bcc
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # bcc -> clang
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libbpf

This is considered an arch dependency so moved to the beginning of the
dependencies list, and repeated in the comment.

package/bpftrace/Config.in line 19

Quoted 6 lines
package/bpftrace/Config.in new file +6 -0
+	depends on BR2_TOOLCHAIN_HAS_THREADS # libbpf
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_13 # libbpf
+	depends on BR2_INSTALL_LIBSTDCPP # bcc -> clang
+	depends on BR2_HOST_GCC_AT_LEAST_7 # bcc -> clang
+	depends on BR2_USE_WCHAR # bcc -> clang, bcc -> python3, libbpf
+	depends on BR2_USE_MMU # bcc -> python3

This is also an arch dependency.

package/bpftrace/Config.in line 30

Quoted 11 lines
package/bpftrace/Config.in new file +11 -0
+	depends on BR2_TOOLCHAIN_HAS_THREADS # bcc -> clang, bcc -> python3
+	depends on !BR2_STATIC_LIBS # bcc -> clang, bcc -> python3, libbpf
+	select BR2_PACKAGE_BCC
+	select BR2_PACKAGE_LIBBPF
+	select BR2_PACKAGE_CEREAL
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_BZIP2
+	select BR2_PACKAGE_XZ
+	# LLVM RTTI mendatory: https://github.com/iovisor/bpftrace/issues/1156
+	select BR2_PACKAGE_LLVM_RTTI
+	select BR2_PACKAGE_LLVM

I ordered all selects alphabetically.

Quoted 12 lines
package/bpftrace/Config.in new file +12 -0
+	help
+	  bpftrace is a high-level tracing language for Linux enhanced
+	  Berkeley Packet Filter (eBPF) available in recent Linux
+	  kernels (4.x).
+
+	  bpftrace uses LLVM as a backend to compile scripts to
+	  BPF-bytecode and makes use of BCC for interacting with the
+	  Linux BPF system, as well as existing Linux tracing
+	  capabilities: kernel dynamic tracing (kprobes), user-level
+	  dynamic tracing (uprobes), and tracepoints. The bpftrace
+	  language is inspired by awk and C, and predecessor tracers
+	  such as DTrace and SystemTap.

package/bpftrace/Config.in line 52

Quoted 10 lines
package/bpftrace/Config.in new file +10 -0
+
+	  It's highly recommended to NOT strip bpftrace binary.
+	  To do so, add "bpftrace" to BR2_STRIP_EXCLUDE_FILES.
+	  See:
+	    https://bugzilla.redhat.com/show_bug.cgi?id=1865787
+
+	  https://www.github.com/iovisor/bpftrace
+
+comment "bpftrace needs a glibc toolchain w/ C++, gcc >= 7"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS

This should have been BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS. In addition, as
mentioned, the SYNC_4 and MMU dependencies are missing.

package/bpftrace/Config.in line 54

Quoted 2 lines
package/bpftrace/Config.in new file +2 -0
+	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_7

host GCC 7 and kernel headers 4.13 dependencies are missing here.

Quoted 16 lines
package/bpftrace/bpftrace.hash new file +3 -0
new file mode 100644
index 000000000000..c2ecc927da35
@@ -0,0 +1,3 @@
+# locally calculated
+sha256  b520340f28ce4d6f2fb2355f1675b6801ff8498ed9e8bff14abbbf6baff5a08e  bpftrace-0.19.1.tar.gz
+sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
package/bpftrace/bpftrace.mk new file +1 -0
new file mode 100644
index 000000000000..072cee4ae72e
@@ -0,0 +1,24 @@
+################################################################################

package/bpftrace/bpftrace.mk line 11

Quoted 10 lines
package/bpftrace/bpftrace.mk new file +10 -0
+#
+# bpftrace
+#
+################################################################################
+
+BPFTRACE_VERSION = 0.19.1
+BPFTRACE_SITE = $(call github,iovisor,bpftrace,v$(BPFTRACE_VERSION))
+BPFTRACE_LICENSE = Apache-2.0
+BPFTRACE_LICENSE_FILES = LICENSE
+BPFTRACE_DEPENDENCIES = host-bison host-flex bcc libbpf cereal bzip2 xz elfutils llvm

I ordered these alphabetically, and changed to one per line.

package/bpftrace/bpftrace.mk line 22

Quoted 11 lines
package/bpftrace/bpftrace.mk new file +11 -0
+
+# libbfd, libopcodes
+ifeq ($(BR2_PACKAGE_BINUTILS),y)
+BPFTRACE_DEPENDENCIES += binutils
+endif
+
+BPFTRACE_CONF_OPTS += -DENABLE_MAN:BOOL=OFF \
+	-DUSE_SYSTEM_BPF_BCC:BOOL=ON \
+	-DBUILD_SHARED_LIBS:BOOL=OFF \
+	-DBUILD_TESTING:BOOL=OFF \
+	-DINSTALL_TOOL_DOCS:BOOL=OFF

I ordered these alphabetically as well.

Regards,
Arnout

package/bpftrace/bpftrace.mk line 24

Quoted 2 lines
package/bpftrace/bpftrace.mk new file +2 -0
+
+$(eval $(cmake-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

Re: [Buildroot] [PATCH v7 2/2] package/bpftrace: new package

Quoted 20 lines · Arnout Vandecappelle
Quoted 7 lines · Mat Martineau

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.1 and later).

Only tested on x86_64.

Quoted 9 lines

v7 changes:
- Ported to current buildroot release
- Update to bpftrace 0.19.1
- Add libcereal dependency
- Use new configure option for USE_SYSTEM_BPF_BCC
- Update dependencies
- Use BUILD_SHARED_LIBS=OFF instead of patching cmake files
- Don't install tool docs in target filesystem
- Propagate config dependencies

Quoted 9 lines

This shouldn't be in the commit message, it should be below the --- line.

Quoted 7 lines

Hi Arnout,

Quoted 3 lines
Quoted 1 line

squashme: bpftrace: more review fixups

And this shouldn't be there :-)

Whoops, sorry about that!

Quoted 2 lines

I applied both to master with this fixed up and a few more things.

Thanks so much for the review and fixups, I'll take that information in to account for future patches. I will send followup patches for the latest bcc and bpftrace versions.

Regards,

Mat
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot