Skip to content

Commit 40bc083

Browse files
nelanbualbertnetymk
authored andcommitted
8358748: Large page size initialization fails with assert "page_size must be a power of 2"
Reviewed-by: ayang, dholmes
1 parent 320235c commit 40bc083

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ JVMFlag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbos
136136
return JVMFlag::SUCCESS;
137137
}
138138

139+
JVMFlag::Error LargePageSizeInBytesConstraintFunc(size_t value, bool verbose) {
140+
if (!is_power_of_2(value)) {
141+
JVMFlag::printError(verbose, "LargePageSizeInBytes ( %zu ) must be "
142+
"a power of 2\n",
143+
value);
144+
return JVMFlag::VIOLATES_CONSTRAINT;
145+
}
146+
return JVMFlag::SUCCESS;
147+
}
148+
139149
JVMFlag::Error OnSpinWaitInstNameConstraintFunc(ccstr value, bool verbose) {
140150
#ifdef AARCH64
141151
if (value == nullptr) {

src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
f(int, ContendedPaddingWidthConstraintFunc) \
4343
f(size_t, VMPageSizeConstraintFunc) \
4444
f(size_t, NUMAInterleaveGranularityConstraintFunc) \
45+
f(size_t, LargePageSizeInBytesConstraintFunc) \
4546
f(ccstr, OnSpinWaitInstNameConstraintFunc)
4647

4748
RUNTIME_CONSTRAINTS(DECLARE_CONSTRAINT)

src/hotspot/share/runtime/globals.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ const int ObjectAlignmentInBytes = 8;
237237
\
238238
product(size_t, LargePageSizeInBytes, 0, \
239239
"Maximum large page size used (0 will use the default large " \
240-
"page size for the environment as the maximum)") \
240+
"page size for the environment as the maximum) " \
241+
"(must be a power of 2)") \
241242
range(0, max_uintx) \
243+
constraint(LargePageSizeInBytesConstraintFunc, AtParse) \
242244
\
243245
product(size_t, LargePageHeapSizeThreshold, 128*M, \
244246
"Use large pages if maximum heap is at least this big") \

test/lib-test/jdk/test/whitebox/vm_flags/SizeTTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
3535
import jdk.test.lib.Platform;
3636

3737
public class SizeTTest {
38-
private static final String FLAG_NAME = "LargePageSizeInBytes";
38+
private static final String FLAG_NAME = "LargePageHeapSizeThreshold";
3939
private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE,
4040
(1L << 32L) - 1L, 1L << 32L};
4141
private static final Long[] EXPECTED_64 = TESTS;

0 commit comments

Comments
 (0)