CentLinux | Learn How to Install CentOS/Rocky Linux Servers

Monday, August 23, 2021

How to Disable Transparent Huge Pages in CentOS/RHEL 8

how-to-disable-transparent-huge-pages-in-centos-rhel-8

In this article, you will learn how to disable Transparent Huge Pages in CentOS / RHEL 8.

 

Table of Contents:

 

What are Transparent Huge Pages? :

Transparent Huge Pages (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 Huge Pages 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 Huge Pages on your Linux operating system.

 

Disable Transparent Huge Pages:

Check the current status of Transparent Huge Pages.

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

THP are currently enabled in your Linux operating system.

To disable Transparent Huge Pages, 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 Huge Pages 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 Huge Pages 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 Link:

 

Conclusion:

In this article, you have learned about disabling the Transparent Huge Pages in CentOS / RHEL 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 by Mark Sobell & Matthew Helmke

If you find this article useful? Consider supporting us by Buy Me A Coffee


No comments:

Post a Comment

© 2023 CentLinux. All Rights Reserved.