-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DLPX-91640 bpftrace: Automatic merge failed #35
Merged
manoj-joseph
merged 20 commits into
develop
from
dlpx/pr/manoj-joseph/68dda4ce-4238-4683-951a-0c0d7cdf9023
Jul 16, 2024
Merged
DLPX-91640 bpftrace: Automatic merge failed #35
manoj-joseph
merged 20 commits into
develop
from
dlpx/pr/manoj-joseph/68dda4ce-4238-4683-951a-0c0d7cdf9023
Jul 16, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It seems that the CI machines were updated to a kernel which has the tcp_drop function inlined. Therefore, we need to use the new version of tcpdrop.bt.
Consolidate and cleanup information that is being printed in the verbose (-v) and debugging output (-d). The main idea is: - the verbose output is intended for users to get more information on what bpftrace is doing and where it is (possibly) failing, - the debug output is intended for developers to help them debugging bpftrace by providing very detailed outputs of individual stages of bon pftrace runtime. The main (user-facing) change this brings is that it introduces a mandatory argument to the -d option which allows to pick the stage whose output should be printed. The currently supported stages are: - 'ast' - prints the AST after each pass - 'codegen' - prints the LLVM IR code as emit by CodegenLLVM - 'codegen-opt' - prints the LLVM IR code after it is optimized by LLVM (i.e. what is actually compiled to BPF bytecode) - 'libbpf' - captures and prints libbpf log for all libbpf operations that we use - 'verifier' - captures and prints the BPF verifier log On top of that, -d can be used multiple times with different arguments and the argument 'all' activates all of the above. Another change is that -d no longer executes a dry run. The reason is that we're printing information from later stages so we need to let bpftrace run all the time. A new option for dry run will be added in the following patch. In addition, there are more user-facing changes: - remove the -dd option, - allow simultaneous use of -v and -d, - add --debug as a long version of -d. Also, some minor refactorings were done: - make sure the verbosity output always goes to stderr while the debugging output always goes to stdout, - improve some formatting of verbose outputs.
The option terminates bpftrace right after all the probes are attached. This can be useful to test that the script can be parsed, loaded, and attached, without actually executing it. We use this in the tools parsing test since the -d option no longer does a dry run.
Similar to what was done for count and sum allow avg to be used in expressions. This is the last map type that will be supported for this functionality. Issue: bpftrace/bpftrace#3126 Issue: bpftrace/bpftrace#3216
"print_per_cpu_map_vals" is a racy test due to the use of a very active probe and per-cpu maps. Let's just use 'BEGIN' to test printing even though this doesn't really exercise the cpu aggregation path as 'BEGIN' only runs on one CPU.
Character literals appear to not be supported at this time. Hence, let's clarify this aspect in the documentation. Fixes: fd0461d ("docs: entries for new int syntax") Fixes: #3278
- Remove entry for #3281, as it's a fix for a bug that hasn't made it to a release - Quote a bunch of things with backticks to make the markdown render more nicely
This will make sure we don't forget to reset async ids in 'create_reset_ids' and also makes sure we're incrementing the id whenever we get it (instead of doing it at some later, random instruction). This is follow up to a conversation here: bpftrace/bpftrace#3249 (comment)
If it is dummy, then the visit() operation should not be executed. For example, on aarch64, there is no syscalls:sys_{enter,exit}_open tracepoint, however, opensnoop.bt tool will try to attch them and visit args's field. We expect to get a warning, but instead we get a segmentation fault. As follows: $ sudo gdb bpftrace ... (gdb) set args opensnoop.bt (gdb) r opensnoop.bt:22-24: WARNING: tracepoint not found: syscalls:sys_enter_open opensnoop.bt:28-30: WARNING: tracepoint not found: syscalls:sys_exit_open Thread 1 "bpftrace" received signal SIGSEGV, Segmentation fault. 0x000000000052bbd8 in __gnu_cxx::__normal_iterator<bpftrace::Field const*, std::vector<bpftrace::Field, std::allocator<bpftrace::Field> > >::__normal_iterator (this=0xffffffffb0b8, __i=<error reading variable: Cannot access memory at address 0x10>) at /usr/include/c++/14/bits/stl_iterator.h:1068 1068 : _M_current(__i) { } (gdb) bt #0 0x000000000052bbd8 in __gnu_cxx::__normal_iterator<bpftrace::Field const*, std::vector<bpftrace::Field, std::allocator<bpftrace::Field> > >::__normal_iterator (this=0xffffffffb0b8, __i=<error reading variable: Cannot access memory at address 0x10>) at /usr/include/c++/14/bits/stl_iterator.h:1068 #1 0x0000000000525bdc in std::vector<bpftrace::Field, std::allocator<bpftrace::Field> >::begin (this=0x10) at /usr/include/c++/14/bits/stl_vector.h:884 #2 0x000000000059ce8c in bpftrace::Struct::GetField (this=0x0, name="filename") at /home/rongtao/Git/bpftrace/bpftrace/src/struct.cpp:131 #3 0x00000000005a70a0 in bpftrace::SizedType::GetField (this=0xe9b998, name="filename") at /home/rongtao/Git/bpftrace/bpftrace/src/types.cpp:538 #4 0x00000000007c7178 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, acc=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:1973 #5 0x0000000000847db0 in bpftrace::ast::FieldAccess::accept (this=0xe9be30, v=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:31 #6 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xe9be30) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778 #7 0x00000000007c8bec in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, assignment=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2218 #8 0x0000000000847eb4 in bpftrace::ast::AssignMapStatement::accept (this=0xffffe4429250, v=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:36 #9 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xffffe4429250) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778 #10 0x00000000007ca4c4 in bpftrace::ast::CodegenLLVM::generateProbe (this=0xffffffffc650, probe=..., full_func_id="dummy", name="dummy", func_type=0xff2b50, usdt_location_index=std::optional [no contained value], dummy=true) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2539 #11 0x00000000007cb4e4 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, probe=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2734 #12 0x00000000008480f0 in bpftrace::ast::Probe::accept (this=0xffffe4427650, v=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:47 #13 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xffffe4427650) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778 #14 0x00000000007cb7a4 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, program=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2752 #15 0x000000000084818c in bpftrace::ast::Program::accept (this=0xe90f50, v=...) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:50 #16 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xe90f50) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778 #17 0x00000000007d03fc in bpftrace::ast::CodegenLLVM::generate_ir (this=0xffffffffc650) at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3450 #18 0x0000000000478138 in main (argc=2, argv=0xfffffffff4c8) at /home/rongtao/Git/bpftrace/bpftrace/src/main.cpp:898 We can simplify opensnoop.bt to: tracepoint:syscalls:sys_enter_open_not_exist, tracepoint:syscalls:sys_enter_openat { @ = args.filename; } This will produce the following error: stdin:1:1-45: WARNING: tracepoint not found: syscalls:sys_enter_open_not_exist tracepoint:syscalls:sys_enter_open_not_exist,tracepoint:syscalls:sys_enter_openat {@ = args.filename;} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Segmentation fault We need to generate the dummy probe only for cases when none of the probe attach points exists. Link: bpftrace/bpftrace#3274 Signed-off-by: Viktor Malik <viktor.malik@gmail.com> Signed-off-by: Rong Tao <rongtao@cestc.cn>
Instead of using bpf_prog_load to load BPF programs and bpf_map_create to create BPF maps, use bpf_object__load to load everything at once, just as libbpf does. This leverages the fact that codegen now produces an ELF compliant with libbpf. Required properties of BPF programs (namely program type, expected attach type, and attach target) still need to be fixed manually (as we're not using libbpf-compatible section names), this is now done in BpfBytecode. Verifier log is now kept per-program as the verifier overrides it for every program load. This also means that when the user sets config.log_size to "size", the actual amount of memory allocated is (size * number_of_probes). Thanks to this change, a lot of code could have been dropped: - the entire ELF parsing and BpfBytecode::sections_ (ELF is now directly passed to libbpf and all data is accessed via operations over bpf_object and bpf_program), - custom relocations of BPF programs (now done by libbpf), - custom fixups of BTF data (now done by libbpf). The change also brought some problems: - kfunc probes require libbpf commit dd589c3b31c1 ("libbpf: support "module: Function" syntax for tracing programs") [1]. Since this is not in a released version of libbpf, yet, let's pin Nix to the specific commit and leave a TODO in CMakeLists.txt to require the libbpf version which contains this support (probably 1.5.0). - It broke two builtin calls: debugf and printf for iter probes. For now, disable the corresponding tests and fix them in the following commit. - Since we now call one libbpf function to do a lot of things (load all programs, create all maps, load BTF info, etc.), we have less options to figure out what went wrong in case of a failure. Unfortunately, libbpf doesn't set program/map fds to error codes so it is hard to locate the program which actually failed to load. What we do here is we assume that a program failed to load if the verifier log is non-empty. If all verifier logs are empty, we advice user to check libbpf debugging output to find out more. [1] libbpf/libbpf@dd589c3
BPF helpers that use fmt strings (bpf_trace_printk, bpf_seq_printf) expect the string passed in a data map. Currently, we create that map manually, however libbpf is able to create it internally if an internal global constant string is used in its place. Creating such a constant string allows us to get rid of a good amount of code for maintaining the data map and we now only store the format strings themselves in RequiredResources. Re-enable tests for builtins using such helpers (debugf, printf in iter) which were disabled in the previous commit.
For-loops in multiple probes are now supported without problems b/c libbpf takes care of program relocations. This reverts commit cdf9e9d and re-enables a disabled runtime test for the feature.
If we have a map with key type [string[9], int64], then the int64 should be treated as an unaligned access. Previously the alignment calculations worked off the length of the string value, not the maximum size allocated for the string key. Example: @mapa["ccccdddd", 0] = 1; @mapa["aaaabbb", 0] = 1; The string key's size is taken from the maximum string length, which is 9 bytes. Fields after this key should be considered unaligned. The second line contains a string of 8 bytes. Padding was not taken into account and the following key(s) were incorrectly treated as aligned.
1. Determine which variables need to be shared with the loop callback 2. Pack pointers to them into a context struct 3. Pass pointer to the context struct to the callback function 4. In the callback, override the shared variables so that they read and write through the context pointers instead of directly from their original addresses See the comment in semantic_analyser.cpp for pseudo code of this transformation.
manoj-joseph
force-pushed
the
dlpx/pr/manoj-joseph/68dda4ce-4238-4683-951a-0c0d7cdf9023
branch
from
July 9, 2024 22:45
5425bc3
to
408d238
Compare
LogStream.basic test runs ENABLE_LOG(V1) to test the verbose logging output but forgets to run DISABLE_LOG(V1) afterwards. This causes all subsequent tests (e.g. when running all unit tests) to print verbose error messages which pollute the output. Add the missing line.
Simplify the test cases such that each is only testing the minimal functionality that it needs to. Minimises noise from changing expected results in unrelated patches.
This adds the ability to create const volatile global variables in bpf and allow them to be updated in userspace after program opening but before program loading. This is useful for things like AOT, where we don't know know the number of CPUs on the machine where the bpftrace program will run at the time of codegen.
manoj-joseph
force-pushed
the
dlpx/pr/manoj-joseph/68dda4ce-4238-4683-951a-0c0d7cdf9023
branch
2 times, most recently
from
July 15, 2024 19:40
93e9887
to
fe27d92
Compare
manoj-joseph
force-pushed
the
dlpx/pr/manoj-joseph/68dda4ce-4238-4683-951a-0c0d7cdf9023
branch
2 times, most recently
from
July 15, 2024 19:55
98d0d9f
to
889aa9d
Compare
manoj-joseph
changed the title
Merge branch 'upstreams-develop' into merge
DLPX-91640 bpftrace: Automatic merge failed
Jul 15, 2024
manoj-joseph
force-pushed
the
dlpx/pr/manoj-joseph/68dda4ce-4238-4683-951a-0c0d7cdf9023
branch
from
July 15, 2024 20:03
889aa9d
to
3dc3760
Compare
pcd1193182
approved these changes
Jul 15, 2024
prakashsurya
approved these changes
Jul 15, 2024
jwk404
approved these changes
Jul 15, 2024
manoj-joseph
deleted the
dlpx/pr/manoj-joseph/68dda4ce-4238-4683-951a-0c0d7cdf9023
branch
July 16, 2024 04:35
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
DLPX-91538 a.k.a PR #30 was a bad merge. I reverted it with #34.
Problem
Git still thinks that the upstream changes pulled in by PR 30 are still in. So, I had to redo the merge locally and pulled the changes back in with this commit.
Once that was done, the remaining upstream changes merged without conflict.
Solution
Testing Done
http://ops.jenkins.delphix.com/job/linux-pkg/job/develop/job/build-package/job/bpftrace/job/pre-push/204/console SUCCESS