How to disable transparent Hugepage (THP) on Red Hat Enterprise Linux 8?

你好我是李白發表於2020-01-19

環境

  • Red Hat Enterprise Linux 8
  • Transparent HugePage (THP)

問題

  • How to disable transparent Hugepage (THP) on Red Hat Enterprise Linux 8?

決議

  • The transparent hugepage (THP) can be disabled by booting the system with the kernel boot parameter  transparent_hugepage=never.

Command Line: The  grub2-editenv command can be used to set the kernel parameter  transparent_hugepage=never at the end of  kerneloptsin the file  /boot/grub2/grubenv.

  • Get the current kernel command line parameters.
# grub2-editenv - list | grep kernelopts
kernelopts=root=/dev/mapper/rhel-root ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap
  • Set the kernel parameter  transparent_hugepage=never by using the  grub2-editenv command.
# grub2-editenv - set "kernelopts=root=/dev/mapper/rhel-root ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap transparent_hugepage=never"
  • Verify the changes.
# grub2-editenv - list | grep kernelopts
kernelopts=root=/dev/mapper/rhel-root ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap transparent_hugepage=never
  • Reboot the system for changes to take effect.
# reboot
  • Check the following files to confirm that the transparent hugepage (THP) is disabled.
# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
# grep AnonHugePages: /proc/meminfo 
AnonHugePages:         0 kB
# grep nr_anon_transparent_hugepages /proc/vmstat
nr_anon_transparent_hugepages 0

Configuration File: The kernel boot parameter  transparent_hugepage=never can be directly set at the end of  kernelopts in the file  /boot/grub2/grubenv.

  • Edit file  /boot/grub2/grubenv and set the kernel boot parameter  transparent_hugepage=never at the end of  kernelopts.

Eg:

# cat /boot/grub2/grubenv
# GRUB Environment Block
saved_entry=d956a05b4c9341b9a364b20b801afc12-4.18.0-64.el8.x86_64
boot_success=0
boot_indeterminate=0
kernelopts=root=/dev/mapper/rhel-root ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap transparent_hugepage=never
  • Reboot the system for changes to take effect.
# reboot
  • Check the following files to confirm that the transparent hugepage (THP) is disabled.
# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
# grep AnonHugePages: /proc/meminfo 
AnonHugePages:         0 kB
# grep nr_anon_transparent_hugepages /proc/vmstat
nr_anon_transparent_hugepages 0


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31439444/viewspace-2674003/,如需轉載,請註明出處,否則將追究法律責任。

相關文章