Skip to content

Commit c0ae141

Browse files
committed
8275735: [linux] Remove deprecated Metrics api (kernel memory limit)
Reviewed-by: sgehwolf Backport-of: 6dbd5a68c7c1e8f433c3e1c9a0e0746f8d9d730f
1 parent 5898945 commit c0ae141

File tree

6 files changed

+4
-95
lines changed

6 files changed

+4
-95
lines changed

src/java.base/linux/classes/jdk/internal/platform/CgroupV1Metrics.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ public interface CgroupV1Metrics extends Metrics {
5353
*/
5454
public long getKernelMemoryFailCount();
5555

56-
/**
57-
* Returns the maximum amount of kernel physical memory, in bytes, that
58-
* can be allocated in the Isolation Group.
59-
*
60-
* @return The maximum amount of memory in bytes or -1 if
61-
* there is no limit set.
62-
*
63-
*/
64-
public long getKernelMemoryLimit();
65-
6656
/**
6757
* Returns the largest amount of kernel physical memory, in bytes, that
6858
* have been allocated in the Isolation Group.
@@ -93,16 +83,6 @@ public interface CgroupV1Metrics extends Metrics {
9383
*/
9484
public long getTcpMemoryFailCount();
9585

96-
/**
97-
* Returns the maximum amount of networking physical memory, in bytes,
98-
* that can be allocated in the Isolation Group.
99-
*
100-
* @return The maximum amount of memory in bytes or -1 if
101-
* there is no limit.
102-
*
103-
*/
104-
public long getTcpMemoryLimit();
105-
10686
/**
10787
* Returns the largest amount of networking physical memory, in bytes,
10888
* that have been allocated in the Isolation Group.

src/java.base/linux/classes/jdk/internal/platform/CgroupV1MetricsImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ public long getKernelMemoryFailCount() {
4848
return metrics.getKernelMemoryFailCount();
4949
}
5050

51-
@Override
52-
public long getKernelMemoryLimit() {
53-
return metrics.getKernelMemoryLimit();
54-
}
55-
5651
@Override
5752
public long getKernelMemoryMaxUsage() {
5853
return metrics.getKernelMemoryMaxUsage();
@@ -68,11 +63,6 @@ public long getTcpMemoryFailCount() {
6863
return metrics.getTcpMemoryFailCount();
6964
}
7065

71-
@Override
72-
public long getTcpMemoryLimit() {
73-
return metrics.getTcpMemoryLimit();
74-
}
75-
7666
@Override
7767
public long getTcpMemoryMaxUsage() {
7868
return metrics.getTcpMemoryMaxUsage();

src/java.base/linux/classes/jdk/internal/platform/cgroupv1/CgroupV1Subsystem.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,6 @@ public long getKernelMemoryFailCount() {
333333
return getLongValue(memory, "memory.kmem.failcnt");
334334
}
335335

336-
public long getKernelMemoryLimit() {
337-
return CgroupV1SubsystemController.longValOrUnlimited(getLongValue(memory, "memory.kmem.limit_in_bytes"));
338-
}
339-
340336
public long getKernelMemoryMaxUsage() {
341337
return getLongValue(memory, "memory.kmem.max_usage_in_bytes");
342338
}
@@ -349,10 +345,6 @@ public long getTcpMemoryFailCount() {
349345
return getLongValue(memory, "memory.kmem.tcp.failcnt");
350346
}
351347

352-
public long getTcpMemoryLimit() {
353-
return CgroupV1SubsystemController.longValOrUnlimited(getLongValue(memory, "memory.kmem.tcp.limit_in_bytes"));
354-
}
355-
356348
public long getTcpMemoryMaxUsage() {
357349
return getLongValue(memory, "memory.kmem.tcp.max_usage_in_bytes");
358350
}

test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ public static void main(String[] args) {
3939
case "memoryswap":
4040
testMemoryAndSwapLimit(args[1], args[2]);
4141
break;
42-
case "kernelmem":
43-
testKernelMemoryLimit(args[1]);
44-
break;
4542
case "oomkill":
4643
testOomKillFlag(Boolean.parseBoolean(args[2]));
4744
break;
@@ -119,26 +116,6 @@ private static void testMemorySoftLimit(String softLimit) {
119116
System.out.println("TEST PASSED!!!");
120117
}
121118

122-
private static void testKernelMemoryLimit(String value) {
123-
Metrics m = Metrics.systemMetrics();
124-
if (m instanceof CgroupV1Metrics) {
125-
CgroupV1Metrics mCgroupV1 = (CgroupV1Metrics)m;
126-
System.out.println("TEST PASSED!!!");
127-
long limit = getMemoryValue(value);
128-
long kmemlimit = mCgroupV1.getKernelMemoryLimit();
129-
// Note that the kernel memory limit might get ignored by OCI runtimes
130-
// This feature is deprecated. Only perform the check if we get an actual
131-
// limit back.
132-
if (kmemlimit != UNLIMITED && limit != kmemlimit) {
133-
throw new RuntimeException("Kernel Memory limit not equal, expected : ["
134-
+ limit + "]" + ", got : ["
135-
+ kmemlimit + "]");
136-
}
137-
} else {
138-
throw new RuntimeException("kernel memory limit test not supported for cgroups v2");
139-
}
140-
}
141-
142119
private static void testMemoryAndSwapLimit(String memory, String memAndSwap) {
143120
long expectedMem = getMemoryValue(memory);
144121
long expectedMemAndSwap = getMemoryValue(memAndSwap);

test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,14 @@ public static void main(String[] args) throws Exception {
6363
testMemoryAndSwapLimit("100m", "200m");
6464

6565
Metrics m = Metrics.systemMetrics();
66-
// kernel memory, '--kernel-memory' switch, and OOM killer,
67-
// '--oom-kill-disable' switch, tests not supported by cgroupv2
68-
// runtimes
66+
// OOM killer disable, '--oom-kill-disable' switch, test not supported
67+
// by cgroupv2
6968
if (m != null) {
7069
if ("cgroupv1".equals(m.getProvider())) {
71-
testKernelMemoryLimit("100m");
72-
testKernelMemoryLimit("1g");
73-
7470
testOomKillFlag("100m", false);
7571
} else {
76-
System.out.println("kernel memory tests and OOM Kill flag tests not " +
77-
"possible with cgroupv2.");
72+
System.out.println("OOM kill disable test not " +
73+
"supported with cgroupv2.");
7874
}
7975
}
8076
testOomKillFlag("100m", true);
@@ -136,18 +132,6 @@ private static void testMemoryAndSwapLimit(String memory, String memandswap) thr
136132
DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
137133
}
138134

139-
private static void testKernelMemoryLimit(String value) throws Exception {
140-
Common.logNewTestCase("testKernelMemoryLimit, value = " + value);
141-
DockerRunOptions opts =
142-
new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsMemoryTester");
143-
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
144-
.addDockerOpts("--kernel-memory=" + value)
145-
.addJavaOpts("-cp", "/test-classes/")
146-
.addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED")
147-
.addClassOptions("kernelmem", value);
148-
DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
149-
}
150-
151135
private static void testOomKillFlag(String value, boolean oomKillFlag) throws Exception {
152136
Common.logNewTestCase("testOomKillFlag, oomKillFlag = " + oomKillFlag);
153137
DockerRunOptions opts =

test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV1.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,6 @@ public void testMemorySubsystem() {
247247
fail(Controller.MEMORY, "memory.kmem.failcnt", oldVal, newVal);
248248
}
249249

250-
oldVal = metrics.getKernelMemoryLimit();
251-
newVal = getLongValueFromFile(Controller.MEMORY, "memory.kmem.limit_in_bytes");
252-
newVal = newVal > unlimited_minimum ? CgroupSubsystem.LONG_RETVAL_UNLIMITED : newVal;
253-
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
254-
fail(Controller.MEMORY, "memory.kmem.limit_in_bytes", oldVal, newVal);
255-
}
256-
257250
oldVal = metrics.getKernelMemoryMaxUsage();
258251
newVal = getLongValueFromFile(Controller.MEMORY, "memory.kmem.max_usage_in_bytes");
259252
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
@@ -273,13 +266,6 @@ public void testMemorySubsystem() {
273266
fail(Controller.MEMORY, "memory.kmem.tcp.failcnt", oldVal, newVal);
274267
}
275268

276-
oldVal = metrics.getTcpMemoryLimit();
277-
newVal = getLongValueFromFile(Controller.MEMORY, "memory.kmem.tcp.limit_in_bytes");
278-
newVal = newVal > unlimited_minimum ? CgroupSubsystem.LONG_RETVAL_UNLIMITED: newVal;
279-
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
280-
fail(Controller.MEMORY, "memory.kmem.tcp.limit_in_bytes", oldVal, newVal);
281-
}
282-
283269
oldVal = metrics.getTcpMemoryMaxUsage();
284270
newVal = getLongValueFromFile(Controller.MEMORY, "memory.kmem.tcp.max_usage_in_bytes");
285271
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {

0 commit comments

Comments
 (0)