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

Reviewed-by: ayang, dholmes
This commit is contained in:
Yagmur Eren 2025-08-20 07:16:36 +00:00 committed by Albert Mingkun Yang
parent 320235ccb8
commit 40bc083267
4 changed files with 16 additions and 3 deletions

View File

@ -136,6 +136,16 @@ JVMFlag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbos
return JVMFlag::SUCCESS;
}
JVMFlag::Error LargePageSizeInBytesConstraintFunc(size_t value, bool verbose) {
if (!is_power_of_2(value)) {
JVMFlag::printError(verbose, "LargePageSizeInBytes ( %zu ) must be "
"a power of 2\n",
value);
return JVMFlag::VIOLATES_CONSTRAINT;
}
return JVMFlag::SUCCESS;
}
JVMFlag::Error OnSpinWaitInstNameConstraintFunc(ccstr value, bool verbose) {
#ifdef AARCH64
if (value == nullptr) {

View File

@ -42,6 +42,7 @@
f(int, ContendedPaddingWidthConstraintFunc) \
f(size_t, VMPageSizeConstraintFunc) \
f(size_t, NUMAInterleaveGranularityConstraintFunc) \
f(size_t, LargePageSizeInBytesConstraintFunc) \
f(ccstr, OnSpinWaitInstNameConstraintFunc)
RUNTIME_CONSTRAINTS(DECLARE_CONSTRAINT)

View File

@ -237,8 +237,10 @@ const int ObjectAlignmentInBytes = 8;
\
product(size_t, LargePageSizeInBytes, 0, \
"Maximum large page size used (0 will use the default large " \
"page size for the environment as the maximum)") \
"page size for the environment as the maximum) " \
"(must be a power of 2)") \
range(0, max_uintx) \
constraint(LargePageSizeInBytesConstraintFunc, AtParse) \
\
product(size_t, LargePageHeapSizeThreshold, 128*M, \
"Use large pages if maximum heap is at least this big") \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,7 @@
import jdk.test.lib.Platform;
public class SizeTTest {
private static final String FLAG_NAME = "LargePageSizeInBytes";
private static final String FLAG_NAME = "LargePageHeapSizeThreshold";
private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE,
(1L << 32L) - 1L, 1L << 32L};
private static final Long[] EXPECTED_64 = TESTS;