Skip to content

Commit 870438e

Browse files
committed
8358748: Large page size initialization fails with assert "page_size must be a power of 2"
Reviewed-by: mdoerr Backport-of: 40bc083267c0bac64b1092c63325b8d245937b0e
1 parent e5ba180 commit 870438e

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
@@ -105,3 +105,13 @@ JVMFlag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbos
105105

106106
return JVMFlag::SUCCESS;
107107
}
108+
109+
JVMFlag::Error LargePageSizeInBytesConstraintFunc(size_t value, bool verbose) {
110+
if (!is_power_of_2(value)) {
111+
JVMFlag::printError(verbose, "LargePageSizeInBytes ( %zu ) must be "
112+
"a power of 2\n",
113+
value);
114+
return JVMFlag::VIOLATES_CONSTRAINT;
115+
}
116+
return JVMFlag::SUCCESS;
117+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
f(intx, ContendedPaddingWidthConstraintFunc) \
3939
f(intx, PerfDataSamplingIntervalFunc) \
4040
f(uintx, VMPageSizeConstraintFunc) \
41-
f(size_t, NUMAInterleaveGranularityConstraintFunc)
41+
f(size_t, NUMAInterleaveGranularityConstraintFunc) \
42+
f(size_t, LargePageSizeInBytesConstraintFunc)
4243

4344
RUNTIME_CONSTRAINTS(DECLARE_CONSTRAINT)
4445

src/hotspot/share/runtime/globals.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,10 @@ const int ObjectAlignmentInBytes = 8;
244244
\
245245
product(size_t, LargePageSizeInBytes, 0, \
246246
"Maximum large page size used (0 will use the default large " \
247-
"page size for the environment as the maximum)") \
247+
"page size for the environment as the maximum) " \
248+
"(must be a power of 2)") \
248249
range(0, max_uintx) \
250+
constraint(LargePageSizeInBytesConstraintFunc, AtParse) \
249251
\
250252
product(size_t, LargePageHeapSizeThreshold, 128*M, \
251253
"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)