Skip to content
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

linux: disable DEBUG_INFO_BTF by default #141284

Closed
wants to merge 1 commit into from

Conversation

Atemu
Copy link
Member

@Atemu Atemu commented Oct 11, 2021

Motivation for this change

linux: disable DEBUG_INFO_BTF by default

It made the ZFS module balloon in size and probably shouldn't be enabled on
production kernels to begin with.

Fixes #140851

Merge this so that it ends up in the same eval as #141112 to avoid unnecessary rebuilds.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

It made the ZFS module balloon in size and probably shouldn't be enabled on
production kernels to begin with.

Fixes NixOS#140851
@lovesegfault
Copy link
Member

@Atemu I think this should contain some study of prior art. What do other distros do here? E.g. Gentoo (check the distkernels), Arch, Debian, OpenSUSE.

@Mic92
Copy link
Member

Mic92 commented Oct 11, 2021

Afaik NixOS would be the only one not to enable BTF. Ubuntu, arch and fedora have it. Have not checked the other.

@Mic92
Copy link
Member

Mic92 commented Oct 11, 2021

Also what is the size increase afterwards? Also ZFS is used on systems with a lot of storage, so a few mb won't really matter.

@markpash
Copy link
Contributor

BTF should be kept IMO, but there's probably some other configs that we've forgotten to set which could reduce the size, maybe we could test them out before disabling BTF? Keeping BTF by default is the way to go, it's not a "debug only" feature.

@Artturin
Copy link
Member

@markpash
Copy link
Contributor

Some quick googling took me to this patch series that demonstrates some Kconfig that reduces overall sizes when using BTF. We should experiment with them. https://patches.linaro.org/patch/318424/

@Atemu
Copy link
Member Author

Atemu commented Oct 11, 2021

I wouldn't care about MiBs on my main partition but, on my 512MiB boot partition, I'm a bit stingy about 9MiB extra in every initrd.

By disabling BTF, initrd size is back to normal AFAICT.

I would absolutely not mind having this feature enabled by default if the other distros do so aswell. My main issue is that it bloats every ZFS user's /boot/ by multiple MiB unnecessarily.

@Mic92
Copy link
Member

Mic92 commented Oct 11, 2021

Maybe we should ask zfs upstream why btf blows up their module.

@Atemu
Copy link
Member Author

Atemu commented Oct 11, 2021

I'd prefer if we disabled it for the time being though.

@Mic92
Copy link
Member

Mic92 commented Oct 11, 2021

I wonder if we can strip it somehow from the zfs module without breaking it.

@Mic92
Copy link
Member

Mic92 commented Oct 11, 2021

Opened up openzfs/zfs#12635

@markpash
Copy link
Contributor

Yeah, I think it's worth using this PR as an opportunity to figure this out rather than blanket disabling again and breaking applications and workflows. Does every module balloon in size or just ZFS?

What happens if we disable CONFIG_DEBUG_INFO_BTF_MODULES?

@Mic92
Copy link
Member

Mic92 commented Oct 11, 2021

It looks like the zfs module also contains debug_info i.e. debug symbols now. Is this a change from what we had before?

@Artturin
Copy link
Member

Artturin commented Oct 11, 2021

nix build nixpkgs/cf887eb36fb74d8d440ffdf4a8f35dd8e866826b#linuxPackages.zfs a commit before the enabling of btf (if i did it correctly)

edit: for some reason it still gives me a 15M result but checking out that commit i get a 3M

@Artturin
Copy link
Member

pre-btf

13K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/nix-support
76K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/linux
270K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/spl/sys
13K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/spl/rpc
291K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/spl
13K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys/zstd
35K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys/lua
18K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys/sysevent
13K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys/fm/fs
31K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys/fm
25K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys/fs
26K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys/crypto
1,1M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include/sys
1,5M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/include
35K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0/5.10.57
1,6M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/zfs-2.1.0
11K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src/spl-2.1.0
1,6M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/src
885K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/zfs
77K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/lua
193K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/zstd
33K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/nvpair
109K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/icp
13K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/avl
37K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/zcommon
41K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/unicode
45K	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra/spl
1,5M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57/extra
1,5M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules/5.10.57
1,5M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib/modules
1,5M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57/lib
3,0M	/nix/store/giy9jijzi958j6qh3l2mly3z7ahyf2dj-zfs-kernel-2.1.0-5.10.57
3,0M	total

post-btf

