Hi,

This is a follow-up from https://groups.google.com/g/slurm-users/c/JI3UkbCtj3U, but as I could not find any progress, I am opening a new thread.

When setting IgnoreSystemd=yes in cgroup.conf, I have the error:

error: common_file_write_content: unable to open '/sys/fs/cgroup/system.slice/cgroup.subtree_control' for writing: No such file or directory
error: Cannot enable cpuset in /sys/fs/cgroup/system.slice/cgroup.subtree_control: No such file or directory
error: common_file_write_content: unable to open '/sys/fs/cgroup/system.slice/cgroup.subtree_control' for writing: No such file or directory
error: Cannot enable memory in /sys/fs/cgroup/system.slice/cgroup.subtree_control: No such file or directory
error: common_file_write_content: unable to open '/sys/fs/cgroup/system.slice/cgroup.subtree_control' for writing: No such file or directory
error: Cannot enable cpu in /sys/fs/cgroup/system.slice/cgroup.subtree_control: No such file or directory
error: Could not create scope directory /sys/fs/cgroup/system.slice/slurmstepd.scope: No such file or directory
error: Couldn't load specified plugin name for cgroup/v2: Plugin init() callback failed
error: cannot create cgroup context for cgroup/v2
error: Unable to initialize cgroup plugin
error: slurmd initialization failed

I wrote a patch that solves this issue:

--- cgroup_v2.c.orig    2024-09-02 13:18:21.376312875 +0200
+++ cgroup_v2.c 2024-09-02 13:22:00.516986953 +0200
@@ -43,6 +43,7 @@
 #include <sys/inotify.h>
 #include <poll.h>
 #include <unistd.h>
+#include <libgen.h>

 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
@@ -743,11 +744,33 @@
    return SLURM_SUCCESS;
 }
+static int _mkdir(const char *path, mode_t mode)
+{
+   int rc;
+   char *dir, *pdir;
+
+   dir = strdup(path);
+   if (dir == NULL) {
+       return ENOMEM;
+   }
+   pdir = dirname(dir);
+   if (strcmp(pdir, path) != 0) {
+       rc = _mkdir(pdir, mode);
+       if (rc && (errno != EEXIST)) {
+           free(dir);
+           return rc;
+       }
+   }
+   rc = mkdir(path, mode);
+   free(dir);
+   return rc;
+}
+
 static int _init_new_scope(char *scope_path)
 {
    int rc;

-   rc = mkdir(scope_path, 0755);
+   rc = _mkdir(scope_path, 0755);
    if (rc && (errno != EEXIST)) {
        error("Could not create scope directory %s: %m", scope_path);
        return SLURM_ERROR;

This patch concerns the file src/plugins/cgroup/v2/cgroup_v2.c. Am I missing something ?

Cheers,
Honoré.