Oracle Linux: How To Disable Transparent HugePages On Oracle Linux 7 (Doc ID 2336923.1)
APPLIES TO:
Linux OS - Version Oracle Linux 7.3 with Unbreakable Enterprise Kerne [4.1.12] and later
Information in this document applies to any platform.
GOAL
Disable the transparent hugepages (THP) feature to improve system stability and performance.
禁用透明hugepages(THP)功能以提高系统稳定性和性能。
SOLUTION
To keep THP disabled across a reboot, Please perform any one of the following action plans 要在重新启动期间禁用THP,请执行以下任何一项行动计划
Use a systemd(1) service to disable transparent hugepages
1. Create the systemd(1) service definition file /etc/systemd/system/disable-thp.service similar to this:
创建类似于以下内容的systemd(1)服务定义文件/etc/systemd/system/disable-thp.service:
[Unit]
Description=Disable Transparent Huge Pages (THP)
[Service]
Type=simple
ExecStart=/bin/sh -c "echo 'never' >/sys/kernel/mm/transparent_hugepage/enabled && echo 'never' >/sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
2. Enable the new service to run automatically: 启用新服务以自动运行
# systemctl daemon-reload
# systemctl start disable-thp
# systemctl enable disable-thp
# systemctl status disable-htp
Disable transparent hugepages via the Linux kernel command line 通过Linux内核命令行禁用透明的hugepages
1. Add the clause "transparent_hugepages=never" to the GRUB_CMDLINE_LINUX entry of /etc/default/grub, like this:
1. 将子句"transparent_hugepages=never"添加到/etc/default/grub的GRUB_CMDLINE_LINUX条目中,如下所示:
# /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="elevator=deadline audit=1 crashkernel=auto rd.lvm.lv=rootvg/rootlv rd.lvm.lv=rootvg/swaplv rd.lvm.lv=rootvg/usrlv transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"
2. Backup the GRUB configuration file and generate a new file to incorporate the change:
2. 备份GRUB配置文件并生成一个新文件以合并更改:
# cp -pv /boot/grub2/grub.cfg /boot/grub2/grub.cfg-bkp
# grub2-mkconfig -o /boot/grub2/grub.cfg
3. Reboot the server to activate the change. 重新启动服务器以激活更改。
# reboot
4. Verify the correction is persistent: 验证
# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
REFERENCES
NOTE:2279458.1 - Transparent Hugepage is not getting disabled
NOTE:1500235.1 - How To Collect an Sosreport on Oracle Linux