Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8321526

StaticHugePageSupport::pagesizes() should only return page sizes with non-zero nr_hugepages

XMLWordPrintable

      `StaticHugePageSupport::pagesizes()` returns page sizes which Linux supports. The page sizes are got from scanning all directories in `/sys/kernel/mm/hugepages`. This is done in `scan_hugepages()` function.

      When `ReservedSpace::reserve` fails to allocate memory with the specified page size, it tries to use a smaller page size from the list, which is based on `StaticHugePageSupport::pagesizes()`, till it fails to the OS vm page size. Attempts to use page sizes with zero nr_hugepages will always fail because there is no such pages in the kernel's huge page pool. For example, AArch64 supports 64k, 2M, 32M, 1G pages for 4k granule. To avoid such attempts `StaticHugePageSupport::pagesizes()` should only return page sizes with non-zero `nr_hugepages`.

      A user with root privileges can dynamically allocate more or free some persistent huge pages by increasing or decreasing the value of 'nr_hugepages':
       - Doing this before starting JVM, will cause the corresponding page sizes to be added to the list.
       - Doing this after JVM is initialized will have no effect because memory has been reserved and committed using pages available in the kernel's huge page pool at the time of initialization.
       - Doing this during JVM initialization could result inconsistent memory allocation.

      Note: when persistent huge pages are reserved they are always committed.

            eastigeevich Evgeny Astigeevich
            eastigeevich Evgeny Astigeevich
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: