rhel7.2 禁用透明的大页内存--transparent_hugepage(TPH)
[root@rac1 tmp]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
[root@rac1 tmp]# uname -r
3.10.0-327.el7.x86_64
[root@rac1 tmp]#
[root@rac1 tmp]# cd /etc/default/
[root@rac1 default]# ll
total 12
-rw-r--r--. 1 root root 218 Jun 2 14:04 grub
-rw-r--r--. 1 root root 1756 Aug 14 2015 nss
-rw-r--r--. 1 root root 119 Nov 25 2014 useradd
[root@rac1 default]# cp grub grub.bak ------->>>>备份grub文件
修改/etc/default/grub文件,如下是修改之后的效果:
[root@rac1 default]# cat /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="rhgb quiet transparent_hugepage=never" ---->>> transparent_hugepage=never是新加的
GRUB_DISABLE_RECOVERY="true"
[root@rac1 default]# grub2-mkconfig -o /boot/grub2/grub.cfg ---->>执行该命令
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-3b932bfbe4f94ccf93c11ba19641e845
Found initrd image: /boot/initramfs-0-rescue-3b932bfbe4f94ccf93c11ba19641e845.img
done
[root@rac1 default]# init 6 -------->>>>重启生效
os重启之后,查看效果
[root@rac1 ~]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=UUID=0dd676f4-cb3b-469d-b5e6-73defbc87f4e ro rhgb quiet transparent_hugepage=never ---->>>有此行。
[root@rac1 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never] ---->>>[never]表示成功禁用THP。
[root@rac1 ~]# cd /sys/kernel/mm/
[root@rac1 mm]# ls -lrt
total 0
drwxr-xr-x 4 root root 0 Jun 9 19:32 hugepages
drwxr-xr-x 2 root root 0 Jun 9 19:32 ksm
drwxr-xr-x 3 root root 0 Jun 9 19:35 transparent_hugepage
[root@rac1 mm]# cd transparent_hugepage/
[root@rac1 transparent_hugepage]# ls -lrt
total 0
-rw-r--r-- 1 root root 4096 Jun 9 19:35 enabled
-rw-r--r-- 1 root root 4096 Jun 9 19:35 use_zero_page
drwxr-xr-x 2 root root 0 Jun 9 19:35 khugepaged
-rw-r--r-- 1 root root 4096 Jun 9 19:35 defrag
[root@rac1 transparent_hugepage]# cat enabled
always madvise [never]
[root@rac1 transparent_hugepage]# pwd
/sys/kernel/mm/transparent_hugepage
[root@rac1 transparent_hugepage]# grep AnonHugePages /proc/meminfo
AnonHugePages: 0 kB ---------->>>返回值若是零,代表成功禁用THP。
[root@rac1 transparent_hugepage]#
————————————————
版权声明:本文为优快云博主「msdnchina」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/msdnchina/article/details/72968215