Linux Huge Pages vs Transparent Huge Pages: Benefits, Risks, and Disabling Guide
This article explains the two types of Linux huge pages—static HugeTLB pages and dynamic Transparent Huge Pages—detailing their sizes, performance advantages, drawbacks, especially for Oracle workloads, and provides step‑by‑step instructions for checking status and permanently disabling THP via sysfs or GRUB.
Huge Pages and Transparent Huge Pages
Linux provides two kinds of huge pages: static HugeTLB pages (often called Huge pages) and dynamic Transparent Huge Pages (THP) . The default page size is 4 KB; huge pages use 2 MB or 1 GB blocks, reducing the number of pages the CPU must manage.
HugeTLB Pages
Introduced after kernel 2.6, HugeTLB pages replace the traditional 4 KB pages to support large memory systems. 2 MB pages suit gigabyte‑scale memory, while 1 GB pages are intended for terabyte‑scale memory.
Transparent Huge Pages (THP)
THP was added in RHEL 6 and is enabled by default on recent kernels. It creates an abstraction layer that automatically allocates and manages huge pages, removing the need for manual reservation and code changes. THP aims to improve performance, but it is not recommended for database workloads.
The main difference is that HugeTLB pages are pre‑allocated, whereas THP are allocated on demand.
Benefits of HugeTLB Pages
Larger page size reduces the number of pages the system must handle (512× fewer pages compared with 4 KB pages).
Reduced page‑table walks increase TLB hit probability.
Lower overhead for memory operations and less memory consumption for page tables.
Pages are not swappable, eliminating swap overhead.
Kernel thread kswapd is not involved, saving CPU cycles.
Drawbacks of HugeTLB Pages
Enabling them requires extra configuration, and they conflict with Oracle 11g’s Automatic Memory Management (AMM); however, Automatic Shared Memory Management (ASMM) can still be used.
Issues with Transparent Huge Pages
Oracle recommends disabling THP because it can cause node restarts and performance problems in RAC environments and even on single‑node systems.
How to Disable Transparent Huge Pages
On CentOS 7 (or similar), you can check the current status:
# grep Huge /proc/meminfo
AnonHugePages: 7956480 kB # non‑zero means THP is active
HugePages_Total: 0
HugePages_Free: 0
Hugepagesize: 2048 kBAnd view the kernel settings:
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise neverMethod 1 – Runtime (temporary)
Echo never to the sysfs files:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defragMethod 2 – Persistent (boot‑time)
Make the changes permanent by adding transparent_hugepage=never to the kernel command line.
Edit /etc/default/grub (or /etc/sysconfig/grub) and append the parameter to GRUB_CMDLINE_LINUX.
Regenerate the GRUB configuration and reboot:
# grub2-mkconfig -o /boot/grub2/grub.cfg
# init 6 # rebootAfter reboot, verify that THP is disabled:
# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
# grep Huge /proc/meminfo
AnonHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
Hugepagesize: 2048 kBMonitoring THP
Relevant metrics are available under /sys/kernel/mm/transparent_hugepage/khugepaged, including pages_to_scan (default 4096 ≈ 16 MB), scan_sleep_millisecs (default 10000 ms), and alloc_sleep_millisecs (default 60000 ms).
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
