/* * create a cgroup namespace for tasks containment * * returned values: * - XCGROUP_ERROR * - XCGROUP_SUCCESS */ int xcgroup_ns_create(slurm_cgroup_conf_t *conf, xcgroup_ns_t *cgns, char *mnt_args, char *subsys) { cgns->mnt_point = xstrdup_printf("%s/%s", conf->cgroup_mountpoint, subsys); cgns->mnt_args = xstrdup(mnt_args); cgns->subsystems = xstrdup(subsys); cgns->notify_prog = xstrdup_printf("%s/release_%s", conf->cgroup_release_agent, subsys); /* check that freezer cgroup namespace is available */ if (!xcgroup_ns_is_available(cgns)) { if (conf->cgroup_automount) { if (xcgroup_ns_mount(cgns)) { error("unable to mount %s cgroup " "namespace: %s", subsys, slurm_strerror(errno)); goto clean; } info("cgroup namespace '%s' is now mounted", subsys); } else { error("cgroup namespace '%s' not mounted. aborting", subsys); goto clean; } } return XCGROUP_SUCCESS; clean: xcgroup_ns_destroy(cgns); return XCGROUP_ERROR; }
extern int task_cgroup_cpuset_init(slurm_cgroup_conf_t *slurm_cgroup_conf) { char release_agent_path[PATH_MAX]; /* initialize cpuinfo internal data */ if (xcpuinfo_init() != XCPUINFO_SUCCESS) { return SLURM_ERROR; } /* initialize user/job/jobstep cgroup relative paths */ user_cgroup_path[0]='\0'; job_cgroup_path[0]='\0'; jobstep_cgroup_path[0]='\0'; /* initialize cpuset cgroup namespace */ release_agent_path[0]='\0'; if (snprintf(release_agent_path,PATH_MAX,"%s/release_cpuset", slurm_cgroup_conf->cgroup_release_agent) >= PATH_MAX) { error("task/cgroup: unable to build cpuset release agent path"); goto error; } if (xcgroup_ns_create(slurm_cgroup_conf, &cpuset_ns, "/cpuset", "", "cpuset",release_agent_path) != XCGROUP_SUCCESS) { error("task/cgroup: unable to create cpuset namespace"); goto error; } /* check that cpuset cgroup namespace is available */ if (! xcgroup_ns_is_available(&cpuset_ns)) { if (slurm_cgroup_conf->cgroup_automount) { if (xcgroup_ns_mount(&cpuset_ns)) { error("task/cgroup: unable to mount cpuset " "namespace"); goto clean; } info("task/cgroup: cpuset namespace is now mounted"); } else { error("task/cgroup: cpuset namespace not mounted. " "aborting"); goto clean; } } return SLURM_SUCCESS; clean: xcgroup_ns_destroy(&cpuset_ns); error: xcpuinfo_fini(); return SLURM_ERROR; }
extern int jobacct_gather_cgroup_memory_init( slurm_cgroup_conf_t *slurm_cgroup_conf) { char release_agent_path[PATH_MAX]; /* initialize user/job/jobstep cgroup relative paths */ user_cgroup_path[0]='\0'; job_cgroup_path[0]='\0'; jobstep_cgroup_path[0]='\0'; /* initialize memory cgroup namespace */ release_agent_path[0]='\0'; if (snprintf(release_agent_path, PATH_MAX, "%s/release_memory", slurm_cgroup_conf->cgroup_release_agent) >= PATH_MAX) { error("jobacct_gather/cgroup: unable to build memory release " "agent path"); goto error; } if (xcgroup_ns_create(slurm_cgroup_conf, &memory_ns, "/memory", "", "memory", release_agent_path) != XCGROUP_SUCCESS) { error("jobacct_gather/cgroup: unable to create memory " "namespace"); goto error; } /* check that memory cgroup namespace is available */ if (!xcgroup_ns_is_available(&memory_ns)) { if (slurm_cgroup_conf->cgroup_automount) { if (xcgroup_ns_mount(&memory_ns)) { error("jobacct_gather/cgroup: unable to mount " "memory namespace"); goto clean; } info("jobacct_gather/cgroup: memory namespace is now " "mounted"); } else { error("jobacct_gather/cgroup: memory namespace not " "mounted. aborting"); goto clean; } } return SLURM_SUCCESS; clean: xcgroup_ns_destroy(&memory_ns); error: return SLURM_ERROR; }