怎么在RHEL7上禁用transparent hugepages (THP)

原文标题:

How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7 

原文网址:

https://access.redhat.com/solutions/1320153

 

环境

  • Red Hat Enterprise Linux 7
  • transparent hugepages (THP)
  • tuned

问题

  • How to disable transparent hugepages (THP) on Red Hat Enterprise Linux 7
  • Disabling transparent hugepages (THP) on Red Hat Enterprise Linux 7 is not taking effect.

决议

 

Follow the steps below

  1. Add the "transparent_hugepage=never" kernel parameter option to the grub2 configuration file.

    • Append or change the "transparent_hugepage=never" kernel parameter on the GRUB_CMDLINE_LINUX option in /etc/default/grub file. Only include the parameter once.

      Raw

      GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap ... transparent_hugepage=never"
      
  2. Rebuild the /boot/grub2/grub.cfg file by running the grub2-mkconfig -o command as follows:

    • Please ensure to take a backup of the existing /boot/grub2/grub.cfg before rebuilding.
      • On BIOS-based machines: ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
      • On UEFI-based machines: ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  3. Reboot the system and verify option has been added

    • Reboot the system

      Raw

      # shutdown -r now
      
    • Verify the parameter is set correctly

      Raw

      # cat /proc/cmdline
      

查询hugepage状态,第一种方式

1

2

3

4

[root@localhost yucanlin]# cat /sys/kernel/mm/transparent_hugepage/enabled

always madvise [never]

[root@localhost yucanlin]# cat /sys/kernel/mm/transparent_hugepage/defrag

always madvise [never]

never就对了。

第二种方式

1

2

3

4

5

6

7

[yucanlin@localhost ~]$ grep Huge /proc/meminfo

AnonHugePages:         0 kB

HugePages_Total:       0

HugePages_Free:        0

HugePages_Rsvd:        0

HugePages_Surp:        0

Hugepagesize:       2048 kB

0就对了。

不过有个小遗憾,重启后我发现 enabled 是never,但defrag却依然是always,不过经过查询meminfo,大内存页面是被禁用了。就不去管他了。


If Transparent Huge Pages (THP) is still not disabled, continue and use one of the options below.

  • Option 1: (Recommended) create a customized tuned profile with disabled THP

    • With this resolution we will create a customized version of the currently running profile. The customized version will disable THP.
    • Find out which profile is active, create a copy. In the following example we currently use the throughput-performance profile:

      Raw

       
      1. # tuned-adm active

      2. Current active profile: throughput-performance

    • To create customized profile, create a new directory in /etc/tuned directory with desired profile name.

      Raw

      # mkdir /etc/tuned/myprofile-nothp
      
    • Then create a new tuned.conf file for myprofile-nothp, and insert the new tuning info:

      Raw

       
      1. # cat /etc/tuned/myprofile-nothp/tuned.conf

      2. [main]

      3. include= throughput-performance

      4.  
      5. [vm]

      6. transparent_hugepages=never

    • Make the script executable:

      Raw

      # chmod +x /etc/tuned/myprofile-nothp/tuned.conf 
      
    • Enable myprofile like so:

      Raw

      # tuned-adm profile myprofile-nothp
      
    • This change will immediately take effect and persist reboots.

    • To verify if THP are disabled or not, run below command:

      Raw

      # cat /sys/kernel/mm/transparent_hugepage/enabled
      
  • Option 2: (Alternative) Disable tuned services

    • This resolution will disable the tuned services.

      Raw

       
      1. # systemctl stop tuned

      2. # systemctl disable tuned

    • OR

      Raw

      # tuned-adm off
      
    • Now add "transparent_hugepage=never" kernel parameter in grub2 configuration file as explained in steps 1-3 above.

    • Reboot the server for changes to take effect.

 

转载至https://blog.csdn.net/msdnchina/article/details/79830455

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值