Skip to content

Commit 5daa772

Browse files
Automatic merge of master into galahad
2 parents 5804b8b + 6118c2c commit 5daa772

File tree

17 files changed

+303
-168
lines changed

17 files changed

+303
-168
lines changed

common.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545

4646
"oraclejdk23": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+37", "platformspecific": true, "extrabundles": ["static-libs"]},
4747

48-
"oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+12", "platformspecific": true, "extrabundles": ["static-libs"]},
49-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+12-jvmci-b01", "platformspecific": true },
50-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+12-jvmci-b01-debug", "platformspecific": true },
51-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+12-jvmci-b01-sulong", "platformspecific": true },
52-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+12-jvmci-b01", "platformspecific": true },
53-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+12-jvmci-b01-debug", "platformspecific": true },
54-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+12-jvmci-b01-sulong", "platformspecific": true }
48+
"oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+13", "platformspecific": true, "extrabundles": ["static-libs"]},
49+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+13-jvmci-b01", "platformspecific": true },
50+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+13-jvmci-b01-debug", "platformspecific": true },
51+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+13-jvmci-b01-sulong", "platformspecific": true },
52+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+13-jvmci-b01", "platformspecific": true },
53+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+13-jvmci-b01-debug", "platformspecific": true },
54+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+13-jvmci-b01-sulong", "platformspecific": true }
5555
},
5656