11K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/spl-2.1.1
35K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/5.10.71
13K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys/fm/fs
31K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys/fm
13K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys/zstd
25K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys/fs
18K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys/sysevent
35K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys/lua
26K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys/crypto
1,1M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/sys
13K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/spl/rpc
270K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/spl/sys
291K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/spl
76K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include/linux
1,5M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1/include
1,6M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src/zfs-2.1.1
1,6M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/src
529K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/spl
325K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/zcommon
129K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/nvpair
1,3M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/zstd
9,4M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/zfs
409K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/lua
37K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/avl
1,2M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/icp
81K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra/unicode
14M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71/extra
14M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules/5.10.71
14M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib/modules
14M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/lib
13K	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71/nix-support
15M	/nix/store/c0fxk7s08n5lmyxqgq0q722pvvyw55sb-zfs-kernel-2.1.1-5.10.71
15M	total

@Atemu
Copy link
Member Author

Atemu commented Oct 12, 2021

CONFIG_DEBUG_INFO_BTF_MODULES

That doesn't seem to be a valid option.

@Mic92
Copy link
Member

Mic92 commented Oct 12, 2021

CONFIG_DEBUG_INFO_BTF_MODULES

You need to drop the CONFIG_ prefix. We have this option enabled:

$ zgrep CONFIG_DEBUG_INFO_BTF_MODULES /proc/config.gz
CONFIG_DEBUG_INFO_BTF_MODULES=y

@Atemu
Copy link
Member Author

Atemu commented Oct 12, 2021

You can try it yourself, it's not an option we can set.

@Mic92
Copy link
Member

Mic92 commented Oct 12, 2021

You can try it yourself, it's not an option we can set.

I took this from my current nixos kernel:

$ uname -a
Linux turingmachine 5.14.8-zen1 #1-NixOS ZEN SMP Tue Jan 1 00:00:00 UTC 1980 x86_64 GNU/Linux

Is it possible that this option is only available in _latest?

@Atemu
Copy link
Member Author

Atemu commented Oct 12, 2021

I don't mean the resulting config.gz, I mean the options we are able to set in common-config.nix. I tried setting it in 5.10 and 5.14.

@nagisa
Copy link
Contributor

nagisa commented Oct 16, 2021

One other consequence of DEBUG_INFO_BTF is that it is impossible to build a kernel on systems with full 16G of /tmp available now. I vote for landing this.

@roblabla
Copy link
Contributor

roblabla commented Oct 16, 2021

NixOS would then be one of the only distros to not support BTF, which would make using and packaging bpf-based tools really annoying (especially as the ecosystem is moving further towards BPF CO-RE, which requires btf), as it'd require the users to do their own kernel builds instead of relying on the kernel in the nix binary cache. On the other hand, if you're doing a local build of the kernel, you can trivially turn the option off in your own configuration.nix.

@nagisa
Copy link
Contributor

nagisa commented Oct 17, 2021

trivially turn the option off in your own configuration.nix

While the process of turning the option off is fairly straightforward, figuring out what to turn off when starting with "zfs module is too large to fit into my /boot" or "why is building kernel requiring so much memory/disk space" is not. If there's a good way to inform the user they might want to turn this specific option off, then I'm comfortable with leaving this in for the prebuilt builds.

if you're doing a local build of the kernel

Local builds don't necessarily happen because of changes to the derivation. Testing changes to nixpkgs or using channels for which hydra hasn't cached the build for whatever reason are both also perfectly valid use-cases.

@roblabla
Copy link
Contributor

roblabla commented Oct 17, 2021

Also, specifically for the ZFS problem, we should probably experiment with setting DEBUG_INFO_BTF_MODULES = false on kernels 5.11+. I believe most eBPF use-cases would be supported in this mode, and it may avoid generating large ZFS modules until they fix the bug on their end. Unfortunately, the flag doesn't exist on previous versions of the kernel, and the default kernel packaged in NixOS is 5.10 😞...

EDIT: Actually, the flag doesn't exist on previous versions because module BTF support doesn't exist in 5.10 and below. Given that large zfs also happens on 5.10, I guess the flag wouldn't actually help.

@Mic92
Copy link
Member

Mic92 commented Oct 17, 2021

Stripping debug symbols seems to solve the size issue without having to disable btf: #141942

@Atemu
Copy link
Member Author

Atemu commented Oct 17, 2021

One other consequence of DEBUG_INFO_BTF is that it is impossible to build a kernel on systems with full 16G of /tmp available now. I vote for landing this.

The builddir of kernel I just built does indeed take ~19GiB apparent and ~10GiB lz4'd which is quite a lot.

You can just put that in /var/tmp instead though, or, since you're compiling your own kernel anyways, set btf=no.

@Atemu Atemu closed this Oct 17, 2021
@Atemu Atemu deleted the linux-disable-btf branch November 26, 2023 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZFS kernel modules have ballooned in size
7 participants