import bpftrace-0.10.0-4.el8

This commit is contained in:
CentOS Sources 2020-11-03 06:59:23 -05:00 committed by Andrew Lukoshko
parent 0069d6708d
commit 52f4f58b77
8 changed files with 350 additions and 14 deletions

View File

@ -1 +1 @@
f35927be0719e7537e10cab1f4bee28705270ff8 SOURCES/bpftrace-0.9.2.tar.gz 1b1d4e5058e07f82904971e65733791b25ef5263 SOURCES/bpftrace-0.10.0.tar.gz

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/bpftrace-0.9.2.tar.gz SOURCES/bpftrace-0.10.0.tar.gz

View File

@ -0,0 +1,126 @@
From 3516f05627b33cb2e6e74965650c6d6c043f78f9 Mon Sep 17 00:00:00 2001
From: Sumanth Korikkar <sumanthk@linux.ibm.com>
Date: Mon, 6 Apr 2020 09:23:34 +0200
Subject: [PATCH] bpftrace: Add s390x register support
Add s390x specific registers. This is needed for bpftrace builtins like argX,
regs(), retval etc. This commit provides various functions to perform proper
offset calculation from the pt_regs context. The builtin functions of
bpftrace uses these offset functions to generate the proper bytecode for s390x
Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
src/arch/CMakeLists.txt | 3 ++
src/arch/s390.cpp | 85 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+)
create mode 100644 src/arch/s390.cpp
diff --git a/src/arch/CMakeLists.txt b/src/arch/CMakeLists.txt
index 7156276..51707cb 100644
--- a/src/arch/CMakeLists.txt
+++ b/src/arch/CMakeLists.txt
@@ -3,6 +3,9 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR
CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
add_library(arch ppc64.cpp)
+elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390" OR
+ CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x")
+ add_library(arch s390.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
add_library(arch x86_64.cpp)
else()
diff --git a/src/arch/s390.cpp b/src/arch/s390.cpp
new file mode 100644
index 0000000..a2278c8
--- /dev/null
+++ b/src/arch/s390.cpp
@@ -0,0 +1,85 @@
+#include "arch.h"
+
+#include <algorithm>
+#include <array>
+
+#define REQ_REGISTERS 19
+#define ARG_REGISTERS 5
+
+namespace bpftrace {
+namespace arch {
+
+// clang-format off
+static std::array<std::string, REQ_REGISTERS> registers = {
+ // Breakpoint event address
+ "arg",
+ "pswmask",
+ // Instruction address
+ "pswaddr",
+ "r0",
+ "r1",
+ "r2",
+ "r3",
+ "r4",
+ "r5",
+ "r6",
+ "r7",
+ "r8",
+ "r9",
+ "r10",
+ "r11",
+ "r12",
+ "r13",
+ "r14",
+ "r15",
+};
+
+static std::array<std::string, ARG_REGISTERS> arg_registers = {
+ "r2",
+ "r3",
+ "r4",
+ "r5",
+ "r6",
+};
+// clang-format on
+
+int offset(std::string reg_name)
+{
+ auto it = find(registers.begin(), registers.end(), reg_name);
+ if (it == registers.end())
+ return -1;
+ return distance(registers.begin(), it);
+}
+
+int max_arg()
+{
+ return arg_registers.size() - 1;
+}
+
+int arg_offset(int arg_num)
+{
+ return offset(arg_registers.at(arg_num));
+}
+
+int ret_offset()
+{
+ return offset("r2");
+}
+
+int pc_offset()
+{
+ return offset("pswaddr");
+}
+
+int sp_offset()
+{
+ return offset("r15");
+}
+
+std::string name()
+{
+ return std::string("s390x");
+}
+
+} // namespace arch
+} // namespace bpftrace
--
2.25.3

View File

@ -0,0 +1,27 @@
From 042675755d1ec2446105af700cd9cfb1bace905c Mon Sep 17 00:00:00 2001
From: Masanori Misono <m.misono760@gmail.com>
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<std::string> 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

View File

@ -0,0 +1,64 @@
From e9ebda9b3d14831df5e1c5174d21f322e084d074 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
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

View File

@ -1,14 +1,14 @@
From 1dce61acfec57712f84cfdf2a8f4c69d27744b04 Mon Sep 17 00:00:00 2001 From a09a2f06d6316801e89e7f676d0839910aea765d Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com> From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 11 Jun 2019 16:41:59 +0200 Date: Tue, 11 Jun 2019 16:41:59 +0200
Subject: RHEL 8 fixes Subject: [PATCH] RHEL 8 fixes
Fixes the following RHEL 8 specific issues: Fixes the following RHEL 8 specific issues:
- library path in gethostlatency - library path in gethostlatency and threadsnoop
--- ---
tools/gethostlatency.bt | 12 ++++++------ tools/gethostlatency.bt | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-) tools/threadsnoop.bt | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/gethostlatency.bt b/tools/gethostlatency.bt diff --git a/tools/gethostlatency.bt b/tools/gethostlatency.bt
index a1ac1b2..ade1005 100755 index a1ac1b2..ade1005 100755
@ -38,6 +38,19 @@ index a1ac1b2..ade1005 100755
/@start[tid]/ /@start[tid]/
{ {
$latms = (nsecs - @start[tid]) / 1000000; $latms = (nsecs - @start[tid]) / 1000000;
-- diff --git a/tools/threadsnoop.bt b/tools/threadsnoop.bt
2.20.1 index e4d3875..c56b1ac 100755
--- a/tools/threadsnoop.bt
+++ b/tools/threadsnoop.bt
@@ -18,7 +18,7 @@ BEGIN
printf("%-10s %-6s %-16s %s\n", "TIME(ms)", "PID", "COMM", "FUNC");
}
-uprobe:/lib/x86_64-linux-gnu/libpthread.so.0:pthread_create
+uprobe:/usr/lib64/libpthread.so:pthread_create
{
printf("%-10u %-6d %-16s %s\n", elapsed / 1000000, pid, comm,
usym(arg2));
--
2.25.4

View File

@ -0,0 +1,73 @@
From 604c9d5619ca01a46c208a70b7beec3041ba77a9 Mon Sep 17 00:00:00 2001
From: Daniel Xu <dxu@dxuuu.xyz>
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

View File

@ -1,14 +1,20 @@
%bcond_without llvm_static %bcond_without llvm_static
Name: bpftrace Name: bpftrace
Version: 0.9.2 Version: 0.10.0
Release: 1%{?dist} Release: 4%{?dist}
Summary: High-level tracing language for Linux eBPF Summary: High-level tracing language for Linux eBPF
License: ASL 2.0 License: ASL 2.0
URL: https://github.com/iovisor/bpftrace URL: https://github.com/iovisor/bpftrace
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Patch0: %{name}-%{version}-RHEL-8-fixes.patch 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 # Arches will be included as upstream support is added and dependencies are
# satisfied in the respective arches # satisfied in the respective arches
@ -39,8 +45,16 @@ and predecessor tracers such as DTrace and SystemTap
%prep %prep
%autosetup -p1 %setup
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%ifarch aarch64
%patch10 -p1
%endif
%build %build
%cmake . \ %cmake . \
@ -59,8 +73,8 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \
sed -i -e '1s=^#!/usr/bin/env %{name}\([0-9.]\+\)\?$=#!%{_bindir}/%{name}=' {} \; sed -i -e '1s=^#!/usr/bin/env %{name}\([0-9.]\+\)\?$=#!%{_bindir}/%{name}=' {} \;
# Move man pages to the right location # Move man pages to the right location
mkdir -p %{buildroot}%{_mandir} #mkdir -p %{buildroot}%{_mandir}
mv %{buildroot}%{_prefix}/man/* %{buildroot}%{_mandir}/ #mv %{buildroot}%{_prefix}/man/* %{buildroot}%{_mandir}/
%files %files
@ -74,9 +88,28 @@ mv %{buildroot}%{_prefix}/man/* %{buildroot}%{_mandir}/
%{_mandir}/man8/* %{_mandir}/man8/*
%attr(0755,-,-) %{_datadir}/%{name}/tools/*.bt %attr(0755,-,-) %{_datadir}/%{name}/tools/*.bt
%{_datadir}/%{name}/tools/doc/*.txt %{_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 %changelog
* Thu Jun 11 2020 Jerome Marchand <jmarchan@redhat.com> - 0.10.0-4
- Fix KBUILD_MODNAME
* Thu Jun 11 2020 Jerome Marchand <jmarchan@redhat.com> - 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 <jmarchan@redhat.com> - 0.10.0-2
- Fix libpthread path in threadsnoop
* Wed Apr 22 2020 Jerome Marchand <jmarchan@redhat.com> - 0.10.0-1
- Rebase on bpftrace 0.10.0
* Fri Nov 08 2019 Jerome Marchand <jmarchan@redhat.com> - 0.9.2-1 * Fri Nov 08 2019 Jerome Marchand <jmarchan@redhat.com> - 0.9.2-1
- Rebase on bpftrace 0.9.2 - Rebase on bpftrace 0.9.2