Linux large pages: why do we have UseSHM?

David Holmes david.holmes at oracle.com
Sat Dec 5 05:00:36 UTC 2020


Hi Thomas,

On 4/12/2020 4:48 am, Thomas Stüfe wrote:
> 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.

We had the UseSHM stuff first. The UseHugeTLBFS stuff came later. See 
this discussion:

http://mail.openjdk.java.net/pipermail/hotspot-dev/2011-April/004063.html

and the related bug that made the changes:

https://bugs.openjdk.java.net/browse/JDK-7034464

HTH.

David

> 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