Table of Contents
How to check Transparent HugePage status if it is enabled or disabled in Linux (RHEL/CentOS 7). Verify the status of Transparent HugePages in Linux. Check if transparent hugepages are enabled. check if transparent hugepages are disabled. Steps to check transparent hugepage status with examples in Linux.
Overview on Transparent HugePage
Transparent Hugepage Support maximizes the usefulness of free memory if compared to the reservation approach of hugetlbfs by allowing all unused memory to be used as cache or other movable (or even unmovable entities). It doesn't require reservation to prevent hugepage allocation failures to be noticeable from userland. It allows paging and all other advanced VM features to be available on the hugepages. It requires no modifications for applications to take advantage of it.
Types of HugePages:
There can be two types of HugePages in the system
- Explicit Huge Pages (nr_hugepages) which are allocated explicitly by
vm.nr_hugepagessysctl parameter i.e. the pages that are used as huge pages are reserved inside the kernel and cannot be used for other purposes.
- Transparent Huge Pages (AnonHugePages) which are allocated automatically by the kernel.
Check Transparent HugePage Status
/proc/meminfo file provides information about the total number of persistent
hugetlb pages in the kernel's huge page pool. It also displays default huge page size and information about the number of free, reserved and surplus huge pages in the pool of huge pages of default size.
# grep -i huge /proc/meminfo AnonHugePages: 264192 kB HugePages_Total: 50226 HugePages_Free: 50226 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB
HugePages_Total is the size of the pool of huge pages and is configured using /proc/sys/vm/nr_hugepages HugePages_Free is the number of huge pages in the pool that are not yet allocated. HugePages_Rsvd is short for "reserved," and is the number of huge pages for which a commitment to allocate from the pool has been made, but no allocation has yet been made. Reserved huge pages guarantee that an application will be able to allocate a huge page from the pool of huge pages at fault time. HugePages_Surp is short for "surplus," and is the number of huge pages in the pool above the value in /proc/sys/vm/nr_hugepages. The maximum number of surplus huge pages is controlled by /proc/sys/vm/nr_overcommit_hugepages. Hugepagesize is the default hugepage size (in Kb).
Check Transparent HugePage status for AnonHugePages
To check Transparent HugePage Status for
AnonHugePages use the below file
# cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never]
"always" means that an application requesting THP will stall on allocation failure and directly reclaim pages and compact memory in an effort to allocate a THP immediately. This may be desirable for virtual machines that benefit heavily from THP use and are willing to delay the VM start to utilise them. "madvise" will enter direct reclaim like "always" but only for regions that are have used madvise(MADV_HUGEPAGE). This is the default behaviour. "never" should be self-explanatory.
Check Transparent HugePage status for nr_hugepages
To check Transparent HugePage status for
- In the below snippets as you see the value of HugePages_Total and nr_hugepages is which means that explicit hugepage is disabled on my system.
- If you see a non-zero value here then it means that the provided amount of memory is reserved in the kernel for explicit transparent hugepage.
# cat /sys/devices/system/node/node*/meminfo | fgrep Huge Node 0 AnonHugePages: 0 kB Node 0 HugePages_Total: 0 Node 0 HugePages_Free: 0 Node 0 HugePages_Surp: 0 # grep -i huge /proc/meminfo AnonHugePages: 174080 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB # sysctl -a | grep nr_hugepages vm.nr_hugepages = 0
Lastly I hope the steps from the article to check transparent hugepage status whether it is enabled or disabled on Linux was helpful. So, let me know your suggestions and feedback using the comment section.