From c2ce30c2c1879da4d3b02622ca82819163c90d30 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" <mgrondona@llnl.gov> Date: Thu, 2 Jul 2015 13:15:38 -0700 Subject: [PATCH] proctrack/cgroup: Move slurmstepd out of freezer cgroup before removal In order to successfully remove the freezer cgroup at the end of a job step, the slurmstepd process itself must first be moved outside of the cgroup, or removal will always fail. This fix moves the slurmstepd back to the root cgroup just before the rmdir operations are attempted. --- src/plugins/proctrack/cgroup/proctrack_cgroup.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/plugins/proctrack/cgroup/proctrack_cgroup.c b/src/plugins/proctrack/cgroup/proctrack_cgroup.c index 847182fc81d..ffd2922b93d 100644 --- a/src/plugins/proctrack/cgroup/proctrack_cgroup.c +++ b/src/plugins/proctrack/cgroup/proctrack_cgroup.c @@ -270,10 +270,27 @@ bail: return SLURM_ERROR; } +static int _move_current_to_root_cgroup(xcgroup_ns_t *ns) +{ + xcgroup_t cg; + + if (xcgroup_create(ns, &cg, "", 0, 0) != XCGROUP_SUCCESS) + return SLURM_ERROR; + + return xcgroup_move_process(&cg, getpid()); +} + int _slurm_cgroup_destroy(void) { xcgroup_lock(&freezer_cg); + /* + * First move slurmstepd process to the root cgroup, otherwise + * the rmdir(2) triggered by the calls below will always fail, + * because slurmstepd is still in the cgroup! + */ + _move_current_to_root_cgroup(&freezer_ns); + if (jobstep_cgroup_path[0] != '\0') { if (xcgroup_delete(&step_freezer_cg) != XCGROUP_SUCCESS) { debug("_slurm_cgroup_destroy: problem deleting step cgroup path %s: %m", -- GitLab