mmap error : cannot allocate memory. how to allocate enough default sized huge pages as admin?
mmap error : cannot allocate memory. how to allocate enough default sized huge pages as admin?
我正在编译 运行 this 程序但收到了 'mmap error : cannot allocate memory'。
顶部的评论是
/*
* Example of using hugepage memory in a user application using the mmap
* system call with MAP_HUGETLB flag. Before running this program make
* sure the administrator has allocated enough default sized huge pages
* to cover the 256 MB allocation.
*
* For ia64 architecture, Linux kernel reserves Region number 4 for hugepages.
* That means the addresses starting with 0x800000... will need to be
* specified. Specifying a fixed address is not required on ppc64, i386
* or x86_64.
*/
我想查看 if the administrator has allocated enough default sized huge pages to cover the 256 MB allocation
但我是系统管理员。我应该怎么办?我在 ubuntu 20.04 x86_64 机器上。 (附带问题:mmap 是否使用堆区域?)
添加:请看我的评论(我添加了一个启动命令参数,代码可以工作。我临时在 grub 菜单中添加了启动参数。)但我希望我可以添加一个初始化脚本,这样每次都能生效计算机启动。
好像有2种方法。
在 /etc/sysctrl.conf 中添加 vm.nr_hugepages = 16
并重新启动。
我检查过这个有效。
(正如 Nate Eldredge 评论的那样)在 /etc/default/grub 的 GRUB_CMDLINE_LINUX="" 行(引号内)中添加 'hugepages=16' 并执行 update-grub。
我正在编译 运行 this 程序但收到了 'mmap error : cannot allocate memory'。 顶部的评论是
/*
* Example of using hugepage memory in a user application using the mmap
* system call with MAP_HUGETLB flag. Before running this program make
* sure the administrator has allocated enough default sized huge pages
* to cover the 256 MB allocation.
*
* For ia64 architecture, Linux kernel reserves Region number 4 for hugepages.
* That means the addresses starting with 0x800000... will need to be
* specified. Specifying a fixed address is not required on ppc64, i386
* or x86_64.
*/
我想查看 if the administrator has allocated enough default sized huge pages to cover the 256 MB allocation
但我是系统管理员。我应该怎么办?我在 ubuntu 20.04 x86_64 机器上。 (附带问题:mmap 是否使用堆区域?)
添加:请看我的评论(我添加了一个启动命令参数,代码可以工作。我临时在 grub 菜单中添加了启动参数。)但我希望我可以添加一个初始化脚本,这样每次都能生效计算机启动。
好像有2种方法。
在 /etc/sysctrl.conf 中添加
vm.nr_hugepages = 16
并重新启动。
我检查过这个有效。(正如 Nate Eldredge 评论的那样)在 /etc/default/grub 的 GRUB_CMDLINE_LINUX="" 行(引号内)中添加 'hugepages=16' 并执行 update-grub。