Skip to content

Commit

Permalink
bpftrace: fix the runtime ptest errors
Browse files Browse the repository at this point in the history
bpftrace/bpftrace#2935 changed the test scripts,
then the runtime ptest got the following errors:
| KeyError: 'BPFTRACE_AOT_RUNTIME_TEST_EXECUTABLE'
| Output: /bin/sh: line 1: /usr/bin/: Is a directory\n
The changes in run-ptest is to solve these problems.

After fixing the previously mentioned problems,
we got the the following errors while running the runtime ptest:
| error: <unknown>:0:0: in function BEGIN i64 (ptr): 0x56056cec80f0: i64 = GlobalAddress<ptr @__atomic_compare_exchange> 0 too many arguments
The new patch in the bb file is to solve this problem.

Signed-off-by: Wentao Zhang <[email protected]>
  • Loading branch information
wentao-windriver authored and kraj committed Apr 10, 2024
1 parent 13dcab8 commit c38281d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 76538f80d3c56430c3105b6a3a7614313b01ddc5 Mon Sep 17 00:00:00 2001
From: Frank van der Linden <[email protected]>
Date: Mon, 11 Mar 2024 15:35:32 +0000
Subject: [PATCH] use 64bit alignment for map counter atomic add

For an atomic inc of a map counter (ringbuf loss counter), generate
IR with 64bit alignment. This is more correct, and will avoid problems
with upcoming LLVM versions, as they will emit a function call for
a potentially unaligned atomicrmw. This will lead to an error like this:

error: <unknown>:0:0: in function BEGIN i64 (ptr): t15: i64 = GlobalAddress<ptr @__atomic_compare_exchange> 0 too many arguments

Upstream-Status: Backport [https://github.com/bpftrace/bpftrace/pull/3045/commits/3878a437ca946ab69cc92bcd2cb3c2369625b3dc]

Signed-off-by: Wentao Zhang <[email protected]>
---
CHANGELOG.md | 2 ++
src/ast/irbuilderbpf.cpp | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4fa3b673..81b6e0e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,8 @@ and this project adheres to
#### Fixed
- Fix field resolution on structs with anon union as first field
- [#2964](https://github.com/bpftrace/bpftrace/pull/2964)
+- Fix alignment of atomic map counter update
+ - [#3045](https://github.com/bpftrace/bpftrace/pull/3045)
#### Docs
#### Tools

diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp
index 2ff3c0ce..98c4b0d5 100644
--- a/src/ast/irbuilderbpf.cpp
+++ b/src/ast/irbuilderbpf.cpp
@@ -1474,7 +1474,7 @@ void IRBuilderBPF::CreateAtomicIncCounter(const std::string &map_name,
CREATE_ATOMIC_RMW(AtomicRMWInst::BinOp::Add,
val,
getInt64(1),
- 1,
+ 8,
AtomicOrdering::SequentiallyConsistent);
CreateBr(lookup_merge_block);

--
2.35.5

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# parameter in ptest-runner is necessary to not kill it before completion

cd tests || exit 1
export BPFTRACE_RUNTIME_TEST_EXECUTABLE=/usr/bin
export BPFTRACE_RUNTIME_TEST_EXECUTABLE=/usr/bin/bpftrace
export BPFTRACE_AOT_RUNTIME_TEST_EXECUTABLE=/usr/bin/bpftrace-aotrt

PASS_CNT=0
FAIL_CNT=0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \
file://0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch \
file://0003-ast-Adjust-to-enum-changes-in-llvm-18.patch \
file://0004-cmake-Bump-max-LLVM-version-to-18.patch \
file://0001-use-64bit-alignment-for-map-counter-atomic-add.patch \
file://run-ptest \
"
SRCREV = "fe6362b4e2c1b9d0833c7d3f308c1d4006b54723"
Expand Down

0 comments on commit c38281d

Please sign in to comment.