Linux 大页修改

随笔记录

目录

1. 背景介绍

2. 麒麟SP1 系统修改大页

2.1 查询大页信息

2.2 通过kernel cmdline配置大页 

2.3 生成配置

2.4 查看配置是否生效

2.5 查询大页是否配置成功

3. CenOS 系统修改大页


1. 背景介绍

若操作系统当前Hugepagesize不是2048kB,则只能通过修改kernel cmdline的方式进行配置修改,此方式在系统重启后仍然生效。

不同Linux发行版本的配置方式有所不同

2. 麒麟SP1 系统修改大页

2.1 查询大页信息

[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# cat /proc/meminfo|grep -i hugepage
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
HugePages_Total:      15
HugePages_Free:       15
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:     524288 kB
[root@ptg97 Python-3.8.13]# 

2.2 通过kernel cmdline配置大页 

# 修改“/etc/default/grub”文件中“GRUB_CMDLINE_LINUX”对应行,添加“default_hugepagesz=2M hugepagesz=2M hugepages=1024

[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# 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="crashkernel=1024M,high rd.lvm.lv=klas/root video=VGA-1:640x480-32@60me rhgb quiet  smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me"
GRUB_DISABLE_RECOVERY="true"
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# vi /etc/default/grub 
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# 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="crashkernel=1024M,high rd.lvm.lv=klas/root video=VGA-1:640x480-32@60me rhgb quiet  smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me"
GRUB_CMDLINE_LINUX="crashkernel=1024M,high rd.lvm.lv=klas/root video=VGA-1:640x480-32@60me rhgb quiet  smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me default_hugepagesz=2M hugepagesz=2M hugepages=1024"
GRUB_DISABLE_RECOVERY="true"
[root@ptg97 Python-3.8.13]# 

2.3 生成配置

注意“grub.cfg”所在目录在不同版本系统中会有所不同

执行“grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg” 生成配置,然后重启系统

注意“grub.cfg”所在目录在不同版本系统中会有所不同,


[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# find /boot -name grub.cfg
/boot/efi/EFI/kylin/grub.cfg
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# grub2-mkconfig -o /boot/efi/EFI/kylin/grub.cfg 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.19.90-23.8.v2101.ky10.aarch64
Found initrd image: /boot/initramfs-4.19.90-23.8.v2101.ky10.aarch64.img
Found linux image: /boot/vmlinuz-0-rescue-12b759ac8f8e48e0a406e01c68af06a0
Found initrd image: /boot/initramfs-0-rescue-12b759ac8f8e48e0a406e01c68af06a0.img
Adding boot menu entry for EFI firmware configuration
done
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# 
[root@ptg97 Python-3.8.13]# reboot


 重启后,继续检查

2.4 查看配置是否生效

执行“cat /proc/cmdline”,查看配置是否生效

# cat /proc/cmdline

[root@ptg97 ~]# 
[root@ptg97 ~]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-4.19.90-23.8.v2101.ky10.aarch64 root=/dev/mapper/klas-root ro crashkernel=1024M,high rd.lvm.lv=klas/root video=VGA-1:640x480-32@60me rhgb quiet smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me default_hugepagesz=2M hugepagesz=2M hugepages=1024
[root@ptg97 ~]# 

2.5 查询大页是否配置成功

# cat /proc/meminfo|grep -i hugepage

[root@ptg97 ~]# cat /proc/meminfo|grep -i hugepage
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
HugePages_Total:    1024
HugePages_Free:     1024
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
[root@ptg97 ~]# 
[root@ptg97 ~]# 

3. CenOS 系统修改大页


root@bogon ~]# 
[root@bogon ~]# 
[root@bogon ~]# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
#GRUB_DEFAULT=1
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
#GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cs/root rhgb quiet"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cs/root rhgb quiet isolcpus=1,3 nohz_full=1,3 rcu_nocbs=1,3 iommu=pt intel_idle.max_cstate=0 idle=poll intel_pstate=disable"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

pcie_aspm=off
[root@bogon ~]# vi /etc/default/grub 
[root@bogon ~]# 
[root@bogon ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg 
Generating grub configuration file ...
Adding boot menu entry for EFI firmware configuration
done
[root@bogon ~]# 
[root@bogon ~]# 
[root@bogon ~]# cat /proc/meminfo|grep -i hugepage
AnonHugePages:     98304 kB
ShmemHugePages:        0 kB
FileHugePages:         0 kB
HugePages_Total:    1024
HugePages_Free:     1024
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
[root@bogon ~]# 
[root@bogon ~]# 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值