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

jemalloc: disable transparent hugepages by default on ARMv6/7 #33260

Merged
merged 3 commits into from Jan 2, 2018

Conversation

lopsided98
Copy link
Contributor

@lopsided98 lopsided98 commented Jan 1, 2018

Motivation for this change

This PR disables transparent hugepage support in jemalloc by default on ARMv6/7 (adding a parameter that allows it to be enabled if desired). The NixOS ARMv6/7 kernels do not enable transparent hugepage support, but jemalloc is not able to detect this (see jemalloc/jemalloc#526).

Even though the --disable-thp flag is available in jemalloc 4.5.0, it does not work correctly in this version, so this PR also updates jemalloc to 5.0.1 (which requires a large rebuild with the possibility of breakage).

Alternatively, this problem could be solved by enabling THP in the default kernel config, but it still might be good to have an option to disable it in jemalloc.

Also, is stdenv.system the correct way to do platform detection nowadays (with the upcoming better cross compiling support)?

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@dezgeg
Copy link
Contributor

dezgeg commented Jan 1, 2018

I think enabling THP on 32-bit ARM is not possible by default, given that it depends on LPAE (and if LPAE is enabled, the kernel won't run on CPUs that lack it):

1692 config HAVE_ARCH_TRANSPARENT_HUGEPAGE
1693        def_bool y
1694        depends on ARM_LPAE

# jemalloc is unable to correctly detect transparent hugepage support on
# ARM, and the default kernel ARMv6/7 kernel does not enable it, so we
# explicitly disable support
thpSupport ? stdenv.system != "armv7l-linux" &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use: stdenv.isArm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add a link to jemalloc/jemalloc#526 in the comments, so we know when we can strip this.

The default NixOS kernels for ARMv7 (and probably ARMv6) do not have support
for transparent huge pages, but jemalloc is unable to detect this. This is a
known bug and the current solution is to pass --disable-thp to ./configure.
# jemalloc is unable to correctly detect transparent hugepage support on
# ARM (https://github.com/jemalloc/jemalloc/issues/526), and the default
# kernel ARMv6/7 kernel does not enable it, so we explicitly disable support
thpSupport ? !stdenv.isArm }:
Copy link
Member

@Mic92 Mic92 Jan 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not expose this as an option.

The only common use case so far seems ARMv6/ARMv7 support.
The way this option is exposed might collide with a package with the
same name. Also the option naming on its own is not self-descriptive
without context.
@Mic92 Mic92 merged commit e9d5c55 into NixOS:master Jan 2, 2018
@lopsided98 lopsided98 deleted the jemalloc-thp branch January 6, 2018 04:15
kierdavis added a commit to kierdavis/config that referenced this pull request Feb 17, 2018
This overlays NixOS/nixpkgs#33260 on top of
the current release channel.
kierdavis added a commit to kierdavis/config that referenced this pull request Sep 27, 2022
This overlays NixOS/nixpkgs#33260 on top of
the current release channel.
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.

None yet

5 participants