因为目前在openshift的容器里使用hugepage, 不能使用iova-mode:pa 模式, 我需要判断底层的redhat 系统上能不能使用hugepage。 如果RHEL能使用, 那就是openshift 上层平台阻止了Hugepage的使用。
从网上找了几个链接配置都没有成功。
无意中在查看OS 版本时, 看到了文档说明 :
[root@localhost testmacDemo]# cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="9.4 (Plow)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="9.4"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Red Hat Enterprise Linux 9.4 (Plow)"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:redhat:enterprise_linux:9::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9"
BUG_REPORT_URL="https://issues.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 9"
REDHAT_BUGZILLA_PRODUCT_VERSION=9.4
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.4"
这不就有希望了, 按照说明, 搞了几次成功了。 步骤分享如下:
1.To create a HugeTLB pool for 1 GB pages, enable the default_hugepagesz=1G and hugepagesz=1G kernel options:
grubby --update-kernel=ALL --args="default_hugepagesz=1G hugepagesz=1G"
2.Create a new file called hugetlb-gigantic-pages.service in the /usr/lib/systemd/system/ directory and add the following content:
[Unit]
Description=HugeTLB Gigantic Pages Reservation
DefaultDependencies=no
Before=dev-hugepages.mount
ConditionPathExists=/sys/devices/system/node
ConditionKernelCommandLine=hugepagesz=1G
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/hugetlb-reserve-pages.sh
[Install]
WantedBy=sysinit.target
3.Create a new file called hugetlb-reserve-pages.sh in the /usr/lib/systemd/ directory and add the following content:
While adding the following content, replace number_of_pages with the number of 1GB pages you want to reserve, and node with the name of the node on which to reserve these pages.
#!/bin/sh
nodes_path=/sys/devices/system/node/
if [ ! -d $nodes_path ]; then
echo "ERROR: $nodes_path does not exist"
exit 1
fi
reserve_pages()
{
echo $1 > $nodes_path/$2/hugepages/hugepages-1048576kB/nr_hugepages
}
reserve_pages 8 node0
reserve_pages 8 node1
4.Create an executable script:
chmod +x /usr/lib/systemd/hugetlb-reserve-pages.sh
5. Enable early boot reservation:
systemctl enable hugetlb-gigantic-pages
6. reboot.
7.Password:
[root@localhost test]# cat /proc/meminfo
MemTotal: 63864348 kB
MemFree: 44422116 kB
MemAvailable: 44692992 kB
Buffers: 5012 kB
Cached: 750512 kB
SwapCached: 0 kB
Active: 1203648 kB
Inactive: 352900 kB
Active(anon): 849800 kB
Inactive(anon): 0 kB
Active(file): 353848 kB
Inactive(file): 352900 kB
Unevictable: 96 kB
Mlocked: 0 kB
SwapTotal: 24420348 kB
SwapFree: 24420348 kB
Zswap: 0 kB
Zswapped: 0 kB
Dirty: 20 kB
Writeback: 0 kB
AnonPages: 789012 kB
Mapped: 241468 kB
Shmem: 48772 kB
KReclaimable: 57988 kB
Slab: 228168 kB
SReclaimable: 57988 kB
SUnreclaim: 170180 kB
KernelStack: 20048 kB
PageTables: 17180 kB
SecPageTables: 0 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 47963912 kB
Committed_AS: 4607012 kB
VmallocTotal: 133141626880 kB
VmallocUsed: 180244 kB
VmallocChunk: 0 kB
Percpu: 69888 kB
HardwareCorrupted: 0 kB
AnonHugePages: 116736 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 16
HugePages_Free: 16
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 1048576 kB
Hugetlb: 16777216 kB