DPDK has two hugepage sizes:2MB hugepages and 1GB hugepages. I run the command below to use the 1GB hugepages:
echo 6 > /sys/devices/system/node/node0/hugepages/hugepages-1048576kB/nr_hugepages
sudo mkdir -p /dev/hugepages_1gb
mount -t hugetlbfs nodev /dev/hugepages_1gb -o pagesize=1GB
However, when I run the command cat /proc/meminfo:
HugePages_Total: 8192
HugePages_Free: 8191
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
It still seems to use the 2MB hugepages. What should I do to use the 1GB hugepages?
The Hugepagesize field of /proc/meminfo is the default huge page size used by applications allocating huge pages. The available huge page sizes on your system can be seen with:
If you want to change the default huge page size, you can do it on the kernel command line with the default_hugepagesz parameter:
This will define the size of the huge pages in the mounted hugetlbfs file system. Here is an example where the default size is 2M:
You can also specify the number of huge pages that you need by writing in the corresponding nr_hugepages file in /sys/kernel/mm/hugepages:
If your application starts early, it is also possible to specify the number of reserved huge pages on the kernel command line with hugepages parameter: