Skip to content

Commit 1d44608

Browse files
nelanbushipilev
authored andcommitted
8358748: Large page size initialization fails with assert "page_size must be a power of 2"
Reviewed-by: ayang, dholmes Backport-of: 40bc083267c0bac64b1092c63325b8d245937b0e
1 parent 0a6cbb7 commit 1d44608

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

148148
return JVMFlag::SUCCESS;
149149
}
150+
151+
JVMFlag::Error LargePageSizeInBytesConstraintFunc(size_t value, bool verbose) {
152+
if (!is_power_of_2(value)) {
153+
JVMFlag::printError(verbose, "LargePageSizeInBytes ( %zu ) must be "
154+
"a power of 2\n",
155+
value);
156+
return JVMFlag::VIOLATES_CONSTRAINT;
157+
}
158+
return JVMFlag::SUCCESS;
159+
}

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(int, ContendedPaddingWidthConstraintFunc) \
4343
f(int, 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
@@ -242,8 +242,10 @@ const int ObjectAlignmentInBytes = 8;
242242
\
243243
product(size_t, LargePageSizeInBytes, 0, \
244244
"Maximum large page size used (0 will use the default large " \
245-
"page size for the environment as the maximum)") \
245+
"page size for the environment as the maximum) " \
246+
"(must be a power of 2)") \
246247
range(0, max_uintx) \
248+
constraint(LargePageSizeInBytesConstraintFunc, AtParse) \
247249
\
248250
product(size_t, LargePageHeapSizeThreshold, 128*M, \
249251
"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)