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

Wrong heap mapper can be selected with UseLargePages on G1

XMLWordPrintable

    • gc
    • b23

      In some cases, wrong heap mapper can be selected if there is inconsistency between UseLargePages and actual heap reservation on G1.

      If UseLargePages=true and os::can_commit_large_page_memory() is false, ReservedSpace::initialize() will try to allocate 'special' memory. (ReservedSpace::_special). But if it fails, regular memory will be reserved.

      However, after getting ReservedSpace instance at G1CollectedHeap::initialize(), we don't check whether the reservation is occurred with large page or not. It just checks UseLargePages option which is not properly reflecting the situation.
      As a result, G1 would decide wrong heap mapper as page size is one of the key factor when we choose the heap mapper.

      This situation only happens when G1HeapRegionSize is less than or equal to large page size.
      e.g. G1HeapRegionsSize=1MB, default page size=4KB, large page size=2MB. G1 selects G1RegionsSmallerThanCommitSizeMapper (G1HeapRegionSize < large page size, at G1RegionToSpaceMapper::create_mapper()) but actually we are using default page(failed allocating with large page) so G1RegionsLargerThanCommitSizeMapper should be selected. Eventually G1 commits memory with not optimal way(it works) and pages will not touched properly when AlwaysPreTouch option is enabled.

      FYI, just changing UseLargePages option at ReservedSpace::initialize() seems not good idea as there are other cases using ReservedSpace class. e.g. CodeCache..

            sangheki Sangheon Kim
            sangheki Sangheon Kim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: