RFR: 8217338: [Containers] Improve systemd slice memory limit support

Bob Vandette bob.vandette at oracle.com
Fri Mar 22 18:25:50 UTC 2019


Is there ever a situation where the memory.limit_in_bytes could be unlimited but the
hierarchical_memory_limit is not?

Could you maybe combine subsystem_file_contents with subsystem_file_line_contents
by adding an additional argument?



BTW:  I found another problem with the mountinfo/cgroup parsing that impacts the
container tests.

I don’t know why it only caused a failure on one of my systems.  I’m going to
file another bug.  You might want to test with these changes to make sure
your looking at the correct subsystem files.


diff --git a/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java b/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java
--- a/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java
+++ b/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java
@@ -60,7 +60,7 @@
                     path = mountPoint;
                 }
                 else {
-                    if (root.indexOf(cgroupPath) == 0) {
+                    if (cgroupPath.indexOf(root) == 0) {
                         if (cgroupPath.length() > root.length()) {
                             String cgroupSubstr = cgroupPath.substring(root.length());
                             path = mountPoint + cgroupSubstr;
diff --git a/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java b/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java
--- a/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java
+++ b/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java
@@ -85,7 +85,7 @@
                 String mountPoint = paths[1];
                 if (root != null && cgroupPath != null) {
                     if (root.equals("/")) {
-                        if (cgroupPath.equals("/")) {
+                        if (!cgroupPath.equals("/")) {
                             finalPath = mountPoint + cgroupPath;
                         } else {
                             finalPath = mountPoint;
@@ -94,7 +94,7 @@
                         if (root.equals(cgroupPath)) {
                             finalPath = mountPoint;
                         } else {
-                            if (root.indexOf(cgroupPath) == 0) {
+                            if (cgroupPath.indexOf(root) == 0) {
                                 if (cgroupPath.length() > root.length()) {
                                     String cgroupSubstr = cgroupPath.substring(root.length());
                                     finalPath = mountPoint + cgroupSubstr;
@@ -103,7 +103,7 @@
                         }
                     }
                 }
-                subSystemPaths.put(subSystem, new String[]{finalPath});
+                subSystemPaths.put(subSystem, new String[]{finalPath, mountPoint});
             }
         }
     }


Bob.



> On Mar 22, 2019, at 6:43 AM, Severin Gehwolf <sgehwolf at redhat.com> wrote:
> 
> Hi,
> 
> Please review this change which improves container detection support
> tin the JVM. While docker container detection works quite well the
> results for systemd slices with memory limits are mixed and depend on
> the Linux kernel version in use. With newer kernel versions becoming
> more widely used we should improve JVMs memory limit detection support
> as well. This should be entirely backwards compatible as the
> hierarchical limit will only be used if everything else is unlimited.
> 
> Bug: https://bugs.openjdk.java.net/browse/JDK-8217338
> webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8217338/04/webrev/
> 
> Testing: Manual testing of -XshowSettings and -Xlog:os+container=trace
> with systemd slices on affected Linux distributions: Fedora 29,
> recent Ubuntu (18-10). Existing docker tests pass. I'm currently also
> running this through jdk/submit.
> 
> Thoughts?
> 
> Thanks,
> Severin
> 



More information about the core-libs-dev mailing list