Skip to content
Snippets Groups Projects
Commit ddc48a62 authored by Moe Jette's avatar Moe Jette
Browse files

Add logic to replicate cpus from /dev/cpuset/cpus to the main slurm job's subdirectory.

parent 48cb1052
No related branches found
No related tags found
No related merge requests found
...@@ -88,8 +88,7 @@ ...@@ -88,8 +88,7 @@
#include "src/common/util-net.h" #include "src/common/util-net.h"
#include "src/common/slurm_resource_info.h" #include "src/common/slurm_resource_info.h"
#define CPUSET_DIRX "/dev/cpuset" #define CPUSET_DIR "/dev/cpuset"
#define CPUSET_DIR "/g/g0/jette/cpuset"
/*** from affinity.c ***/ /*** from affinity.c ***/
void slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval); void slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval);
...@@ -102,7 +101,7 @@ int slurm_getaffinity(pid_t pid, size_t size, cpu_set_t *mask); ...@@ -102,7 +101,7 @@ int slurm_getaffinity(pid_t pid, size_t size, cpu_set_t *mask);
int slurm_set_memset(char *path, nodemask_t *new_mask); int slurm_set_memset(char *path, nodemask_t *new_mask);
int slurm_memset_available(void); int slurm_memset_available(void);
#endif #endif
int slurm_build_cpuset(char *path, uid_t uid, gid_t gid); int slurm_build_cpuset(char *base, char *path, uid_t uid, gid_t gid);
int slurm_get_cpuset(char *path, pid_t pid, size_t size, cpu_set_t *mask); int slurm_get_cpuset(char *path, pid_t pid, size_t size, cpu_set_t *mask);
int slurm_set_cpuset(char *path, pid_t pid, size_t size, int slurm_set_cpuset(char *path, pid_t pid, size_t size,
const cpu_set_t *mask); const cpu_set_t *mask);
......
...@@ -54,25 +54,36 @@ static void _cpuset_to_cpustr(const cpu_set_t *mask, char *str) ...@@ -54,25 +54,36 @@ static void _cpuset_to_cpustr(const cpu_set_t *mask, char *str)
} }
} }
int slurm_build_cpuset(char *path, uid_t uid, gid_t gid) int slurm_build_cpuset(char *base, char *path, uid_t uid, gid_t gid)
{ {
char file_path[PATH_MAX], mstr[16]; char file_path[PATH_MAX], mstr[16];
int fd, rc; int fd, rc;
snprintf(file_path, sizeof(file_path), "%s/cpus", base);
fd = open(file_path, O_RDONLY);
if (fd < 0) {
error("open(%s): %m", file_path);
return -1;
}
rc = read(fd, mstr, sizeof(mstr));
close(fd);
if (rc < 1) {
error("read(%s): %m", file_path);
return -1;
}
if (mkdir(path, 0700) && (errno != EEXIST)) { if (mkdir(path, 0700) && (errno != EEXIST)) {
error("mkdir(%s): %m", path); error("mkdir(%s): %m", path);
return -1; return -1;
} }
if (chown(path, uid, gid))
error("chown(%s): %m", path);
snprintf(file_path, sizeof(file_path), "%s/notify_on_release", path); snprintf(file_path, sizeof(file_path), "%s/cpus", path);
fd = open(file_path, O_CREAT | O_WRONLY, 0700); fd = open(file_path, O_CREAT | O_WRONLY, 0700);
if (fd < 0) { if (fd < 0) {
error("open(%s): %m", file_path); error("open(%s): %m", file_path);
return -1; return -1;
} }
rc = write(fd, "1", 2); rc = write(fd, mstr, rc);
close(fd); close(fd);
snprintf(file_path, sizeof(file_path), "%s/tasks", path); snprintf(file_path, sizeof(file_path), "%s/tasks", path);
...@@ -88,6 +99,19 @@ int slurm_build_cpuset(char *path, uid_t uid, gid_t gid) ...@@ -88,6 +99,19 @@ int slurm_build_cpuset(char *path, uid_t uid, gid_t gid)
error("write(%s, %s): %m", file_path, mstr); error("write(%s, %s): %m", file_path, mstr);
return -1; return -1;
} }
snprintf(file_path, sizeof(file_path), "%s/notify_on_release", path);
fd = open(file_path, O_CREAT | O_WRONLY, 0700);
if (fd < 0) {
error("open(%s): %m", file_path);
return -1;
}
rc = write(fd, "1", 2);
close(fd);
if (chown(path, uid, gid))
error("chown(%s): %m", path);
return 0; return 0;
} }
......
...@@ -163,7 +163,7 @@ int task_pre_setuid ( slurmd_job_t *job ) ...@@ -163,7 +163,7 @@ int task_pre_setuid ( slurmd_job_t *job )
error("cpuset path too long"); error("cpuset path too long");
return SLURM_ERROR; return SLURM_ERROR;
} }
slurm_build_cpuset(path, job->uid, job->gid); slurm_build_cpuset(CPUSET_DIR, path, job->uid, job->gid);
return SLURM_SUCCESS; return SLURM_SUCCESS;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment