|
Lines 178-188
static char *_get_relative_cg_path(const char *pid)
Link Here
|
| 178 |
static char *_get_self_cg_path() |
178 |
static char *_get_self_cg_path() |
| 179 |
{ |
179 |
{ |
| 180 |
char *buf, *start = NULL, *p, *ret = NULL; |
180 |
char *buf, *start = NULL, *p, *ret = NULL; |
| 181 |
size_t sz; |
181 |
char *relative_cg_path = NULL; |
|
|
182 |
size_t sz, relative_cg_len; |
| 182 |
|
183 |
|
| 183 |
if (common_file_read_content("/proc/self/cgroup", &buf, &sz) != |
184 |
if (common_file_read_content("/proc/self/cgroup", &buf, &sz) != |
| 184 |
SLURM_SUCCESS) |
185 |
SLURM_SUCCESS) |
| 185 |
fatal("cannot read /proc/self/cgroup contents: %m"); |
186 |
fatal("cannot read /proc/self/cgroup contents: %m"); |
|
|
187 |
debug4("Self cgroup data is %s.", buf); |
| 186 |
|
188 |
|
| 187 |
/* |
189 |
/* |
| 188 |
* In Unified mode there will be just one line containing the path |
190 |
* In Unified mode there will be just one line containing the path |
|
Lines 196-201
static char *_get_self_cg_path()
Link Here
|
| 196 |
* If we have multiple slurmd, we will likely have one unit file per |
198 |
* If we have multiple slurmd, we will likely have one unit file per |
| 197 |
* node, and the path takes the name of the service file, e.g: |
199 |
* node, and the path takes the name of the service file, e.g: |
| 198 |
* /sys/fs/cgroup/system.slice/slurmd-<nodename>.service/ |
200 |
* /sys/fs/cgroup/system.slice/slurmd-<nodename>.service/ |
|
|
201 |
* |
| 202 |
* If the cgroup path contains .. then cgroup namespaces are |
| 203 |
* in use. In this case remove the relative path to the root |
| 204 |
* of the cgroup namespace from our path. |
| 199 |
*/ |
205 |
*/ |
| 200 |
if ((p = xstrchr(buf, ':'))) { |
206 |
if ((p = xstrchr(buf, ':'))) { |
| 201 |
if ((p + 2) < (buf + sz - 1)) |
207 |
if ((p + 2) < (buf + sz - 1)) |
|
Lines 205-212
static char *_get_self_cg_path()
Link Here
|
| 205 |
if (start && (*start != '\0')) { |
211 |
if (start && (*start != '\0')) { |
| 206 |
if ((p = xstrchr(start, '\n'))) |
212 |
if ((p = xstrchr(start, '\n'))) |
| 207 |
*p = '\0'; |
213 |
*p = '\0'; |
| 208 |
xstrfmtcat(ret, "%s%s", |
214 |
debug3("Found self cgroup path %s.", start); |
| 209 |
slurm_cgroup_conf.cgroup_mountpoint, start); |
215 |
if (xstrstr(start, "..")) { |
|
|
216 |
debug3("Relative path to cgroup namespace root found; removing the relative path prefix."); |
| 217 |
relative_cg_path = _get_relative_cg_path("self"); |
| 218 |
if (xstrstr(start, relative_cg_path)) { |
| 219 |
relative_cg_len = strlen(relative_cg_path); |
| 220 |
xstrfmtcat(ret, "%s%s", |
| 221 |
slurm_cgroup_conf.cgroup_mountpoint, |
| 222 |
start + relative_cg_len); |
| 223 |
debug2("Using %s as my cgroup path.", ret); |
| 224 |
} else { |
| 225 |
error("Did not find relative path to cgroup namespace root prefix %s in self cgroup path %s.", |
| 226 |
relative_cg_path, start); |
| 227 |
} |
| 228 |
xfree(relative_cg_path); |
| 229 |
} else { |
| 230 |
debug2("Using constructed cgroup path %s + %s.", slurm_cgroup_conf.cgroup_mountpoint, start); |
| 231 |
xstrfmtcat(ret, "%s%s", |
| 232 |
slurm_cgroup_conf.cgroup_mountpoint, start); |
| 233 |
} |
| 210 |
} |
234 |
} |
| 211 |
|
235 |
|
| 212 |
xfree(buf); |
236 |
xfree(buf); |
| 213 |
- |
|
|
| 214 |
-- |
| 215 |
src/plugins/cgroup/v2/cgroup_v2.c | 31 ++++++++++++++++++++++++++++--- |
237 |
src/plugins/cgroup/v2/cgroup_v2.c | 31 ++++++++++++++++++++++++++++--- |
| 216 |
1 file changed, 28 insertions(+), 3 deletions(-) |
238 |
1 file changed, 28 insertions(+), 3 deletions(-) |