我在 DPDK 上运行某些应用程序,为了节省内存,我通过设置“nr_hugepages”不断调整大页面的数量
echo 8192> /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
cat /proc/meminfo | grep -i huge
AnonHugePages: 0 kB
HugePages_Total: 8192
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
free -g
total used free shared buff/cache available
Mem: 188 17 159 0 11 170
Swap: 191 0 191
但是,当我达到 64K 时,我似乎卡住了,无法再次更改 Hugepages
echo 65536 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
sudo hugeadm --pool-list
Size Minimum Current Maximum Default
2097152 65536 65536 65536 *
1073741824 0 0
cat /proc/meminfo | grep -i huge
AnonHugePages: 0 kB
HugePages_Total: 65536
HugePages_Free: 64
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
现在,即使我将 nr_hugepages 设置为 512
echo 512 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
nr_hugepages 读回为 64K
cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
65472