Parameters Used to Configure Transparent HugePages

The following table describes selected parameter settings that can be used when configuring Transparent HugePages (THP).

Table 3-1 Commonly Used THP Parameters

Parameter File Location Value Options
enabled /sys/kernel/mm/transparent_hugepage/enabled Sets THP and its mode, which is one of the following:
  • always (default): THP is enabled in system-wide mode.

    In this setting, the kernel, whenever possible, assigns huge pages to processes using large contiguous virtual memory areas.

  • madvise: THP is enabled in per-process mode.

    In this setting the kernel only assigns huge pages to application processes that explicitly request huge pages through the madvise()system call.

  • disabled: THP is disabled.
defrag /sys/kernel/mm/transparent_hugepage/defrag
Determines how aggressively an application can reclaim pages and defrag memory when THP is unavailable. The following list explains the available options:
  • always: An application requesting THP stalls on allocation failure and directly reclaims pages and compact memory to obtain a THP immediately.

  • defer: An application doesn't stall but continues using small pages. The application requests the kernel daemons kswapd and kcompactd to reclaim pages and compact memory so that THP is available later.
  • defer+madvise:

    Regions using the madvise(MADV_HUGEPAGE) call stall on allocation failure and directly reclaim pages and compact memory to obtain a THP immediately

    However, all other regions request the kernel daemons kswapd and kcompactd to reclaim pages and compact memory so that THP is available later.

  • madvise (default): Regions using the madvise(MADV_HUGEPAGE) call stall on allocation failure and directly reclaim pages and compact memory to obtain a THP immediately.