5757
"eclipse": {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public final class JVMCIVersionCheck {
5656
private static final Map<String, Map<String, Version>> JVMCI_MIN_VERSIONS = Map.of(
5757
"21", Map.of(DEFAULT_VENDOR_ENTRY, createLegacyVersion(23, 1, 33)),
5858
"25", Map.of(
59-
"Oracle Corporation", createLabsJDKVersion("25+12", 1),
60-
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25+12", 1)));
59+
"Oracle Corporation", createLabsJDKVersion("25+13", 1),
60+
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25+13", 1)));
6161
private static final int NA = 0;
6262
/**
6363
* Minimum Java release supported by Graal.

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java

+13
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ public UnimplementedGraalIntrinsics(Architecture arch) {
108108
// @formatter:on
109109
);
110110
}
111+
112+
if (jdk >= 25) {
113+
add(toBeInvestigated,
114+
// JDK-8348561: Add aarch64 intrinsics for ML-DSA
115+
// JDK-8351034: Add AVX-512 intrinsics for ML-DSA
116+
"sun/security/provider/ML_DSA.implDilithiumAlmostInverseNtt([I[I)I",
117+
"sun/security/provider/ML_DSA.implDilithiumAlmostNtt([I[I)I",
118+
"sun/security/provider/ML_DSA.implDilithiumDecomposePoly([I[I[III)I",
119+
"sun/security/provider/ML_DSA.implDilithiumMontMulByConstant([II)I",
120+
"sun/security/provider/ML_DSA.implDilithiumNttMult([I[I[I)I",
121+
"sun/security/provider/SHA3Parallel.doubleKeccak([J[J)I");
122+
}
123+
111124
add(ignore,
112125
// These are dead
113126
"java/lang/Math.atan2(DD)D",

substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* It seems like this could be easily supported once thread-local handshakes are supported.
4242
*/
4343
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+15/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess-bin.java.template")
44-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+2/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template")
44+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template")
4545
@TargetClass(className = "jdk.internal.misc.ScopedMemoryAccess", onlyWith = ForeignFunctionsEnabled.class)
4646
public final class Target_jdk_internal_misc_ScopedMemoryAccess {
4747
@Substitute

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java

+38-38
Original file line numberDiff line numberDiff line change
@@ -48,46 +48,46 @@
4848
@CContext(ContainerLibraryDirectives.class)
4949
@CLibrary(value = "svm_container", requireStatic = true, dependsOn = "m")
5050
// The following annotations are for files in `src/hotspot`, which are copied from the JDK
51-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/java.base/share/native/include/jni.h")
51+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/java.base/share/native/include/jni.h")
5252
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/java.base/unix/native/include/jni_md.h")
53-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupSubsystem_linux.cpp")
54-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupSubsystem_linux.hpp")
55-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupUtil_linux.cpp")
56-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupUtil_linux.hpp")
57-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp")
58-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp")
59-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp")
60-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp")
61-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/osContainer_linux.cpp")
62-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/osContainer_linux.hpp")
63-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+8/src/hotspot/os/linux/os_linux.cpp")
64-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+8/src/hotspot/os/linux/os_linux.hpp")
65-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/linux/os_linux.inline.hpp")
66-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/posix/include/jvm_md.h")
67-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+7/src/hotspot/os/posix/os_posix.cpp")
68-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/posix/os_posix.hpp")
69-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/os/posix/os_posix.inline.hpp")
70-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+12/src/hotspot/share/memory/allocation.hpp")
71-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/memory/allocation.inline.hpp")
72-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/memory/allStatic.hpp")
73-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/nmt/memTag.hpp")
74-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+10/src/hotspot/share/runtime/os.cpp")
75-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/runtime/os.hpp")
76-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/runtime/os.inline.hpp")
77-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/utilities/checkedCast.hpp")
78-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/utilities/compilerWarnings_gcc.hpp")
79-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/utilities/compilerWarnings.hpp")
80-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/utilities/globalDefinitions_gcc.hpp")
81-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+10/src/hotspot/share/utilities/globalDefinitions.hpp")
82-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/utilities/macros.hpp")
83-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+7/src/hotspot/share/utilities/ostream.cpp")
84-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/utilities/ostream.hpp")
53+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupSubsystem_linux.cpp")
54+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupSubsystem_linux.hpp")
55+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupUtil_linux.cpp")
56+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupUtil_linux.hpp")
57+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp")
58+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp")
59+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp")
60+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp")
61+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/osContainer_linux.cpp")
62+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/osContainer_linux.hpp")
63+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/os_linux.cpp")
64+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/os_linux.hpp")
65+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/linux/os_linux.inline.hpp")
66+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/posix/include/jvm_md.h")
67+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/posix/os_posix.cpp")
68+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/posix/os_posix.hpp")
69+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/os/posix/os_posix.inline.hpp")
70+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/memory/allocation.hpp")
71+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/memory/allocation.inline.hpp")
72+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/memory/allStatic.hpp")
73+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/nmt/memTag.hpp")
74+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/runtime/os.cpp")
75+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/runtime/os.hpp")
76+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/runtime/os.inline.hpp")
77+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/checkedCast.hpp")
78+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/compilerWarnings_gcc.hpp")
79+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/compilerWarnings.hpp")
80+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/globalDefinitions_gcc.hpp")
81+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/globalDefinitions.hpp")
82+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/macros.hpp")
83+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/ostream.cpp")
84+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/ostream.hpp")
8585
// The following annotations are for files in `src/svm`, which are completely customized for SVM
86-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/logging/log.hpp")
87-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+7/src/hotspot/share/memory/allocation.cpp")
88-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+12/src/hotspot/share/runtime/globals.hpp")
89-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+7/src/hotspot/share/utilities/debug.cpp")
90-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+6/src/hotspot/share/utilities/debug.hpp")
86+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/logging/log.hpp")
87+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/memory/allocation.cpp")
88+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/runtime/globals.hpp")
89+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/debug.cpp")
90+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/hotspot/share/utilities/debug.hpp")
9191
public class ContainerLibrary {
9292
static final int VERSION = 240100;
9393

substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsFeature.java

+31
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,44 @@ private static <S, T, U extends ResolvedJavaMethod> Map<S, U> createStubs(
422422
return created;
423423
}
424424

425+
private static final String JLI_PREFIX = "java.lang.invoke.";
426+
427+
/**
428+
* List of (generated) classes that provide accessor methods for memory segments. Those methods
429+
* are referenced with {@code java.lang.invoke.SegmentVarHandle}. Unfortunately, the classes
430+
* containing the methods are not subclasses of {@link java.lang.invoke.VarHandle} and so the
431+
* automatic registration for reflective access (see
432+
* {@link com.oracle.svm.hosted.methodhandles.MethodHandleFeature#beforeAnalysis}) does not
433+
* trigger.
434+
*/
435+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+13/src/java.base/share/classes/java/lang/invoke/VarHandles.java#L313-L344") //
436+
private static final List<String> VAR_HANDLE_SEGMENT_ACCESSORS = List.of(
437+
"VarHandleSegmentAsBooleans",
438+
"VarHandleSegmentAsBytes",
439+
"VarHandleSegmentAsShorts",
440+
"VarHandleSegmentAsChars",
441+
"VarHandleSegmentAsInts",
442+
"VarHandleSegmentAsLongs",
443+
"VarHandleSegmentAsFloats",
444+
"VarHandleSegmentAsDoubles");
445+
446+
private static void registerVarHandleMethodsForReflection(FeatureAccess access, Class<?> subtype) {
447+
assert subtype.getPackage().getName().equals(JLI_PREFIX.substring(0, JLI_PREFIX.length() - 1));
448+
RuntimeReflection.register(subtype.getDeclaredMethods());
449+
}
450+
425451
@Override
426452
public void beforeAnalysis(BeforeAnalysisAccess a) {
427453
var access = (FeatureImpl.BeforeAnalysisAccessImpl) a;
428454
sealed = true;
429455

430456
AbiUtils.singleton().checkLibrarySupport();
431457

458+
for (String simpleName : VAR_HANDLE_SEGMENT_ACCESSORS) {
459+
Class<?> varHandleSegmentAsXClass = ReflectionUtil.lookupClass(JLI_PREFIX + simpleName);
460+
access.registerSubtypeReachabilityHandler(ForeignFunctionsFeature::registerVarHandleMethodsForReflection, varHandleSegmentAsXClass);
461+
}
462+
432463
/*
433464
* Specializing an adapter would define a new class at runtime, which is not allowed in
434465
* SubstrateVM

substratevm/src/com.oracle.svm.native.libcontainer/src/hotspot/os/linux/cgroupUtil_linux.cpp

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2024, 2024, Red Hat Inc. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2024, 2025, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -54,20 +54,27 @@ int CgroupUtil::processor_count(CgroupCpuController* cpu_ctrl, int host_cpus) {
5454
}
5555

5656
void CgroupUtil::adjust_controller(CgroupMemoryController* mem) {
57+
assert(mem->cgroup_path() != nullptr, "invariant");
58+
if (strstr(mem->cgroup_path(), "../") != nullptr) {
59+
log_warning(os, container)("Cgroup memory controller path at '%s' seems to have moved to '%s', detected limits won't be accurate",
60+
mem->mount_point(), mem->cgroup_path());
61+
mem->set_subsystem_path("/");
62+
return;
63+
}
5764
if (!mem->needs_hierarchy_adjustment()) {
5865
// nothing to do
5966
return;
6067
}
6168
log_trace(os, container)("Adjusting controller path for memory: %s", mem->subsystem_path());
62-
assert(mem->cgroup_path() != nullptr, "invariant");
6369
char* orig = os::strdup(mem->cgroup_path());
6470
char* cg_path = os::strdup(orig);
6571
char* last_slash;
6672
assert(cg_path[0] == '/', "cgroup path must start with '/'");
6773
julong phys_mem = os::Linux::physical_memory();
6874
char* limit_cg_path = nullptr;
6975
jlong limit = mem->read_memory_limit_in_bytes(phys_mem);
70-
jlong lowest_limit = phys_mem;
76+
jlong lowest_limit = limit < 0 ? phys_mem : limit;
77+
julong orig_limit = ((julong)lowest_limit) != phys_mem ? lowest_limit : phys_mem;
7178
while ((last_slash = strrchr(cg_path, '/')) != cg_path) {
7279
*last_slash = '\0'; // strip path
7380
// update to shortened path and try again
@@ -88,7 +95,7 @@ void CgroupUtil::adjust_controller(CgroupMemoryController* mem) {
8895
limit_cg_path = os::strdup("/");
8996
}
9097
assert(lowest_limit >= 0, "limit must be positive");
91-
if ((julong)lowest_limit != phys_mem) {
98+
if ((julong)lowest_limit != orig_limit) {
9299
// we've found a lower limit anywhere in the hierarchy,
93100
// set the path to the limit path
94101
assert(limit_cg_path != nullptr, "limit path must be set");
@@ -98,6 +105,7 @@ void CgroupUtil::adjust_controller(CgroupMemoryController* mem) {
98105
mem->subsystem_path(),
99106
lowest_limit);
100107
} else {
108+
log_trace(os, container)("Lowest limit was: " JLONG_FORMAT, lowest_limit);
101109
log_trace(os, container)("No lower limit found for memory in hierarchy %s, "
102110
"adjusting to original path %s",
103111
mem->mount_point(), orig);
@@ -109,19 +117,26 @@ void CgroupUtil::adjust_controller(CgroupMemoryController* mem) {
109117
}
110118

111119
void CgroupUtil::adjust_controller(CgroupCpuController* cpu) {
120+
assert(cpu->cgroup_path() != nullptr, "invariant");
121+
if (strstr(cpu->cgroup_path(), "../") != nullptr) {
122+
log_warning(os, container)("Cgroup cpu controller path at '%s' seems to have moved to '%s', detected limits won't be accurate",
123+
cpu->mount_point(), cpu->cgroup_path());
124+
cpu->set_subsystem_path("/");
125+
return;
126+
}
112127
if (!cpu->needs_hierarchy_adjustment()) {
113128
// nothing to do
114129
return;
115130
}
116131
log_trace(os, container)("Adjusting controller path for cpu: %s", cpu->subsystem_path());
117-
assert(cpu->cgroup_path() != nullptr, "invariant");
118132
char* orig = os::strdup(cpu->cgroup_path());
119133
char* cg_path = os::strdup(orig);
120134
char* last_slash;
121135
assert(cg_path[0] == '/', "cgroup path must start with '/'");
122136
int host_cpus = os::Linux::active_processor_count();
123137
int cpus = CgroupUtil::processor_count(cpu, host_cpus);
124-
int lowest_limit = host_cpus;
138+
int lowest_limit = cpus < host_cpus ? cpus: host_cpus;
139+
int orig_limit = lowest_limit != host_cpus ? lowest_limit : host_cpus;
125140
char* limit_cg_path = nullptr;
126141
while ((last_slash = strrchr(cg_path, '/')) != cg_path) {
127142
*last_slash = '\0'; // strip path
@@ -143,7 +158,7 @@ void CgroupUtil::adjust_controller(CgroupCpuController* cpu) {
143158
limit_cg_path = os::strdup(cg_path);
144159
}
145160
assert(lowest_limit >= 0, "limit must be positive");
146-
if (lowest_limit != host_cpus) {
161+
if (lowest_limit != orig_limit) {
147162
// we've found a lower limit anywhere in the hierarchy,
148163
// set the path to the limit path
149164
assert(limit_cg_path != nullptr, "limit path must be set");
@@ -153,6 +168,7 @@ void CgroupUtil::adjust_controller(CgroupCpuController* cpu) {
153168
cpu->subsystem_path(),
154169
lowest_limit);
155170
} else {
171+
log_trace(os, container)("Lowest limit was: %d", lowest_limit);
156172
log_trace(os, container)("No lower limit found for cpu in hierarchy %s, "
157173
"adjusting to original path %s",
158174
cpu->mount_point(), orig);

0 commit comments

Comments
 (0)