Skip to content

Commit 9971a2c

Browse files
committed
8275735: [linux] Remove deprecated Metrics api (kernel memory limit)
Reviewed-by: hseigel, mchung
1 parent b7a06be commit 9971a2c

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
@@ -332,10 +332,6 @@ public long getKernelMemoryFailCount() {
332332
return getLongValue(memory, "memory.kmem.failcnt");
333333
}
334334

335-
public long getKernelMemoryLimit() {
336-
return CgroupV1SubsystemController.longValOrUnlimited(getLongValue(memory, "memory.kmem.limit_in_bytes"));
337-
}
338-
339335
public long getKernelMemoryMaxUsage() {
340336
return getLongValue(memory, "memory.kmem.max_usage_in_bytes");
341337
}
@@ -348,10 +344,6 @@ public long getTcpMemoryFailCount() {
348344
return getLongValue(memory, "memory.kmem.tcp.failcnt");
349345
}
350346

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

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
@@ -61,18 +61,14 @@ public static void main(String[] args) throws Exception {
6161
testMemoryAndSwapLimit("100m", "200m");
6262

6363
Metrics m = Metrics.systemMetrics();
64-
// kernel memory, '--kernel-memory' switch, and OOM killer,
65-
// '--oom-kill-disable' switch, tests not supported by cgroupv2
66-
// runtimes
64+
// OOM killer disable, '--oom-kill-disable' switch, test not supported
65+
// by cgroupv2
6766
if (m != null) {
6867
if ("cgroupv1".equals(m.getProvider())) {
69-
testKernelMemoryLimit("100m");
70-
testKernelMemoryLimit("1g");
71-
7268
testOomKillFlag("100m", false);
7369
} else {
74-
System.out.println("kernel memory tests and OOM Kill flag tests not " +
75-
"possible with cgroupv2.");
70+
System.out.println("OOM kill disable test not " +
71+
"supported with cgroupv2.");
7672
}
7773
}
7874
testOomKillFlag("100m", true);
@@ -149,30 +145,6 @@ private static void testMemoryAndSwapLimit(String memory, String memandswap) thr
149145
DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
150146
}
151147

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