diff --git a/src/common/xcgroup.c b/src/common/xcgroup.c index 8cc8b6376d2ddd9a364f3e23b5469314c86549c1..64e0af11ca598fef0c47eafea903ca9d3adcc88d 100644 --- a/src/common/xcgroup.c +++ b/src/common/xcgroup.c @@ -93,10 +93,13 @@ int _file_write_content(char* file_path, char* content, size_t csize); * - XCGROUP_ERROR * - XCGROUP_SUCCESS */ -int xcgroup_ns_create(xcgroup_ns_t* cgns, char* mnt_point, char* mnt_args, +int xcgroup_ns_create(slurm_cgroup_conf_t *conf, + xcgroup_ns_t* cgns, char* mnt_point, char* mnt_args, char* subsys, char* notify_prog) { - cgns->mnt_point = xstrdup(mnt_point); + cgns->mnt_point = xstrdup(conf->cgroup_mountpoint); + xstrcat(cgns->mnt_point, mnt_point); + cgns->mnt_args = xstrdup(mnt_args); cgns->subsystems = xstrdup(subsys); cgns->notify_prog = xstrdup(notify_prog); diff --git a/src/common/xcgroup.h b/src/common/xcgroup.h index cea81f9990980fafae971c94fce0cb02d491ab4f..7b83d278889eb0a80395227bad85c8571feacae1 100644 --- a/src/common/xcgroup.h +++ b/src/common/xcgroup.h @@ -43,14 +43,11 @@ #include <sys/types.h> #include <dirent.h> +#include "xcgroup_read_config.h" #define XCGROUP_ERROR 1 #define XCGROUP_SUCCESS 0 -#ifndef CGROUP_BASEDIR -#define CGROUP_BASEDIR "/cgroup" -#endif - typedef struct xcgroup_ns { char* mnt_point; /* mount point to use for the associated cgroup */ @@ -80,7 +77,8 @@ typedef struct xcgroup { * - XCGROUP_ERROR * - XCGROUP_SUCCESS */ -int xcgroup_ns_create(xcgroup_ns_t* cgns, +int xcgroup_ns_create(slurm_cgroup_conf_t *conf, + xcgroup_ns_t* cgns, char* mnt_point,char* mnt_args, char* subsys,char* notify_prog); diff --git a/src/common/xcgroup_read_config.c b/src/common/xcgroup_read_config.c index 6f71140845259e6eca7a963e47a129d6611e86f3..ef2397d584fbdc9397460777e16621862b3997a7 100644 --- a/src/common/xcgroup_read_config.c +++ b/src/common/xcgroup_read_config.c @@ -54,6 +54,8 @@ #include "xcgroup_read_config.h" +#define DEFAULT_CGROUP_BASEDIR "/cgroup" + slurm_cgroup_conf_t *slurm_cgroup_conf = NULL; /* Local functions */ @@ -73,6 +75,7 @@ static void _clear_slurm_cgroup_conf(slurm_cgroup_conf_t *slurm_cgroup_conf) { if (slurm_cgroup_conf) { slurm_cgroup_conf->cgroup_automount = false ; + xfree(slurm_cgroup_conf->cgroup_mountpoint); xfree(slurm_cgroup_conf->cgroup_subsystems); xfree(slurm_cgroup_conf->cgroup_release_agent); slurm_cgroup_conf->constrain_cores = false ; @@ -97,6 +100,7 @@ extern int read_slurm_cgroup_conf(slurm_cgroup_conf_t *slurm_cgroup_conf) { s_p_options_t options[] = { {"CgroupAutomount", S_P_BOOLEAN}, + {"CgroupMountpoint", S_P_STRING}, {"CgroupSubsystems", S_P_STRING}, {"CgroupReleaseAgentDir", S_P_STRING}, {"ConstrainCores", S_P_BOOLEAN}, @@ -137,8 +141,14 @@ extern int read_slurm_cgroup_conf(slurm_cgroup_conf_t *slurm_cgroup_conf) /* cgroup initialisation parameters */ if (!s_p_get_boolean(&slurm_cgroup_conf->cgroup_automount, - "CgroupAutomount", tbl)) + "CgroupAutomount", tbl)) slurm_cgroup_conf->cgroup_automount = false; + + if (!s_p_get_string(&slurm_cgroup_conf->cgroup_mountpoint, + "CgroupMountpoint", tbl)) + slurm_cgroup_conf->cgroup_mountpoint = + xstrdup(DEFAULT_CGROUP_BASEDIR); + s_p_get_string(&slurm_cgroup_conf->cgroup_subsystems, "CgroupSubsystems", tbl); s_p_get_string(&slurm_cgroup_conf->cgroup_release_agent, diff --git a/src/common/xcgroup_read_config.h b/src/common/xcgroup_read_config.h index 7693b0e2f3bc3df018215eaae20332a10c7c95b0..bdbe472133c00e4b92b5e58a6bf35e5eb8537932 100644 --- a/src/common/xcgroup_read_config.h +++ b/src/common/xcgroup_read_config.h @@ -55,6 +55,7 @@ typedef struct slurm_cgroup_conf { bool cgroup_automount; + char * cgroup_mountpoint; char * cgroup_subsystems; char * cgroup_release_agent; diff --git a/src/plugins/proctrack/cgroup/proctrack_cgroup.c b/src/plugins/proctrack/cgroup/proctrack_cgroup.c index b38211be6b28ebb4552839a805c2eaa7c3350233..1265326d287a928a36a70128c8edc3c07e9405cd 100644 --- a/src/plugins/proctrack/cgroup/proctrack_cgroup.c +++ b/src/plugins/proctrack/cgroup/proctrack_cgroup.c @@ -129,7 +129,7 @@ int _slurm_cgroup_init(void) } /* initialize freezer cgroup namespace */ - if (xcgroup_ns_create(&freezer_ns, CGROUP_BASEDIR "/freezer", "", + if (xcgroup_ns_create(&slurm_cgroup_conf, &freezer_ns, "/freezer", "", "freezer", release_agent_path) != XCGROUP_SUCCESS) { error("unable to create freezer cgroup namespace"); diff --git a/src/plugins/task/cgroup/task_cgroup_cpuset.c b/src/plugins/task/cgroup/task_cgroup_cpuset.c index 59f46512d39feb5668af5d31cb80f8e62f6fa471..5fe8fba482d246f6b8d65d319c1769c13ec7e2b5 100644 --- a/src/plugins/task/cgroup/task_cgroup_cpuset.c +++ b/src/plugins/task/cgroup/task_cgroup_cpuset.c @@ -94,7 +94,7 @@ extern int task_cgroup_cpuset_init(slurm_cgroup_conf_t *slurm_cgroup_conf) error("task/cgroup: unable to build cpuset release agent path"); goto error; } - if (xcgroup_ns_create(&cpuset_ns,CGROUP_BASEDIR "/cpuset","", + if (xcgroup_ns_create(slurm_cgroup_conf, &cpuset_ns, "/cpuset", "", "cpuset",release_agent_path) != XCGROUP_SUCCESS) { error("task/cgroup: unable to create cpuset namespace"); diff --git a/src/plugins/task/cgroup/task_cgroup_devices.c b/src/plugins/task/cgroup/task_cgroup_devices.c index 9053bec0e91bb5eff7cbcc0e63250145cd6b5e06..da1eb58d3d3cdbeca3d7c22b26b279693d7dc23d 100644 --- a/src/plugins/task/cgroup/task_cgroup_devices.c +++ b/src/plugins/task/cgroup/task_cgroup_devices.c @@ -102,7 +102,7 @@ extern int task_cgroup_devices_init(slurm_cgroup_conf_t *slurm_cgroup_conf) error("task/cgroup: unable to build devices release agent path"); goto error; } - if ( xcgroup_ns_create(&devices_ns,CGROUP_BASEDIR "/devices","", + if (xcgroup_ns_create(slurm_cgroup_conf, &devices_ns, "/devices","", "devices",release_agent_path) != XCGROUP_SUCCESS ) { error("task/cgroup: unable to create devices namespace"); diff --git a/src/plugins/task/cgroup/task_cgroup_memory.c b/src/plugins/task/cgroup/task_cgroup_memory.c index 70de4c76f2d651e6c0160ec2b34b36320d243e4f..321495d7c1f8a7f2c89d9e05f35e656fca8f3e47 100644 --- a/src/plugins/task/cgroup/task_cgroup_memory.c +++ b/src/plugins/task/cgroup/task_cgroup_memory.c @@ -84,7 +84,7 @@ extern int task_cgroup_memory_init(slurm_cgroup_conf_t *slurm_cgroup_conf) error("task/cgroup: unable to build memory release agent path"); goto error; } - if (xcgroup_ns_create(&memory_ns,CGROUP_BASEDIR "/memory","", + if (xcgroup_ns_create(slurm_cgroup_conf, &memory_ns, "/memory", "", "memory",release_agent_path) != XCGROUP_SUCCESS) { error("task/cgroup: unable to create memory namespace");