diff --git a/src/plugins/task/affinity/task_affinity.c b/src/plugins/task/affinity/task_affinity.c index 044e33e21dca497a41c02ef82f5c05580a4a60bc..0e7c9145cf15f7db5c4854c2757d6e8a48fe0e05 100644 --- a/src/plugins/task/affinity/task_affinity.c +++ b/src/plugins/task/affinity/task_affinity.c @@ -492,7 +492,7 @@ extern int task_p_pre_launch (stepd_step_rec_t *job) * task_p_pre_launch_priv() is called prior to exec of application task. * in privileged mode, just after slurm_spank_task_init_privileged */ -extern int task_p_pre_launch_priv (stepd_step_rec_t *job) +extern int task_p_pre_launch_priv(stepd_step_rec_t *job, pid_t pid) { return SLURM_SUCCESS; } diff --git a/src/plugins/task/cgroup/task_cgroup.c b/src/plugins/task/cgroup/task_cgroup.c index d15b3612a0345339d1397e72ff8d7173af193dd8..e5296a1f90d077beb5ea8963f0d6f4928fccf064 100644 --- a/src/plugins/task/cgroup/task_cgroup.c +++ b/src/plugins/task/cgroup/task_cgroup.c @@ -242,7 +242,7 @@ extern int task_p_pre_setuid (stepd_step_rec_t *job) * task_p_pre_launch_priv() is called prior to exec of application task. * in privileged mode, just after slurm_spank_task_init_privileged */ -extern int task_p_pre_launch_priv (stepd_step_rec_t *job) +extern int task_p_pre_launch_priv(stepd_step_rec_t *job, pid_t pid) { if (use_cpuset) { @@ -252,7 +252,7 @@ extern int task_p_pre_launch_priv (stepd_step_rec_t *job) if (use_memory) { /* attach the task to the memory cgroup */ - task_cgroup_memory_attach_task(job); + task_cgroup_memory_attach_task(job, pid); } if (use_devices) { diff --git a/src/plugins/task/cgroup/task_cgroup_memory.c b/src/plugins/task/cgroup/task_cgroup_memory.c index a0b3745f8645bde4e4e2b9320f89b1aa256f0f18..b361ce6d8ea4f174b31319b8b685f220a352290b 100644 --- a/src/plugins/task/cgroup/task_cgroup_memory.c +++ b/src/plugins/task/cgroup/task_cgroup_memory.c @@ -502,15 +502,10 @@ error: return fstatus; } -extern int task_cgroup_memory_attach_task(stepd_step_rec_t *job) +extern int task_cgroup_memory_attach_task(stepd_step_rec_t *job, pid_t pid) { int fstatus = SLURM_ERROR; - pid_t pid; - /* - * Attach the current task to the step memory cgroup - */ - pid = getpid(); if (xcgroup_add_pids(&step_memory_cg, &pid, 1) != XCGROUP_SUCCESS) { error("task/cgroup: unable to add task[pid=%u] to " "memory cg '%s'",pid,step_memory_cg.path); diff --git a/src/plugins/task/cgroup/task_cgroup_memory.h b/src/plugins/task/cgroup/task_cgroup_memory.h index c8f635739f7a8b832fbf9bf848272e4c7e13fe6a..0c8101c98b4f1abe8acb8534090ac23a606d93bb 100644 --- a/src/plugins/task/cgroup/task_cgroup_memory.h +++ b/src/plugins/task/cgroup/task_cgroup_memory.h @@ -49,7 +49,7 @@ extern int task_cgroup_memory_fini(slurm_cgroup_conf_t *slurm_cgroup_conf); extern int task_cgroup_memory_create(stepd_step_rec_t *job); /* create a task cgroup and attach the task to it */ -extern int task_cgroup_memory_attach_task(stepd_step_rec_t *job); +extern int task_cgroup_memory_attach_task(stepd_step_rec_t *job, pid_t pid); /* detect if oom ran on a step or job and print notice of said event */ extern int task_cgroup_memory_check_oom(stepd_step_rec_t *job); diff --git a/src/plugins/task/cray/task_cray.c b/src/plugins/task/cray/task_cray.c index a496a211996b39c63b8fec788b9aa27efbb5aa18..50302fbd1ed559ff1e488b79cacb6959c4ecc524 100644 --- a/src/plugins/task/cray/task_cray.c +++ b/src/plugins/task/cray/task_cray.c @@ -379,7 +379,7 @@ extern int task_p_pre_launch (stepd_step_rec_t *job) * task_p_pre_launch_priv() is called prior to exec of application task. * in privileged mode, just after slurm_spank_task_init_privileged */ -extern int task_p_pre_launch_priv (stepd_step_rec_t *job) +extern int task_p_pre_launch_priv(stepd_step_rec_t *job, pid_t pid) { int rc = SLURM_SUCCESS; DEF_TIMERS; diff --git a/src/plugins/task/none/task_none.c b/src/plugins/task/none/task_none.c index 2df5b48d8d926f2cbcfe95a0effc8abd46114704..35a25ba1d03b9c170022955216523862a0214971 100644 --- a/src/plugins/task/none/task_none.c +++ b/src/plugins/task/none/task_none.c @@ -178,7 +178,7 @@ extern int task_p_pre_launch (stepd_step_rec_t *job) * task_p_pre_launch_priv() is called prior to exec of application task. * in privileged mode, just after slurm_spank_task_init_privileged */ -extern int task_p_pre_launch_priv (stepd_step_rec_t *job) +extern int task_p_pre_launch_priv(stepd_step_rec_t *job, pid_t pid) { debug("task_p_pre_launch_priv: %u.%u", job->jobid, job->stepid); diff --git a/src/slurmd/common/task_plugin.c b/src/slurmd/common/task_plugin.c index ac28338a1acb9bd96a3cfd5409b460ba14b5017b..71447bd6b42d1097447c816a76c78574837d53f4 100644 --- a/src/slurmd/common/task_plugin.c +++ b/src/slurmd/common/task_plugin.c @@ -63,7 +63,7 @@ typedef struct slurmd_task_ops { int (*slurmd_release_resources) (uint32_t job_id); int (*pre_setuid) (stepd_step_rec_t *job); - int (*pre_launch_priv) (stepd_step_rec_t *job); + int (*pre_launch_priv) (stepd_step_rec_t *job, pid_t pid); int (*pre_launch) (stepd_step_rec_t *job); int (*post_term) (stepd_step_rec_t *job, stepd_step_task_info_t *task); @@ -386,7 +386,7 @@ extern int task_g_pre_setuid(stepd_step_rec_t *job) * * RET - slurm error code */ -extern int task_g_pre_launch_priv(stepd_step_rec_t *job) +extern int task_g_pre_launch_priv(stepd_step_rec_t *job, pid_t pid) { int i, rc = SLURM_SUCCESS; @@ -395,7 +395,7 @@ extern int task_g_pre_launch_priv(stepd_step_rec_t *job) slurm_mutex_lock( &g_task_context_lock ); for (i = 0; i < g_task_context_num; i++) { - rc = (*(ops[i].pre_launch_priv))(job); + rc = (*(ops[i].pre_launch_priv))(job, pid); if (rc != SLURM_SUCCESS) { debug("%s: %s: %s", __func__, g_task_context[i]->type, slurm_strerror(rc)); diff --git a/src/slurmd/common/task_plugin.h b/src/slurmd/common/task_plugin.h index 60ca1a5160e0b9227ecd7d9fa3d3acbbcefc9325..6485fd6a89d10b2176be27d4eff91a00258209f5 100644 --- a/src/slurmd/common/task_plugin.h +++ b/src/slurmd/common/task_plugin.h @@ -122,7 +122,7 @@ extern int task_g_pre_setuid(stepd_step_rec_t *job); * * RET - slurm error code */ -extern int task_g_pre_launch_priv(stepd_step_rec_t *job); +extern int task_g_pre_launch_priv(stepd_step_rec_t *job, pid_t pid); /* * Note that a task launch is about to occur. diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c index a06236ec760ff638c75cc8e2279f6358f1e55fc2..2fe670ba8532bd64f884725287cb4e60a4d66b73 100644 --- a/src/slurmd/slurmstepd/mgr.c +++ b/src/slurmd/slurmstepd/mgr.c @@ -1818,7 +1818,7 @@ _fork_all_tasks(stepd_step_rec_t *job, bool *io_initialized) i, job->task[i]->pid, job->pgid); } - if (task_g_pre_launch_priv(job) < 0) { + if (task_g_pre_launch_priv(job, job->task[i]->pid) < 0) { error("task_g_pre_launch_priv: %m"); rc = SLURM_ERROR; goto fail2;