Skip to content

Commit 6dbd5a6

Browse files
committed
8275735: [linux] Remove deprecated Metrics api (kernel memory limit)
Backport-of: 9971a2cab3892a17f3fd39243df5ecfff5b9f108
1 parent fc1d3d3 commit 6dbd5a6

File tree

6 files changed

+4
-104
lines changed

6 files changed

+4
-104
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 & 20 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,23 +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-
if (kmemlimit != UNLIMITED && limit != kmemlimit) {
130-
throw new RuntimeException("Kernel Memory limit not equal, expected : ["
131-
+ limit + "]" + ", got : ["
132-
+ kmemlimit + "]");
133-
}
134-
} else {
135-
throw new RuntimeException("kernel memory limit test not supported for cgroups v2");
136-
}
137-
}
138-
139119
private static void testMemoryAndSwapLimit(String memory, String memAndSwap) {
140120
long expectedMem = getMemoryValue(memory);
141121
long expectedMemAndSwap = getMemoryValue(memAndSwap);

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

Lines changed: 4 additions & 32 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);
@@ -159,30 +155,6 @@ private static void testMemoryAndSwapLimit(String memory, String memandswap) thr
159155
DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
160156
}
161157

162-
private static void testKernelMemoryLimit(String value) throws Exception {
163-
Common.logNewTestCase("testKernelMemoryLimit, value = " + value);
164-
DockerRunOptions opts =
165-
new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsMemoryTester");
166-
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
167-
.addDockerOpts("--kernel-memory=" + value)
168-
.addJavaOpts("-cp", "/test-classes/")
169-
.addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED")
170-
.addClassOptions("kernelmem", value);
171-
OutputAnalyzer oa = DockerTestUtils.dockerRunJava(opts);
172-
173-
// Some container runtimes (e.g. runc, docker 18.09)
174-
// have been built without kernel memory accounting. In
175-
// that case, the runtime issues a message on stderr saying
176-
// so. Skip the test in that case.
177-
if (oa.getStderr().contains("kernel memory accounting disabled")) {
178-
System.out.println("Kernel memory accounting disabled, " +
179-
"skipping the test case");
180-
return;
181-
}
182-
183-
oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
184-
}
185-
186158
private static void testOomKillFlag(String value, boolean oomKillFlag) throws Exception {
187159
Common.logNewTestCase("testOomKillFlag, oomKillFlag = " + oomKillFlag);
188160
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)