I want to disable transparent_hugepage (THP) on a CentOS 7 EC2 instance, which is enabled by default:
# cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never # cat /sys/kernel/mm/transparent_hugepage/defrag [always] madvise never
This setting can be manually changed:
# echo never > /sys/kernel/mm/transparent_hugepage/enabled # echo never > /sys/kernel/mm/transparent_hugepage/defrag # cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never] # cat /sys/kernel/mm/transparent_hugepage/defrag always madvise [never]
… but the changes are lost after reboot.
I tried to put the
echo never [...] instruction into my
cloud.cfg files, but it didn’t work.
I also tried to append the setting
transparent_hugepage=never to the kernel line of
/etc/grub.conf (as explained there), but it didn’t work better.
So… how can I disable THP on CentOS 7 running on an AWS EC2 instance ?
edit: changed title… I need to disable THP and THP defrag
In addition to setting the grub command line, you also need to configure tuned. But not using the instructions you linked to, as they are so full of errors it would take half a day just to explain them all.
Create a custom tuned profile (which I’ll call
custom), and then set the profile. You will base it on an existing profile, such as
virtual-guest if you are running in a virtual machine (EC2 is, of course), or
throughput-performance if you are on a physical machine.
Create the directory to hold the custom profile:
Create the custom profile
/etc/tuned/custom/tuned.conf, for example:
[main] include=virtual-guest [vm] transparent_hugepages=never
Now set the profile:
tuned-adm profile custom
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.