diff --git a/SOURCES/bpftrace-0.10.0-Fix-KBUILD_MODNAME.patch b/SOURCES/bpftrace-0.10.0-Fix-KBUILD_MODNAME.patch new file mode 100644 index 0000000..420e7ba --- /dev/null +++ b/SOURCES/bpftrace-0.10.0-Fix-KBUILD_MODNAME.patch @@ -0,0 +1,27 @@ +From 042675755d1ec2446105af700cd9cfb1bace905c Mon Sep 17 00:00:00 2001 +From: Masanori Misono +Date: Wed, 27 May 2020 17:54:52 +0900 +Subject: [PATCH] Fix KBUILD_MODNAME + +Use "bpftrace" instead of '"bpftrace"'. Previously this causes build +error if included header files use KBUILD_MODNAME. +--- + src/utils.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/utils.cpp b/src/utils.cpp +index dc82689..cec77cf 100644 +--- a/src/utils.cpp ++++ b/src/utils.cpp +@@ -363,7 +363,7 @@ std::vector get_kernel_cflags( + cflags.push_back("-D__HAVE_BUILTIN_BSWAP16__"); + cflags.push_back("-D__HAVE_BUILTIN_BSWAP32__"); + cflags.push_back("-D__HAVE_BUILTIN_BSWAP64__"); +- cflags.push_back("-DKBUILD_MODNAME='\"bpftrace\"'"); ++ cflags.push_back("-DKBUILD_MODNAME=\"bpftrace\""); + + // If ARCH env variable is set, pass this along. + if (archenv) +-- +2.25.4 + diff --git a/SOURCES/bpftrace-0.10.0-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch b/SOURCES/bpftrace-0.10.0-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch new file mode 100644 index 0000000..3c1599f --- /dev/null +++ b/SOURCES/bpftrace-0.10.0-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch @@ -0,0 +1,64 @@ +From e9ebda9b3d14831df5e1c5174d21f322e084d074 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Thu, 11 Jun 2020 14:56:36 +0200 +Subject: [PATCH] RHEL-8: aarch64: fixes statsnoop and opensnoop + +On aarch64 the open syscall has been dropped. Only openat remains, +wich is called by libc open() function. + +The state of *stat* syscalls, is a mess. They are several generations +of the system calls, and not all arches provides all of them. For +instance, new(l)stat are missing from aarch64. + +The only way I can think of fixing thess is RHEL-8 only arch specific +patches. +--- + tools/opensnoop.bt | 2 -- + tools/statsnoop.bt | 8 ++------ + 2 files changed, 2 insertions(+), 8 deletions(-) + +diff --git a/tools/opensnoop.bt b/tools/opensnoop.bt +index a7de802..d99db93 100755 +--- a/tools/opensnoop.bt ++++ b/tools/opensnoop.bt +@@ -21,13 +21,11 @@ BEGIN + printf("%-6s %-16s %4s %3s %s\n", "PID", "COMM", "FD", "ERR", "PATH"); + } + +-tracepoint:syscalls:sys_enter_open, + tracepoint:syscalls:sys_enter_openat + { + @filename[tid] = args->filename; + } + +-tracepoint:syscalls:sys_exit_open, + tracepoint:syscalls:sys_exit_openat + /@filename[tid]/ + { +diff --git a/tools/statsnoop.bt b/tools/statsnoop.bt +index b2d529e..f612ea9 100755 +--- a/tools/statsnoop.bt ++++ b/tools/statsnoop.bt +@@ -30,17 +30,13 @@ tracepoint:syscalls:sys_enter_statfs + @filename[tid] = args->pathname; + } + +-tracepoint:syscalls:sys_enter_statx, +-tracepoint:syscalls:sys_enter_newstat, +-tracepoint:syscalls:sys_enter_newlstat ++tracepoint:syscalls:sys_enter_statx + { + @filename[tid] = args->filename; + } + + tracepoint:syscalls:sys_exit_statfs, +-tracepoint:syscalls:sys_exit_statx, +-tracepoint:syscalls:sys_exit_newstat, +-tracepoint:syscalls:sys_exit_newlstat ++tracepoint:syscalls:sys_exit_statx + /@filename[tid]/ + { + $ret = args->ret; +-- +2.25.4 + diff --git a/SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch b/SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch new file mode 100644 index 0000000..95c4f22 --- /dev/null +++ b/SOURCES/bpftrace-0.10.0-Remove-RLIMIT_AS-limit.patch @@ -0,0 +1,73 @@ +From 604c9d5619ca01a46c208a70b7beec3041ba77a9 Mon Sep 17 00:00:00 2001 +From: Daniel Xu +Date: Thu, 28 May 2020 23:12:47 -0700 +Subject: [PATCH] Remove RLIMIT_AS limit + +We haven't seen any OOM issues in a while so I suspect either our type +fixes in bpftrace or upstream llvm changes have resolved the issue. + +This closes #1355. +--- + src/CMakeLists.txt | 1 - + src/main.cpp | 26 -------------------------- + 2 files changed, 27 deletions(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 4fa0418..ac040f4 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -99,7 +99,6 @@ if (BUILD_ASAN) + # target_link_options is supported in CMake 3.13 and newer + message("Please use CMake 3.13 or newer to enable ASAN") + endif() +- target_compile_definitions(bpftrace PRIVATE BUILD_ASAN) + target_compile_options(bpftrace PUBLIC "-fsanitize=address") + target_link_options(bpftrace PUBLIC "-fsanitize=address") + endif() +diff --git a/src/main.cpp b/src/main.cpp +index 4ff9d37..d92ea8d 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -92,30 +92,6 @@ static void enforce_infinite_rlimit() { + "\"ulimit -l 8192\" to fix the problem" << std::endl; + } + +-#ifdef BUILD_ASAN +-static void cap_memory_limits() +-{ +-} +-#else +-static void cap_memory_limits() { +- struct rlimit rl = {}; +- int err; +- uint64_t memory_limit_bytes = 1 * 1024 * 1024 * 1024; +- +- // this is a safety measure for issue #528 "LLVM ERROR: out of memory", +- // and caps bpftrace memory to 1 Gbyte. This may be removed once the LLVM +- // issue has been fixed, and this is no longer deemed necessary. +- rl.rlim_max = memory_limit_bytes; +- rl.rlim_cur = rl.rlim_max; +- err = setrlimit(RLIMIT_AS, &rl); +- err += setrlimit(RLIMIT_RSS, &rl); +- if (err) +- std::cerr << std::strerror(err)<<": couldn't set RLIMIT_AS and " << +- "RLIMIT_RSS for bpftrace (these are a temporary precaution to stop " << +- "accidental large program loads, and are not required" << std::endl; +-} +-#endif // BUILD_ASAN +- + bool is_root() + { + if (geteuid() != 0) +@@ -425,8 +401,6 @@ int main(int argc, char *argv[]) + // rlimit? + enforce_infinite_rlimit(); + +- cap_memory_limits(); +- + // positional parameters + while (optind < argc) { + bpftrace.add_param(argv[optind]); +-- +2.25.4 + diff --git a/SPECS/bpftrace.spec b/SPECS/bpftrace.spec index f423299..c18ce6c 100644 --- a/SPECS/bpftrace.spec +++ b/SPECS/bpftrace.spec @@ -2,7 +2,7 @@ Name: bpftrace Version: 0.10.0 -Release: 2%{?dist} +Release: 4%{?dist} Summary: High-level tracing language for Linux eBPF License: ASL 2.0 @@ -10,6 +10,11 @@ URL: https://github.com/iovisor/bpftrace Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz Patch0: %{name}-%{version}-RHEL-8-fixes.patch Patch1: %{name}-%{version}-Add-s390x-register-support.patch +Patch2: %{name}-%{version}-Remove-RLIMIT_AS-limit.patch +Patch3: %{name}-%{version}-Fix-KBUILD_MODNAME.patch +# WARNING: because of the arch-specific patch, no autosetup is used +# Remember to patch accordingly +Patch10: %{name}-%{version}-RHEL-8-aarch64-fixes-statsnoop-and-opensnoop.patch # Arches will be included as upstream support is added and dependencies are # satisfied in the respective arches @@ -40,8 +45,16 @@ and predecessor tracers such as DTrace and SystemTap %prep -%autosetup -p1 +%setup +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +%ifarch aarch64 +%patch10 -p1 +%endif %build %cmake . \ @@ -75,9 +88,22 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \ %{_mandir}/man8/* %attr(0755,-,-) %{_datadir}/%{name}/tools/*.bt %{_datadir}/%{name}/tools/doc/*.txt - +# tcp_drop() is inlined on ppc64 +%ifarch %{power64} +%exclude %{_datadir}/%{name}/tools/tcpdrop.bt +%exclude %{_datadir}/%{name}/tools/doc/tcpdrop_example.txt +%exclude %{_mandir}/man8/tcpdrop.8.gz +%endif %changelog +* Thu Jun 11 2020 Jerome Marchand - 0.10.0-4 +- Fix KBUILD_MODNAME + +* Thu Jun 11 2020 Jerome Marchand - 0.10.0-3 +- Fix ENOMEM issue on arm64 machine with many cpus +- Fix statsnoop and opensnoop on aarch64 +- Drop tcpdrop on ppc64 + * Tue May 05 2020 Jerome Marchand - 0.10.0-2 - Fix libpthread path in threadsnoop