I'm looking for a way to allocate huge pages (2M or 1G) in a kernel module (I'm using kernel version 4.15.0).
In user space, I can mount the hugetlbfs
file system, and then allocate huge pages using mmap
(see, e.g., https://blog.kevinhu.me/2018/07/01/01-Linux-Hugepages/). Is there a similar way to do this in kernel space?
I'm aware that I could allocate them in user space first, and then pass them to the kernel using get_user_pages
, as described in Sequential access to hugepages in kernel driver. However, I'm looking for a more direct way to allocate them, as I only need them in kernel space.