Disabling Transparent Huge Pages in CentOS 7.x

Disabling Transparent Huge Pages in CentOS 7.x

Transparent Huge Pages(THP) have been introduced since RedHat/CentOS 6. In CentOS 7,this feature has been turned on by default. Even THP is supposed to increased to memory performance, various database vendors(Oracle,MariaDB) are recommending to turn off THP. It seems to cause performance degradation when THP is enabled.

To verify if THP is enabled.

# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

Edit the rc.local file

Add the following to the bottom of /etc/rc.d/rc.local

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi

Make rc.local file executable

chmod u+x /etc/rc.d/rc.local

Reboot

# init 6

To verfiy if THP is disabled.

# cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

Regards,
Wei Shan

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s