Skip to content

Instantly share code, notes, and snippets.

@cherts
Last active February 14, 2023 16:08
Show Gist options
  • Select an option

  • Save cherts/be1e7551cca7b873a73b697e3fa951e4 to your computer and use it in GitHub Desktop.

Select an option

Save cherts/be1e7551cca7b873a73b697e3fa951e4 to your computer and use it in GitHub Desktop.
Disable transparent huge page via systemd in Ubuntu/Debian
[Unit]
Description=Disable Transparent Huge Pages
Documentation=https://access.redhat.com/solutions/46111
[Service]
Type=oneshot
ExecStart=/bin/sh -c "/usr/bin/echo "never" | tee /sys/kernel/mm/transparent_hugepage/enabled"
ExecStart=/bin/sh -c "/usr/bin/echo "never" | tee /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
@cherts

cherts commented Feb 14, 2023

Copy link
Copy Markdown
Author
wget https://gist.githubusercontent.com/CHERTS/be1e7551cca7b873a73b697e3fa951e4/raw/disable-transparent-huge-pages.service -O  /etc/systemd/system/disable-transparent-huge-pages.service
systemctl daemon-reload
systemctl enable disable-transparent-huge-pages --now

@cherts

cherts commented Feb 14, 2023

Copy link
Copy Markdown
Author

Check THP usage:

grep AnonHugePages /proc/meminfo 
egrep 'trans|thp' /proc/vmstat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment