mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 01:24:33 +02:00
8217766: Container Support doesn't work for some Join Controllers combinations
Reviewed-by: rriggs, sgehwolf
This commit is contained in:
parent
adc6d241ba
commit
30342b596b
2 changed files with 36 additions and 107 deletions
|
@ -217,16 +217,11 @@ PRAGMA_DIAG_POP
|
|||
* we are running under cgroup control.
|
||||
*/
|
||||
void OSContainer::init() {
|
||||
int mountid;
|
||||
int parentid;
|
||||
int major;
|
||||
int minor;
|
||||
FILE *mntinfo = NULL;
|
||||
FILE *cgroup = NULL;
|
||||
char buf[MAXPATHLEN+1];
|
||||
char tmproot[MAXPATHLEN+1];
|
||||
char tmpmount[MAXPATHLEN+1];
|
||||
char tmpbase[MAXPATHLEN+1];
|
||||
char *p;
|
||||
jlong mem_limit;
|
||||
|
||||
|
@ -260,85 +255,24 @@ void OSContainer::init() {
|
|||
return;
|
||||
}
|
||||
|
||||
while ( (p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
|
||||
// Look for the filesystem type and see if it's cgroup
|
||||
char fstype[MAXPATHLEN+1];
|
||||
fstype[0] = '\0';
|
||||
char *s = strstr(p, " - ");
|
||||
if (s != NULL &&
|
||||
sscanf(s, " - %s", fstype) == 1 &&
|
||||
strcmp(fstype, "cgroup") == 0) {
|
||||
while ((p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
|
||||
char tmpcgroups[MAXPATHLEN+1];
|
||||
char *cptr = tmpcgroups;
|
||||
char *token;
|
||||
|
||||
if (strstr(p, "memory") != NULL) {
|
||||
int matched = sscanf(p, "%d %d %d:%d %s %s",
|
||||
&mountid,
|
||||
&parentid,
|
||||
&major,
|
||||
&minor,
|
||||
tmproot,
|
||||
tmpmount);
|
||||
if (matched == 6) {
|
||||
memory = new CgroupSubsystem(tmproot, tmpmount);
|
||||
}
|
||||
else
|
||||
log_debug(os, container)("Incompatible str containing cgroup and memory: %s", p);
|
||||
} else if (strstr(p, "cpuset") != NULL) {
|
||||
int matched = sscanf(p, "%d %d %d:%d %s %s",
|
||||
&mountid,
|
||||
&parentid,
|
||||
&major,
|
||||
&minor,
|
||||
tmproot,
|
||||
tmpmount);
|
||||
if (matched == 6) {
|
||||
cpuset = new CgroupSubsystem(tmproot, tmpmount);
|
||||
}
|
||||
else {
|
||||
log_debug(os, container)("Incompatible str containing cgroup and cpuset: %s", p);
|
||||
}
|
||||
} else if (strstr(p, "cpu,cpuacct") != NULL || strstr(p, "cpuacct,cpu") != NULL) {
|
||||
int matched = sscanf(p, "%d %d %d:%d %s %s",
|
||||
&mountid,
|
||||
&parentid,
|
||||
&major,
|
||||
&minor,
|
||||
tmproot,
|
||||
tmpmount);
|
||||
if (matched == 6) {
|
||||
cpu = new CgroupSubsystem(tmproot, tmpmount);
|
||||
cpuacct = new CgroupSubsystem(tmproot, tmpmount);
|
||||
}
|
||||
else {
|
||||
log_debug(os, container)("Incompatible str containing cgroup and cpu,cpuacct: %s", p);
|
||||
}
|
||||
} else if (strstr(p, "cpuacct") != NULL) {
|
||||
int matched = sscanf(p, "%d %d %d:%d %s %s",
|
||||
&mountid,
|
||||
&parentid,
|
||||
&major,
|
||||
&minor,
|
||||
tmproot,
|
||||
tmpmount);
|
||||
if (matched == 6) {
|
||||
cpuacct = new CgroupSubsystem(tmproot, tmpmount);
|
||||
}
|
||||
else {
|
||||
log_debug(os, container)("Incompatible str containing cgroup and cpuacct: %s", p);
|
||||
}
|
||||
} else if (strstr(p, "cpu") != NULL) {
|
||||
int matched = sscanf(p, "%d %d %d:%d %s %s",
|
||||
&mountid,
|
||||
&parentid,
|
||||
&major,
|
||||
&minor,
|
||||
tmproot,
|
||||
tmpmount);
|
||||
if (matched == 6) {
|
||||
cpu = new CgroupSubsystem(tmproot, tmpmount);
|
||||
}
|
||||
else {
|
||||
log_debug(os, container)("Incompatible str containing cgroup and cpu: %s", p);
|
||||
}
|
||||
// mountinfo format is documented at https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
||||
if (sscanf(p, "%*d %*d %*d:%*d %s %s %*[^-]- cgroup %*s %s", tmproot, tmpmount, tmpcgroups) != 3) {
|
||||
continue;
|
||||
}
|
||||
while ((token = strsep(&cptr, ",")) != NULL) {
|
||||
if (strcmp(token, "memory") == 0) {
|
||||
memory = new CgroupSubsystem(tmproot, tmpmount);
|
||||
} else if (strcmp(token, "cpuset") == 0) {
|
||||
cpuset = new CgroupSubsystem(tmproot, tmpmount);
|
||||
} else if (strcmp(token, "cpu") == 0) {
|
||||
cpu = new CgroupSubsystem(tmproot, tmpmount);
|
||||
} else if (strcmp(token, "cpuacct") == 0) {
|
||||
cpuacct= new CgroupSubsystem(tmproot, tmpmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -392,30 +326,30 @@ void OSContainer::init() {
|
|||
return;
|
||||
}
|
||||
|
||||
while ( (p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
|
||||
int cgno;
|
||||
int matched;
|
||||
char *controller;
|
||||
while ((p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
|
||||
char *controllers;
|
||||
char *token;
|
||||
char *base;
|
||||
|
||||
/* Skip cgroup number */
|
||||
strsep(&p, ":");
|
||||
/* Get controller and base */
|
||||
controller = strsep(&p, ":");
|
||||
/* Get controllers and base */
|
||||
controllers = strsep(&p, ":");
|
||||
base = strsep(&p, "\n");
|
||||
|
||||
if (controller != NULL) {
|
||||
if (strstr(controller, "memory") != NULL) {
|
||||
if (controllers == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while ((token = strsep(&controllers, ",")) != NULL) {
|
||||
if (strcmp(token, "memory") == 0) {
|
||||
memory->set_subsystem_path(base);
|
||||
} else if (strstr(controller, "cpuset") != NULL) {
|
||||
} else if (strcmp(token, "cpuset") == 0) {
|
||||
cpuset->set_subsystem_path(base);
|
||||
} else if (strstr(controller, "cpu,cpuacct") != NULL || strstr(controller, "cpuacct,cpu") != NULL) {
|
||||
} else if (strcmp(token, "cpu") == 0) {
|
||||
cpu->set_subsystem_path(base);
|
||||
} else if (strcmp(token, "cpuacct") == 0) {
|
||||
cpuacct->set_subsystem_path(base);
|
||||
} else if (strstr(controller, "cpuacct") != NULL) {
|
||||
cpuacct->set_subsystem_path(base);
|
||||
} else if (strstr(controller, "cpu") != NULL) {
|
||||
cpu->set_subsystem_path(base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue