-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix bpftrace for older kernels: Fallback to no func_infos, no BTF #3149
Fix bpftrace for older kernels: Fallback to no func_infos, no BTF #3149
Conversation
I think to think more deeply about edge cases here, but on the surface this seems reasonable in isolation. However, I think @viktormalik is/has been working a lot on the libbpf migration. If it's on-track to land this release cycle, then it'd probably be better to wait for that (given this PR or the libbpf migration will ship at the same time). Viktor, can you comment? |
Yes, I've a working implementation now and will start posting PRs. It's a lot of code so I'll need to split it into multiple parts. See #2334 for a preliminary plan of updates. I'm not sure if it's a good idea to land this in this release cycle, though. Since it's quite a disruptive change, I'd prefer having it in unreleased state to have as many people use it in their workflows as possible. On top of that, we haven't done a release in a while and already have a nice set of unreleased features, so maybe let's do a release soon and plan this for the next one? |
Thanks @viktormalik for the insight and sharing your plans for having it in unreleased state to have as many people use it in their workflows as possible and rather do a release, already having a nice set of unreleased features without your big disruptive change soon. That would fall right in line with my use case: I'd like to first integrate a stable release of Also, having Please see this just as a user of bpftrace sharing his use case, not more! I'm merely asking for a decision to be made in order to make my plans for using a branch or fork in 0.19.1 or work directly on upstream master regarding me and my users. (@ajor) @giorio94 reacted with (heart) to this PR to fix #3011, so I guess it would be very welcome for him too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it would generally be useful to have a support for the 4.19 stable kernel in master (and the next release). Then, when we switch to libbpf-based loading which should (theoretically) be backwards compatible, we'll have a baseline to compare with.
The PR itself LGTM, just a few comments below.
Also, we historically used the loading "attempts" for older kernels which required the kernel version (and we had 3 different ways of getting it). I'm wondering if this change could potentially conflict with that.
4567cfd
to
fdb9ff6
Compare
Thanks @viktormalik!
Thanks for the hint! I did not know, and I overlooked that! Yes, I fixed that issue with this push!
Yes, I hadn't added the outer loop yet, but I added it now. Done!
Yes, that makes total sense! Done now on top of the new outer loop! |
fdb9ff6
to
6a75b86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, just a couple of comments below.
6a75b86
to
565e3b0
Compare
565e3b0
to
102d9a7
Compare
Thanks, applied the changes. |
src/attached_probe.cpp
Outdated
<< "bpf_prog_load() failed with error " << progfd_ << ": " | ||
<< std::strerror(-progfd_) << std::endl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary now when the same is printed for each failed attempt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, correct, that is no longer necessary as it is already logged for each failed attempt!
Removed them! - I backed out these two lines from the commit!
This push removes the hunk that added these two lines, no other changes in this push.
102d9a7
to
8339468
Compare
8339468
to
f87cda2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Let's wait for #3166 to land and rebase on top of that to make sure that the tests pass.
Also handle the case where EM_BPF may not be defined on older systems. Co-authored-by: Viktor Malik <[email protected]> Signed-off-by: Bernhard Kaindl <[email protected]>
f87cda2
to
7516d31
Compare
BTW: GitHub implicitly re-bases the PR git checkout for the CI builds onto the target branch automatically. That is the reason why all PRs broke when master broke CI. |
@viktormalik, as https://github.com/bpftrace/bpftrace/releases/tag/v0.20.4 is released, and you assigned v0.21.0 as milestone, and you reviewed it, what is the next milestone to merge this PR? |
@bernhardkaindl I want to get this merged asap, to get it into the upcoming 0.21 release. Just waiting for a review from @danobi. |
Fix #3011:
In #2913 (comment), @viktormalik said:
He detailed the problem in #2913 (comment):
He implemented an initial interim fix in #2934 (as loaded via bpf_object) might be a bigger change, but #3011 shows that this is not enough. In it, @giorio94 bisected that #2804 causes
bpftrace
to fail on all kernels that do not support the types that LLVM now generates. And func_infos fail with 4.19 fail too.I now found that the issue is that current code skips loading the BPF program when loading the BTF into the kernel failed:
bpftrace/src/attached_probe.cpp
Line 831 in c8fd334
But there is no such fall back to handle this error yet, so add it. And, I found:
These changes fix bpftrace to work on 4.19 again.
I plan also submit my BTF fixup changes to fix BTF load on 4.19, they add converting the kinds FUNC, FUNC_PROTO, VAR, and DATASEC. But as said, these only fix BTF load but passing the btf_fd for the loaded BTF still makes the BPF load fail on 4.19.
For now, this is the smallest change and only adds fallbacks for older kernels, that have issues with BTF and func_infos so it does not affect newer kernels at all.
Of course, the best solution is to load everything by using libbpf as bpf_object, but that is a bigger change.
And, I'd also like showing the error code and error message when BPF load fails (added as well).