On your Linux system, you want to check whether transparent hugepages are enabled on your system.
- cat /sys/kernel/mm/transparent_hugepage/enabled
You will get an output like this:
- [always] madvise never
You’ll see a list of all possible options (
never ), with the currently active option being enclosed in brackets.
madvise is the default.
This means transparent hugepages are only enabled for memory regions that explicitly request hugepages using madvise(2).
always means transparent hugepages are always enabled for each process. This usually increases performance, but if you have a usecase with many processes that only consume a small amount of memory each, your overall memory usage could grow drastically.
never means transparent hugepages won’t be enabled even if requested using
For details, take a look at Documentation/vm/transhuge.txt in the Linux kernel documentation.
How to change the default value
Option 1: Modify sysfs directly (the setting is reverted back to default upon reboot):
- echo always >/sys/kernel/mm/transparent_hugepage/enabled
- echo madvise >/sys/kernel/mm/transparent_hugepage/enabled
- echo never >/sys/kernel/mm/transparent_hugepage/enabled
Option 2: Change system default by recompiling kernel with modified config (this is only recommended if you’re using your own custom kernel anyway):
In order to set default to always, set these options:
- # Comment out CONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y
In order to set default to
madvise, set these options:
- # Comment out CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y