Skip to content

Commit e5d39d8

Browse files
committed
8358748: Large page size initialization fails with assert "page_size must be a power of 2"
Backport-of: 870438ed6453b19817c18d48feae01cddea44d50
1 parent 66fad22 commit e5d39d8

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,13 @@ JVMFlag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbos
161161

162162
return JVMFlag::SUCCESS;
163163
}
164+
165+
JVMFlag::Error LargePageSizeInBytesConstraintFunc(size_t value, bool verbose) {
166+
if (!is_power_of_2(value)) {
167+
JVMFlag::printError(verbose, "LargePageSizeInBytes ( %zu ) must be "
168+
"a power of 2\n",
169+
value);
170+
return JVMFlag::VIOLATES_CONSTRAINT;
171+
}
172+
return JVMFlag::SUCCESS;
173+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
f(intx, BiasedLockingDecayTimeFunc) \
4343
f(intx, PerfDataSamplingIntervalFunc) \
4444
f(uintx, VMPageSizeConstraintFunc) \
45-
f(size_t, NUMAInterleaveGranularityConstraintFunc)
45+
f(size_t, NUMAInterleaveGranularityConstraintFunc) \
46+
f(size_t, LargePageSizeInBytesConstraintFunc)
4647

4748
RUNTIME_CONSTRAINTS(DECLARE_CONSTRAINT)
4849

src/hotspot/share/runtime/globals.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,10 @@ const intx ObjectAlignmentInBytes = 8;
241241
\
242242
product(size_t, LargePageSizeInBytes, 0, \
243243
"Maximum large page size used (0 will use the default large " \
244-
"page size for the environment as the maximum)") \
244+
"page size for the environment as the maximum) " \
245+
"(must be a power of 2)") \
245246
range(0, max_uintx) \
247+
constraint(LargePageSizeInBytesConstraintFunc, AtParse) \
246248
\
247249
product(size_t, LargePageHeapSizeThreshold, 128*M, \
248250
"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, 2021, 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 = "ArrayAllocatorMallocLimit";
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)