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
Table of Contents
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 Training: Linux Administration: The Complete Linux Bootcamp in 2025 from Andrei Dumitrescu, Crystal Mind Academy
Disable Transparent Huge Pages
To determine whether Transparent Huge Pages (THP) are currently enabled on your RHEL 8 system, you need to check its status. Transparent Huge Pages dynamically manage memory pages, and their status can impact system performance, especially for database workloads.
Execute the appropriate command in the Linux terminal to display the current state of THP. This will help you identify whether THP is enabled, disabled, or set to “madvise” mode, which allows applications to use it selectively. Understanding the current status is crucial before making any modifications to optimize system performance.
# 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 successfully disabled Transparent Huge Pages (THP) on your Linux operating system. However, it is also necessary to configure the tuned service to optimize your system’s performance further. This ensures that the system is properly tuned according to the hardware and workload requirements, allowing for better resource management and efficiency.
Create a Custom Profile for tuned Service
The tuned service in Linux is a powerful tool used for monitoring and optimizing system performance by adjusting various kernel and system parameters. It helps in fine-tuning the system based on workload characteristics, whether it’s for power-saving, performance improvement, or real-time responsiveness. One of the features it provides is the ability to manage Transparent Huge Pages (THP), allowing you to enable or disable it as needed.
To ensure proper configuration, you must create a custom profile for the tuned service, specifically designed to disable THP. This profile will apply the necessary settings, ensuring that Transparent Huge Pages are turned off, which can help improve performance in certain workloads and prevent issues related to memory management.
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
Linux Basics for Hackers, 2nd Edition
$37.99 (as of February 4, 2025 14:48 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
Disabling Transparent Huge Pages (THP) in RHEL 8 can help improve system performance for certain workloads, especially databases and applications that require finer memory management. By following the steps outlined in this guide, you have successfully disabled THP either temporarily or permanently, depending on your requirements.
After making these changes, it is advisable to monitor system performance to ensure that the adjustment has the desired effect. If necessary, you can revert the changes or fine-tune additional kernel parameters for further optimization. Properly managing memory settings like THP can lead to a more stable and efficient Linux environment.
Searching for a skilled Linux admin? From server management to security, I ensure seamless operations for your Linux systems. Find out more on my Fiverr profile!
FAQs
Here are 5 FAQs with short answers:
1. What is Transparent Huge Pages (THP)?
Answer: THP is a memory management feature in Linux that uses larger memory pages (2MB instead of 4KB) to improve performance by reducing overhead.
2. Why would I disable THP?
Answer: Disabling THP can improve performance for applications that require low latency or manage memory themselves, like databases.
3. How do I disable THP?
Answer: Use the command echo never > /sys/kernel/mm/transparent_hugepage/enabled
or configure the tuned service to disable it permanently.
4. How can I check if THP is enabled?
Answer: Run the command cat /sys/kernel/mm/transparent_hugepage/enabled
to see if THP is enabled, disabled, or madvised.
5. Can THP cause issues?
Answer: Yes, THP can cause performance degradation or memory fragmentation for certain applications, particularly those with custom memory management.
Leave a Reply
You must be logged in to post a comment.