8254854: [cgroups v1] Metric limits not properly detected on some join controller combinations

Reviewed-by: bobv
This commit is contained in:
Severin Gehwolf 2020-10-22 16:36:29 +00:00
parent f279ddfa06
commit a0b687bfb2

View File

@ -158,41 +158,37 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
* setSubSystemPath based on the contents of /proc/self/cgroup
*/
private static void setSubSystemControllerPath(CgroupV1Subsystem subsystem, String[] entry) {
String controllerName;
String base;
CgroupV1SubsystemController controller = null;
CgroupV1SubsystemController controller2 = null;
String controllerName = entry[1];
String base = entry[2];
controllerName = entry[1];
base = entry[2];
if (controllerName != null && base != null) {
switch (controllerName) {
case "memory":
controller = subsystem.memoryController();
break;
case "cpuset":
controller = subsystem.cpuSetController();
break;
case "cpu,cpuacct":
case "cpuacct,cpu":
controller = subsystem.cpuController();
controller2 = subsystem.cpuAcctController();
break;
case "cpuacct":
controller = subsystem.cpuAcctController();
break;
case "cpu":
controller = subsystem.cpuController();
break;
case "blkio":
controller = subsystem.blkIOController();
break;
// Ignore subsystems that we don't support
default:
break;
for (String cName: controllerName.split(",")) {
switch (cName) {
case "memory":
setPath(subsystem, subsystem.memoryController(), base);
break;
case "cpuset":
setPath(subsystem, subsystem.cpuSetController(), base);
break;
case "cpu":
setPath(subsystem, subsystem.cpuController(), base);
break;
case "cpuacct":
setPath(subsystem, subsystem.cpuAcctController(), base);
break;
case "blkio":
setPath(subsystem, subsystem.blkIOController(), base);
break;
// Ignore subsystems that we don't support
default:
break;
}
}
}
}
private static void setPath(CgroupV1Subsystem subsystem, CgroupV1SubsystemController controller, String base) {
if (controller != null) {
controller.setPath(base);
if (controller instanceof CgroupV1MemorySubSystemController) {
@ -204,9 +200,6 @@ public class CgroupV1Subsystem implements CgroupSubsystem, CgroupV1Metrics {
}
subsystem.setActiveSubSystems();
}
if (controller2 != null) {
controller2.setPath(base);
}
}