Skip to content

scripts: Exclude Rust compilation units with pahole #872

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

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

YakoYakoYokuYoku
Copy link

Version 1.24 of pahole has the capability to exclude compilation units (CUs) of specific languages with the --lang_exclude option.
Rust, as of writing, is not currently supported by pahole neither BTF and if it's used with a build that has DEBUG_INFO_BTF_MODULES enabled it results in erroneous binaries. So it's better for pahole to exclude Rust compilation units until support for it arrives.

Fixes #735.

@YakoYakoYokuYoku YakoYakoYokuYoku force-pushed the pahole-exclude-rust branch 2 times, most recently from 225d812 to 82a9615 Compare August 23, 2022 12:25
@YakoYakoYokuYoku YakoYakoYokuYoku requested a review from ojeda August 23, 2022 12:28
@YakoYakoYokuYoku
Copy link
Author

To test this change (as of 459035a) the flag --skip_encoding_btf_enum64 needs to be passed in scripts/pahole-flags.sh, though this change might not be necessary here as it's gonna land in upstream probably.

@ojeda
Copy link
Member

ojeda commented Sep 22, 2022

To test this change (as of 459035a) the flag --skip_encoding_btf_enum64 needs to be passed in scripts/pahole-flags.sh, though this change might not be necessary here as it's gonna land in upstream probably.

Sorry, I got this swapped out from my brain -- could you please expand a bit on why the flag is needed for testing?

The PR otherwise looks good to me, though this probably should go through the BPF tree after the Rust merge. Did you mean that by "gonna land in upstream probably"?

@YakoYakoYokuYoku
Copy link
Author

Sorry, I got this swapped out from my brain -- could you please expand a bit on why the flag is needed for testing?

The PR otherwise looks good to me, though this probably should go through the BPF tree after the Rust merge. Did you mean that by "gonna land in upstream probably"?

There was an issue related to 64 bit enums with the stable branches of the kernel. Though it's solved for both stable and 6.0+ because with the former they've added --skip_encoding_btf_enum64 to scripts/pahole-flags.sh to avoid the encoding and the latter supports those kinds of enums. In resumi, upstream issues had been fixed and there are no blockers for this.

@YakoYakoYokuYoku
Copy link
Author

@ojeda I think this is now ready for inclusion.

@ericcurtin
Copy link

We really need this upstream if this does fix the bpf issue with Rust for Linux, is CONFIG_MODULE_ALLOW_BTF_MISMATCH=y required also or no?

@ericcurtin
Copy link

ericcurtin commented Dec 20, 2022

I can confirm this worked great for me, to get BPF back working with the Rust-based GPU driver on our Fedora Asahi kernel for the non-Rust parts:

https://gitlab.com/fedora-asahi/kernel-asahi/-/commit/cb4241a09a5eeb51d07455df2ca8a1a882990c6f

So...

Reviewed-by: Eric Curtin <ecurtin@redhat.com>
Tested-by: Eric Curtin <ecurtin@redhat.com>

@ericcurtin
Copy link

@marcan

@YakoYakoYokuYoku YakoYakoYokuYoku force-pushed the pahole-exclude-rust branch 2 times, most recently from 84305dc to b978938 Compare December 20, 2022 12:04
@YakoYakoYokuYoku
Copy link
Author

We really need this upstream if this does fix the bpf issue with Rust for Linux, is CONFIG_MODULE_ALLOW_BTF_MISMATCH=y required also or no?

I don't think so as CONFIG_PAHOLE_HAS_LANG_EXCLUDE=y already suffices the condition of having --lang_exclude=rust.

Also I've added those tags in the commit message to credit you, @ericcurtin, so thanks to you too for testing this PR.

@ericcurtin
Copy link

We really need this upstream if this does fix the bpf issue with Rust for Linux, is CONFIG_MODULE_ALLOW_BTF_MISMATCH=y required also or no?

I don't think so as CONFIG_PAHOLE_HAS_LANG_EXCLUDE=y already suffices the condition of having --lang_exclude=rust.

Also I've added those tags in the commit message to credit you, @ericcurtin, so thanks to you too for testing this PR.

Yup you are right, tested without it, works great!

@Conan-Kudo
Copy link

Verified as well:

Reviewed-by: Neal Gompa <neal@gompa.dev>
Tested-by: Neal Gompa <neal@gompa.dev>

@YakoYakoYokuYoku
Copy link
Author

You were added too, @Conan-Kudo.

@ojeda
Copy link
Member

ojeda commented Dec 20, 2022

Thanks everyone! The tags are very useful.

@YakoYakoYokuYoku For upstream, could you please submit the patch? If so, please Cc the BPF list & maintainers and probably the pahole one (@acmel) too, as well as the Rust for Linux list.

@YakoYakoYokuYoku
Copy link
Author

There it goes, though I've fooled up and the message was sent twice. If I recall fixes should be sent upstream directly, right?

@ojeda
Copy link
Member

ojeda commented Dec 20, 2022

There it goes, though I've fooled up and the message was sent twice.

Thanks, and no worries :)

If I recall fixes should be sent upstream directly, right?

At this point, as soon as something has all its dependencies already in mainline, it can be sent.

@YakoYakoYokuYoku
Copy link
Author

v2 at LKML.

@YakoYakoYokuYoku
Copy link
Author

v3 at LKML.

Version 1.24 of pahole has the capability to exclude compilation units
(CUs) of specific languages [1] [2]. Rust, as of writing, is not
currently supported by pahole and if it's used with a build that has
BTF debugging enabled it results in malformed kernel and module
binaries [3]. So it's better for pahole to exclude Rust CUs until
support for it arrives.

Link: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=49358dfe2aaae4e90b072332c3e324019826783f [1]
Link: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=8ee363790b7437283c53090a85a9fec2f0b0fbc4 [2]
Link: Rust-for-Linux#735 [3]

Co-developed-by: Eric Curtin <ecurtin@redhat.com>
Signed-off-by: Eric Curtin <ecurtin@redhat.com>
Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
@YakoYakoYokuYoku
Copy link
Author

@ojeda, can you merge this? This was accepted for bpf-next so this can be included unless we wait for it to be in torvalds and pulled from there.

@ojeda
Copy link
Member

ojeda commented Jan 20, 2023

Sure (in any case, please note that the rust branch will eventually go away when we get it close to upstream)

@ojeda ojeda merged commit 3dfc5eb into Rust-for-Linux:rust Jan 20, 2023
@YakoYakoYokuYoku YakoYakoYokuYoku deleted the pahole-exclude-rust branch January 23, 2023 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Module loading fails with DEBUG_INFO_BTF_MODULES
4 participants