Discover huge page support on POSIX or Linux
3
votes
2
answers
1183
views
I'm working on a program which needs to detect at runtime whether the system it's running on supports hugepages, and if so, what sizes are available. Ideally I'd like this to work for any POSIX platform, but a Linux-specific solution would be a start.
POSIX supports [
sysconf(_SC_PAGESIZE)
](http://man7.org/linux/man-pages/man3/sysconf.3.html) to get the default page size on the platform, but doesn't seem to similarly support asking for any hugepage sizes. I could also potentially check by trying to [mmap
](http://man7.org/linux/man-pages/man2/mmap.2.html) MAP_HUGE_2MB
or MAP_HUGE_1GB
arguments, but that would be slow, and in the case of 1GB huge pages, incredibly wasteful (and it could easily fail due to a lack of available memory).
Asked by joshlf
(395 rep)
May 11, 2017, 11:01 PM
Last activity: Dec 30, 2020, 10:27 PM
Last activity: Dec 30, 2020, 10:27 PM