RFR: 8358748: Large page size initialization fails with assert "page_size must be a power of 2"

David Holmes dholmes at openjdk.org
Thu Jun 26 08:12:30 UTC 2025


On Thu, 26 Jun 2025 07:48:43 GMT, Yagmur Eren <duke at openjdk.org> wrote:

> The VM now exits gracefully if `-XX:LargePageSizeInBytes` is set to a non power of two value, instead of asserting. After this change, `SizeTTest.java` failed because the tested values are not valid for `-XX:LargePageSizeInBytes` (`LargePageSizeInBytesConstraintFunc` returns `JVMFlag::VIOLATES_CONSTRAINT`). Therefore, I updated the test to use `NUMASpaceResizeRate`, since I believe that it only requires a flag of type `size_t`.
> 
> Before the change:
> 
> java -XX:+UseLargePages -XX:LargePageSizeInBytes=6 -version
> 
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # Internal Error (workspace/open/src/hotspot/share/runtime/os.cpp:2449), pid=1885945, tid=1885946
> # assert(is_power_of_2(page_size)) failed: page_size must be a power of 2: 0x6
> 
> 
> 
> After the change:
> 
> java -XX:+UseLargePages -XX:LargePageSizeInBytes=6 -version
> 
> LargePageSizeInBytes ( 6 ) must be a power of 2
> Improperly specified VM option 'LargePageSizeInBytes=6'
> Error: Could not create the Java Virtual Machine.
> Error: A fatal exception has occurred. Program will exit.

The `-XX:LargePageSizeInBytes` flag seems poorly specified. You can't use an arbitrary value in bytes as a large page size - that is just non-sensical. But I'm not sure this should be a hard error rather than applying "ergonomics" and rounding the supplied value to the nearest power-of-2 (with a warning this has happened).

src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp line 136:

> 134:                         "LargePageSizeInBytes ( %zu ) must be "
> 135:                         "a power of 2\n",
> 136:                         value);

Suggestion:

    JVMFlag::printError(verbose, "LargePageSizeInBytes ( %zu ) must be "
                        "a power of 2\n", value);

src/hotspot/share/runtime/globals.hpp line 245:

> 243:   product(size_t, LargePageSizeInBytes, 0,                                  \
> 244:           "Maximum large page size used (0 will use the default large "     \
> 245:           "page size for the environment as the maximum)")                  \

Suggestion:

          "page size for the environment as the maximum) (must be a power of 2)")                  \

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

PR Comment: https://git.openjdk.org/jdk/pull/25994#issuecomment-3007579028
PR Review Comment: https://git.openjdk.org/jdk/pull/25994#discussion_r2168460392
PR Review Comment: https://git.openjdk.org/jdk/pull/25994#discussion_r2168464564


More information about the hotspot-runtime-dev mailing list