How to disable Transparent Huge Pages in RHEL 8

Share on Social Media

Learn how to disable Transparent Huge Pages in RHEL 8 with our step-by-step guide. Optimize your system performance by following our instructions to turn off Transparent Huge Pages safely and effectively. #centlinux #linux #linuxtips

What are Transparent Huge Pages?

Transparent Huge Pages (THP) are a feature in the Linux kernel that aims to improve system performance by using larger memory pages, known as huge pages or large pages. These larger page sizes can reduce the overhead associated with managing memory pages, leading to improved performance, especially for memory-intensive workloads like databases.

Key points about Transparent Huge Pages (THP):

  • Memory Pages:
  • In computer memory management, memory is divided into fixed-size pages, typically 4 KB in size. These pages are the basic unit of memory allocation and management in the operating system.
  • Huge Pages:
  • Huge pages are memory pages that are larger than the standard page size. In Linux, huge pages can be 2 MB or 1 GB in size, compared to the standard 4 KB pages.
  • Transparent Huge Pages (THP):
  • THP is a kernel feature that allows the operating system to automatically manage the allocation and use of huge pages transparently to user-space applications.
  • THP dynamically allocates and manages huge pages based on system workload and memory usage patterns without requiring any changes to application code.
  • Performance Benefits:
  • Using larger pages can reduce the number of page table entries, TLB misses, and memory management overhead, leading to improved performance, especially for memory-intensive applications.
  • THP can benefit workloads such as databases, virtualization, and in-memory computing.
  • Configuration:
  • THP is enabled by default in many Linux distributions, including RHEL (Red Hat Enterprise Linux).
  • However, it can be controlled and configured using kernel parameters and system settings.
  • Considerations:
  • While THP can improve performance for some workloads, it may not provide significant benefits for all applications.
  • In some cases, THP may introduce latency or fragmentation issues, especially for certain database workloads.

In summary, Transparent Huge Pages (THP) are a kernel feature in Linux that leverages larger memory pages to improve system performance, especially for memory-intensive workloads. However, their effectiveness can vary depending on the workload and system configuration.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

745772 0021

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

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

Final Thoughts

Disabling Transparent Huge Pages (THP) in RHEL 8 can be a critical step in optimizing system performance for certain workloads. By following our guide, you can safely and effectively disable THP to fine-tune your system for better performance. If you need personalized assistance or encounter any challenges during the process, I offer professional services on Fiverr. Check out my Fiverr gig for expert help with optimizing your RHEL 8 system and other Linux-related tasks.

Leave a Comment