How to disable Transparent HugePages in Linux 8

Share on Social Media

In this article, you will learn how to disable Transparent HugePages in Linux 8. #centlinux #linux #linuxtips

What are Transparent HugePages? :

Transparent HugePages (THP) is a Linux memory management system that reduces the overhead of Translation Lookaside Buffer (TLB) lookups on machines with large amounts of memory by using larger memory pages.

Transparent HugePages are by default enabled in CentOS / RHEL 8.

Database workloads often perform poorly with THP enabled, because they tend to have sparse rather than contiguous memory access patterns.

Therefore, sometimes it is required that, you should disable Transparent HugePages on your Linux operating system.

Disable Transparent HugePages:

Check the current status of Transparent HugePages.

# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

THP are currently enabled in your Linux operating system.

To disable Transparent HugePages, you have to edit GRUB boot menu. For this purpose, edit the GRUB configuration file in vim text editor.

# vi /etc/default/grub

Locate GRUB_CMDLINE_LINUX and append “transparent_hugepage=never” at the end of that line.

GRUB_CMDLINE_LINUX="resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet transparent_hugepage=never"

Generate new GRUB boot menu based on customized configuration file.

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done

Restart Linux operating system to apply new settings.

# reboot

After restart, check the status of THP again.

# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

You have disabled Transparent HugePages on your Linux operating system. But you are also required to configure tuned service as well.

Create a Custom Profile for tuned Service:

tuned service is used for monitoring and tuning in a Linux system. It can be used to disable or enable THP.

Therefore, you need to create a profile for tuned service and disable the Transparent HugePages in that profile.

Create a directory for new tuned profile.

# mkdir /etc/tuned/no-thp

Create a tuned configuration file.

# vi /etc/tuned/no-thp/tuned.conf

Add following lines in that file.

[main]
include=virtual-guest

[vm]
transparent_hugepages=never

Enable the no-thp profile by using following command.

# tuned-adm profile no-thp

Video to Disable Transparent HugePages:

YouTube player

Conclusion:

In this article, you have learned how to disable Transparent HugePages in Linux 8. If this information is too much technical for you, then you should buy and read Practical Guide to Linux Commands, Editors, and Shell Programming (PAID LINK) by Mark Sobell & Matthew Helmke

Scroll to Top