Linux large pages: why do we have UseSHM?

Thomas Stüfe thomas.stuefe at gmail.com
Thu Dec 3 18:48:35 UTC 2020


Hi,

I wonder why we support two different ways (discounting THPs) to allocate
huge pages on Linux.

We support allocating huge pages both via System V shm APIs (UseSHM) and
via the "newer" mmap Posix APIs (UseHugeTLBFS). The latter is default for
+UseLargePages.

I do not see a practical difference beside the fact that:
- System V shm API is slightly fussier to use (eg no partial unmap possible)
- it requires kernel.shmmax to be correctly set, in addition to the
vm.nr_xxx_hugepages
- it requires more user permissions

But in the end, we end up with kernel huge pages, one way or the other.
Both give access to 2M and 1G pages.

I looked through mailing list archives and bug descriptions, but beyond
vague mentionings of "one way could fail, then try the other" I did not
find anything.

I must be missing something. Does anyone have any closer knowledge
about this?

Thank you!

Thomas


More information about the hotspot-dev mailing list