JDK-8247863 : Unreachable code in OperatingSystemImpl.getTotalSwapSpaceSize()
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 15,16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2020-06-18
  • Updated: 2020-08-06
  • Resolved: 2020-07-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b09Fixed
Related Reports
Relates :  
Relates :  
Description
During review of JDK-8244500 it was discovered that with the new cgroups implementation supporting v1 and v2 Metrics.getMemoryAndSwapLimit() will never return 0 when relevant cgroup files are missing. E.g. on a system where the kernel doesn't support swap limit capabilities. Therefore this code introduced with JDK-8236617 can no longer be reached and should get removed:

             if (limit >= 0 && memLimit >= 0) {
-                return limit - memLimit;
+                // we see a limit == 0 on some machines where "kernel does not support swap limit capabilities"
+                return (limit < memLimit) ? 0 : limit - memLimit;
             }

More details here:
http://mail.openjdk.java.net/pipermail/hotspot-dev/2020-June/042167.html
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/8f7ede592c28 User: sgehwolf Date: 2020-07-30 12:17:29 +0000
30-07-2020

Candidate webrev to be pushed after JDK-8244500 lands: https://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8247863/01/webrev/ RFR: http://mail.openjdk.java.net/pipermail/serviceability-dev/2020-June/032090.html
29-06-2020

podman/docker do not allow --memory-swap option to be less than --memory. Thus, in the new scheme where -1 is returned for Metrics which have files missing we have: iff "limit >= 0 && memLimit >= 0", "limit - memLimit >= 0".
19-06-2020