Skip to content

Commit 10223db

Browse files
christianhaeublzapster
authored andcommitted
[GR-51479] Implement cgroup support in native code.
PullRequest: graal/17421
2 parents 600fda8 + 1bea0be commit 10223db

File tree

64 files changed

+22132
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+22132
-284
lines changed

sdk/mx.sdk/suite.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,10 +1382,24 @@ class UniversalDetector {
13821382
"toolchain.cmake" : {
13831383
"source_type": "string",
13841384
"value": '''
1385-
set(CMAKE_SYSTEM_NAME Linux)
13861385
set(CMAKE_C_COMPILER <path:MUSL_GCC_TOOLCHAIN>/x86_64-linux-musl-native/bin/gcc)
13871386
set(CMAKE_CXX_COMPILER <path:MUSL_GCC_TOOLCHAIN>/x86_64-linux-musl-native/bin/g++)
13881387
set(CMAKE_AR <path:MUSL_GCC_TOOLCHAIN>/x86_64-linux-musl-native/bin/ar)
1388+
'''
1389+
},
1390+
},
1391+
"dependencies": [
1392+
"MUSL_GCC_TOOLCHAIN",
1393+
],
1394+
},
1395+
"aarch64": {
1396+
"layout" : {
1397+
"toolchain.cmake" : {
1398+
"source_type": "string",
1399+
"value": '''
1400+
set(CMAKE_C_COMPILER <path:MUSL_GCC_TOOLCHAIN>/aarch64-linux-musl-native/bin/gcc)
1401+
set(CMAKE_CXX_COMPILER <path:MUSL_GCC_TOOLCHAIN>/aarch64-linux-musl-native/bin/g++)
1402+
set(CMAKE_AR <path:MUSL_GCC_TOOLCHAIN>/aarch64-linux-musl-native/bin/ar)
13891403
'''
13901404
},
13911405
},

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This changelog summarizes major changes to GraalVM Native Image.
3333
* (GR-52844) Add `-Os`, a new optimization mode to configure the optimizer in a way to get the smallest code size.
3434
* (GR-49770) Add support for glob patterns in resource-config files in addition to regexp. The Tracing agent now prints entries in the glob format.
3535
* (GR-46386) Throw missing registration errors for JNI queries when the query was not included in the reachability metadata.
36+
* (GR-51479) Implement cgroup support in native code. See the [README](src/com.oracle.svm.native.libcontainer/README.md) and the [PR description](https://github.com/oracle/graal/pull/8989).
3637

3738
## GraalVM for JDK 22 (Internal Version 24.0.0)
3839
* (GR-48304) Red Hat added support for the JFR event ThreadAllocationStatistics.

substratevm/ci/ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
local t(limit) = task_spec({timelimit: limit}),
1717

1818
// mx gate build config
19-
local mxgate(tags) = os_arch_jdk_mixin + sg.mxgate(tags, suite="substratevm", suite_short="svm"),
19+
local mxgate(tags) = os_arch_jdk_mixin + sg.mxgate(tags, suite="substratevm", suite_short="svm") + task_spec(common.deps.svm),
2020

2121
local eclipse = task_spec(common.deps.eclipse),
2222
local jdt = task_spec(common.deps.jdt),

substratevm/mx.substratevm/suite.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,52 @@
850850
"jacoco" : "exclude",
851851
},
852852

853+
"com.oracle.svm.native.libcontainer": {
854+
"subDir": "src",
855+
"native": "static_lib",
856+
"multitarget": {
857+
"libc": ["glibc", "musl", "default"],
858+
},
859+
"deliverable" : "svm_container",
860+
"os_arch": {
861+
"linux": {
862+
"<others>": {
863+
"cflags": ["-O2", "-fno-rtti", "-fno-exceptions", "-fvisibility=hidden", "-fPIC",
864+
# defines
865+
"-DNATIVE_IMAGE", "-DLINUX", "-DINCLUDE_SUFFIX_COMPILER=_gcc",
866+
# uncomment to enable debugging
867+
# Note: -O0 might run into linker error because it does not purge unused symbols,
868+
# e.g., '__cxa_pure_virtual'. -O1 or higher avoids the problem.
869+
# "-DASSERT", "-DPRINT_WARNINGS", "-g", "-O1", "-DLOG_LEVEL=6",
870+
# include dirs
871+
"-I<path:com.oracle.svm.native.libcontainer>/src/java.base/share/native/include",
872+
"-I<path:com.oracle.svm.native.libcontainer>/src/java.base/unix/native/include",
873+
"-I<path:com.oracle.svm.native.libcontainer>/src/hotspot",
874+
"-I<path:com.oracle.svm.native.libcontainer>/src/hotspot/share",
875+
"-I<path:com.oracle.svm.native.libcontainer>/src/hotspot/os/linux",
876+
"-I<path:com.oracle.svm.native.libcontainer>/src/hotspot/os/posix",
877+
"-I<path:com.oracle.svm.native.libcontainer>/src/hotspot/os/posix/include",
878+
"-I<path:com.oracle.svm.native.libcontainer>/src/svm",
879+
"-I<path:com.oracle.svm.native.libcontainer>/src/svm/share",
880+
# HotSpot standard flags
881+
# See https://github.com/openjdk/jdk/blob/master/make/autoconf/flags-cflags.m4
882+
# C++ standard
883+
"-std=c++14",
884+
# Always enable optional macros
885+
"-D__STDC_FORMAT_MACROS", "-D__STDC_LIMIT_MACROS", "-D__STDC_CONSTANT_MACROS",
886+
],
887+
"ldflags": ["-Wl,-z,noexecstack"],
888+
},
889+
},
890+
"<others>": {
891+
"<others>": {
892+
"ignore": "only needed on linux",
893+
},
894+
},
895+
},
896+
"jacoco" : "exclude",
897+
},
898+
853899
"svm-jvmfuncs-fallback-builder": {
854900
"class" : "SubstrateJvmFuncsFallbacksBuilder",
855901
},
@@ -1798,6 +1844,7 @@
17981844
"./": [
17991845
"dependency:com.oracle.svm.native.libchelper/*",
18001846
"dependency:com.oracle.svm.native.jvm.posix/*",
1847+
"dependency:com.oracle.svm.native.libcontainer/*",
18011848
],
18021849
},
18031850
},

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import com.oracle.svm.core.heap.NoAllocationVerifier;
6060
import com.oracle.svm.core.heap.ObjectHeader;
6161
import com.oracle.svm.core.heap.ObjectVisitor;
62-
import com.oracle.svm.core.heap.PhysicalMemory;
6362
import com.oracle.svm.core.heap.ReferenceHandler;
6463
import com.oracle.svm.core.heap.ReferenceHandlerThread;
6564
import com.oracle.svm.core.heap.ReferenceInternals;
@@ -904,7 +903,6 @@ private long totalMemory() {
904903

905904
@Substitute
906905
private long maxMemory() {
907-
PhysicalMemory.size(); // ensure physical memory size is set correctly and not estimated
908906
GCImpl.getPolicy().updateSizeParameters();
909907
return GCImpl.getPolicy().getMaximumHeapSize().rawValue();
910908
}

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapParameters.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*/
2525
package com.oracle.svm.core.genscavenge;
2626

27-
import jdk.graal.compiler.api.replacements.Fold;
28-
import jdk.graal.compiler.word.Word;
2927
import org.graalvm.nativeimage.Platform;
3028
import org.graalvm.nativeimage.Platforms;
3129
import org.graalvm.word.UnsignedWord;
@@ -38,6 +36,9 @@
3836
import com.oracle.svm.core.util.UserError;
3937
import com.oracle.svm.core.util.VMError;
4038

39+
import jdk.graal.compiler.api.replacements.Fold;
40+
import jdk.graal.compiler.word.Word;
41+
4142
/** Constants and variables for the size and layout of the heap and behavior of the collector. */
4243
public final class HeapParameters {
4344
@Platforms(Platform.HOSTED_ONLY.class)
@@ -87,6 +88,13 @@ public static int getMaxSurvivorSpaces() {
8788
* Memory configuration
8889
*/
8990

91+
/**
92+
* Sets the {@link SubstrateGCOptions#MaxHeapSize} option value.
93+
*
94+
* Note that the value is used during VM initialization and stored in various places in the JDK
95+
* in direct or derived form. These usages will <strong>not be updated!</strong> Thus, changing
96+
* the maximum heap size at runtime is not recommended.
97+
*/
9098
public static void setMaximumHeapSize(UnsignedWord value) {
9199
SubstrateGCOptions.MaxHeapSize.update(value.rawValue());
92100
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import com.oracle.svm.core.util.VMError;
4141

4242
@AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class)
43-
class PhysicalMemorySupportImpl implements PhysicalMemorySupport {
43+
class DarwinPhysicalMemorySupportImpl implements PhysicalMemorySupport {
4444

4545
@Override
4646
public UnsignedWord size() {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Containers.java

Lines changed: 0 additions & 131 deletions
This file was deleted.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Processor.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)