< prev index next >
test/hotspot/jtreg/containers/docker/TestCPUAwareness.java
Print this page
@ rev 56862 : 8230305: Cgroups v2: Container awareness
| Summary: Implement Cgroups v2 container awareness in hotspot
~ Reviewed-by: bobv
o rev 56861 : 8230305: Cgroups v2: Container awareness
| Summary: Implement Cgroups v2 container awareness in hotspot
~ Reviewed-by: bobv
@@ -31,10 +31,11 @@
* java.management
* jdk.jartool/sun.tools.jar
* @run driver TestCPUAwareness
*/
import java.util.List;
+import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.containers.docker.Common;
import jdk.test.lib.containers.docker.DockerRunOptions;
import jdk.test.lib.containers.docker.DockerTestUtils;
import jdk.test.lib.containers.cgroup.CPUSetsReader;
@@ -200,10 +201,22 @@
expectedAPC = adjustExpectedAPCForAvailableCPUs(expectedAPC);
DockerRunOptions opts = Common.newOpts(imageName)
.addDockerOpts("--cpu-shares=" + shares);
- Common.run(opts)
- .shouldMatch("CPU Shares is.*" + shares)
- .shouldMatch("active_processor_count.*" + expectedAPC);
+ OutputAnalyzer out = Common.run(opts);
+ // Cgroups v2 needs to do some scaling of raw shares values. Hence,
+ // 256 CPU shares come back as 264. Raw value written to cpu.weight
+ // is 10. The reason this works for >= 1024 shares value is because
+ // post-scaling the closest multiple of 1024 is found and returned.
+ //
+ // For values < 1024, this doesn't happen so loosen the match to a
+ // 3-digit number and ensure the active_processor_count is as
+ // expected.
+ if (shares < 1024) {
+ out.shouldMatch("CPU Shares is.*\\d{3}");
+ } else {
+ out.shouldMatch("CPU Shares is.*" + shares);
+ }
+ out.shouldMatch("active_processor_count.*" + expectedAPC);
}
}
< prev index next >