-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 15
-
b20
-
generic
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8257748 | 13.0.6 | Ekaterina Vergizova | P4 | Resolved | Fixed | b02 |
JDK-8253780 | 11.0.10-oracle | Jie Fu | P4 | Resolved | Fixed | b01 |
JDK-8253984 | 11.0.10 | Jie Fu | P4 | Resolved | Fixed | b01 |
JDK-8257478 | openjdk8u282 | Severin Gehwolf | P4 | Resolved | Fixed | b04 |
JDK-8254031 | 8u281 | Harold Seigel | P4 | Resolved | Fixed | b01 |
JDK-8257282 | emb-8u281 | Harold Seigel | P4 | Resolved | Fixed | team |
The reason is that current implementation doesn't consider the situation when memory.limit_in_bytes == memory.memsw.limit_in_bytes, which means do not use the swap space at all.
In src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java, let's see
------------------------------------------------
71 public long getFreeSwapSpaceSize() {
72 if (containerMetrics != null) {
73 long memSwapLimit = containerMetrics.getMemoryAndSwapLimit();
74 long memLimit = containerMetrics.getMemoryLimit();
75 if (memSwapLimit >= 0 && memLimit >= 0) {
76 for (int attempt = 0; attempt < MAX_ATTEMPTS_NUMBER; attempt++) {
77 long memSwapUsage = containerMetrics.getMemoryAndSwapUsage();
78 long memUsage = containerMetrics.getMemoryUsage();
79 if (memSwapUsage > 0 && memUsage > 0) {
80 // We read "memory usage" and "memory and swap usage" not atomically,
81 // and it's possible to get the negative value when subtracting these two.
82 // If this happens just retry the loop for a few iterations.
83 if ((memSwapUsage - memUsage) >= 0) {
84 return memSwapLimit - memLimit - (memSwapUsage - memUsage);
85 }
86 }
87 }
88 }
89 }
90 return getFreeSwapSpaceSize0();
91 }
------------------------------------------------
If memSwapLimit (@line 73) equals memLimit (@line 74), then getFreeSwapSpaceSize() may return a negative value @line 84.
- backported by
-
JDK-8253780 Negative value may be returned by getFreeSwapSpaceSize() in the docker
- Resolved
-
JDK-8253984 Negative value may be returned by getFreeSwapSpaceSize() in the docker
- Resolved
-
JDK-8254031 Negative value may be returned by getFreeSwapSpaceSize() in the docker
- Resolved
-
JDK-8257282 Negative value may be returned by getFreeSwapSpaceSize() in the docker
- Resolved
-
JDK-8257478 Negative value may be returned by getFreeSwapSpaceSize() in the docker
- Resolved
-
JDK-8257748 Negative value may be returned by getFreeSwapSpaceSize() in the docker
- Resolved
- relates to
-
JDK-8246648 issue with OperatingSystemImpl getFreeSwapSpaceSize in docker after 8242480
- Resolved
-
JDK-8257397 [TESTBUG] test/lib/containers/docker/Common.java refers to -Xlog:os+container=trace
- Resolved
-
JDK-8244500 jtreg test error in test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java
- Resolved
-
JDK-8283279 [Testbug] Improve TestGetSwapSpaceSize
- Resolved
-
JDK-8226575 OperatingSystemMXBean should be made container aware
- Resolved