How to Check Transparent HugePages( THP) Enabled Or Not in RHEL 6 and 7 ?

1)Check “/sys/kernel/mm/redhat_transparent_hugepage/enabled”.

always   -  always use THP
never    -  disable THP

if it is set as “always”, then khugepaged will be automatically started.

$ ps -eaf | grep khugepaged
root 188 2 0 Feb05 ? 00:04:37 [khugepaged]

2) Check /proc/meminfo.

If THP is enabled :

$ grep AnonHugePages /proc/meminfo
AnonHugePages: 8450048 kB

If THP is disabled:

$ grep AnonHugePages /proc/meminfo
AnonHugePages: 0 kB

3) for RHEL 6.2 and later, check /proc/vmstat:

If THP is enabled:

$ egrep 'trans|thp' /proc/vmstat
nr_anon_transparent_hugepages 4127
thp_fault_alloc 12446176
thp_fault_fallback 7205480
thp_collapse_alloc 27143
thp_collapse_alloc_failed 14815
thp_split 310753
thp_zero_page_alloc 16
thp_zero_page_alloc_failed 0

If THP is disabled:

$ egrep 'trans|thp' /proc/vmstat
nr_anon_transparent_hugepages 0
thp_fault_alloc 0
thp_fault_fallback 0
thp_collapse_alloc 0
thp_collapse_alloc_failed 0
thp_split 0
thp_zero_page_alloc 0
thp_zero_page_alloc_failed 0

4) Check THP usage per process:

$ grep -e AnonHugePages /proc/*/smaps | awk '{ if($2>4) print $0} ' | awk -F "/" '{print $0; system("ps -fp " $3)} '

/proc/64068/smaps:AnonHugePages: 2048 kB
UID PID PPID C STIME TTY TIME CMD
oracle 64068 1 0 Feb10 ? 01:50:36 ora_diag_RACNODE1
/proc/64085/smaps:AnonHugePages: 4096 kB
UID PID PPID C STIME TTY TIME CMD
oracle 64085 1 0 Feb10 ? 16:39:31 ora_dia0_RACNODE2
/proc/64085/smaps:AnonHugePages: 6144 kB
...
..
.