RFR: 8346005: Parallel: Incorrect page size calculation with UseLargePages [v6]

Joel Sikström jsikstro at openjdk.org
Thu Oct 2 09:39:03 UTC 2025


On Thu, 25 Sep 2025 11:14:46 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

>> Refactor the heap-space and OS memory interface code to clearly separate two related but distinct concepts: `alignment` and `os-page-size`. These are now represented as two fields in `PSVirtualSpace`.
>> 
>> The parallel heap consists of four spaces: old, eden, from, and to. The first belongs to the old generation, while the latter three belong to the young generation.
>> 
>> The size of any space is always aligned to `alignment`, which also determines the unit for resizing. To keep the implementation simple while allowing flexible per-space commit and uncommit operations, each space must contain at least one OS page. As a result, `alignment` is always greater than or equal to `os-page-size`.
>> 
>> When using explicit large pages -- which require pre-allocating large pages before the VM starts -- the actual OS page size is not known until the heap has been reserved. The additional logic in `ParallelScavengeHeap::initialize` detects the OS page size in use and adjusts `alignment` if necessary.
>> 
>> Test: tier1–8
>
> Albert Mingkun Yang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - Merge branch 'master' into pgc-largepage
>  - Merge branch 'master' into pgc-largepage
>  - page-size
>  - Merge branch 'master' into pgc-largepage
>  - Merge branch 'master' into pgc-largepage
>  - Merge branch 'master' into pgc-largepage
>  - pgc-largepage

Reviewing this is taking some time, so this is not a full review yet, but so far I have some comments:

Why do we need the dance with Parallel being able to set a specific `desired_page_size` in `Universe::reserve_heap()`? Maybe I'm wrong, but would it not work to disable UseLargePages early and not have specific logic for Parallel?

src/hotspot/share/gc/parallel/mutableSpace.hpp line 65:

> 63: 
> 64: protected:
> 65:   size_t page_size() const                           { return _page_size;         }

We should vertically align this with the other blocks.

src/hotspot/share/gc/parallel/parallelArguments.cpp line 131:

> 129:   if (page_sz == os::vm_page_size()) {
> 130:     log_warning(gc, heap)("MinHeapSize (%zu) must be large enough for 4 * page-size; Disabling UseLargePages for heap", MinHeapSize);
> 131:     return;

Wouldn't it make sense to do `FLAG_SET_ERGO(UseLargepages, false)` here since it is effectively disabled.

src/hotspot/share/gc/parallel/parallelArguments.cpp line 137:

> 135:   assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2");
> 136:   // Space is largepage-aligned.
> 137:   size_t new_alignment = page_sz;

To me it looks like new_alignment will always be different from SpaceAlignment here. We could simplify this to the following:


  SpaceAlignment = page_sz;
    
  // Redo everything from the start
  initialize_heap_flags_and_sizes_one_pass();

-------------

PR Review: https://git.openjdk.org/jdk/pull/26700#pullrequestreview-3252288423
PR Review Comment: https://git.openjdk.org/jdk/pull/26700#discussion_r2397598451
PR Review Comment: https://git.openjdk.org/jdk/pull/26700#discussion_r2397910679
PR Review Comment: https://git.openjdk.org/jdk/pull/26700#discussion_r2397931660


More information about the hotspot-gc-dev mailing list