Skip to content
Snippets Groups Projects
Commit 8aa9e802 authored by Mark Grondona's avatar Mark Grondona
Browse files

o propagate all resource limits from srun to slurmd

parent bbda4331
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,8 @@ documents those changes that are of interest to users and admins. ...@@ -19,6 +19,8 @@ documents those changes that are of interest to users and admins.
shared nodes. shared nodes.
-- Set SLURM_DISTRIBUTION environment varible for user tasks. -- Set SLURM_DISTRIBUTION environment varible for user tasks.
-- Fix for file descriptor leak in slurmd. -- Fix for file descriptor leak in slurmd.
-- Propagate stacksize limit to jobs along with other resource limits
that were previously ignored.
* Changes in SLURM 0.3.0.0-pre9 * Changes in SLURM 0.3.0.0-pre9
=============================== ===============================
......
...@@ -52,17 +52,35 @@ struct userlim { ...@@ -52,17 +52,35 @@ struct userlim {
*/ */
static struct userlim ulims[] = static struct userlim ulims[] =
{ {
#ifdef RLIMIT_CPU
{ "SLURM_RLIMIT_CPU" , RLIMIT_CPU },
#endif
#ifdef RLIMIT_FSIZE
{ "SLURM_RLIMIT_FSIZE" , RLIMIT_FSIZE },
#endif
#ifdef RLIMIT_DATA
{ "SLURM_RLIMIT_DATA" , RLIMIT_DATA },
#endif
#ifdef RLIMIT_STACK
{ "SLURM_RLIMIT_STACK" , RLIMIT_STACK },
#endif
#ifdef RLIMIT_CORE #ifdef RLIMIT_CORE
{ "SLURM_RLIMIT_CORE" , RLIMIT_CORE }, { "SLURM_RLIMIT_CORE" , RLIMIT_CORE },
#endif #endif
#ifdef RLIMIT_FSIZE #ifdef RLIMIT_RSS
{ "SLURM_RLIMIT_FSIZE" , RLIMIT_FSIZE }, { "SLURM_RLIMIT_RSS" , RLIMIT_RSS },
#endif #endif
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
{ "SLURM_RLIMIT_NPROC" , RLIMIT_NPROC }, { "SLURM_RLIMIT_NPROC" , RLIMIT_NPROC },
#endif #endif
#ifdef RLIMIT_NOFILE #ifdef RLIMIT_NOFILE
{ "SLURM_RLIMIT_NOFILE", RLIMIT_NOFILE}, { "SLURM_RLIMIT_NOFILE", RLIMIT_NOFILE},
#endif
#ifdef RLIMIT_MEMLOCK
{ "SLURM_RLIMIT_MEMLOCK", RLIMIT_MEMLOCK },
#endif
#ifdef RLIMIT_AS
{ "SLURM_RLIMIT_AS" , RLIMIT_AS },
#endif #endif
{ NULL, 0 } { NULL, 0 }
}; };
......
...@@ -119,8 +119,6 @@ int main(int ac, char **av) ...@@ -119,8 +119,6 @@ int main(int ac, char **av)
*/ */
initialize_and_process_args(ac, av); initialize_and_process_args(ac, av);
if (!opt.allocate)
(void) _set_rlimit_env();
/* reinit log with new verbosity (if changed by command line) /* reinit log with new verbosity (if changed by command line)
*/ */
...@@ -131,6 +129,9 @@ int main(int ac, char **av) ...@@ -131,6 +129,9 @@ int main(int ac, char **av)
log_alter(logopt, 0, NULL); log_alter(logopt, 0, NULL);
} }
if (!opt.allocate)
(void) _set_rlimit_env();
/* Set up slurmctld message handler */ /* Set up slurmctld message handler */
slurmctld_msg_init(); slurmctld_msg_init();
...@@ -691,49 +692,81 @@ _set_batch_script_env(job_t *job) ...@@ -691,49 +692,81 @@ _set_batch_script_env(job_t *job)
static int _set_rlimit_env(void) static int _set_rlimit_env(void)
{ {
int rc = SLURM_SUCCESS; int rc = SLURM_SUCCESS;
struct rlimit my_rlimit; struct rlimit rlim[1];
struct rlimit_info {
const int res;
const char *var;
} rlimit_vars[] = {
#ifdef RLIMIT_CPU
{ RLIMIT_CPU, "CPU" },
#endif
#ifdef RLIMIT_FSIZE #ifdef RLIMIT_FSIZE
if (getrlimit(RLIMIT_FSIZE, &my_rlimit) || { RLIMIT_FSIZE, "FSIZE" },
setenvf("SLURM_RLIMIT_FSIZE=%ld", (long)my_rlimit.rlim_cur)) { #endif
error("Can't set SLURM_RLIMIT_FSIZE environment variable"); #ifdef RLIMIT_DATA
rc = SLURM_FAILURE; { RLIMIT_DATA, "DATA" },
} #endif
#ifdef RLIMIT_STACK
{ RLIMIT_STACK, "STACK" },
#endif #endif
#ifdef RLIMIT_CORE #ifdef RLIMIT_CORE
if (getrlimit(RLIMIT_CORE, &my_rlimit) || { RLIMIT_CORE, "CORE" },
setenvf("SLURM_RLIMIT_CORE=%ld", (long)my_rlimit.rlim_cur)) { #endif
error("Can't set SLURM_RLIMIT_CORE environment variable"); #ifdef RLIMIT_RSS
rc = SLURM_FAILURE; { RLIMIT_RSS, "RSS" },
}
#endif #endif
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
if (getrlimit(RLIMIT_NPROC, &my_rlimit) || { RLIMIT_NPROC, "NPROC" },
setenvf("SLURM_RLIMIT_NPROC=%ld", (long)my_rlimit.rlim_cur)) {
error("Can't set SLURM_RLIMIT_NPROC environment variable");
rc = SLURM_FAILURE;
}
#endif #endif
#ifdef RLIMIT_NOFILE #ifdef RLIMIT_NOFILE
if (getrlimit(RLIMIT_NOFILE, &my_rlimit) == 0) { { RLIMIT_NOFILE, "NOFILE" },
if (setenvf("SLURM_RLIMIT_NOFILE=%ld", #endif
(long)my_rlimit.rlim_cur)) { #ifdef RLIMIT_MEMLOCK
error("Can't set SLURM_RLIMIT_NOFILE environment variable"); { RLIMIT_MEMLOCK,"MEMLOCK"},
#endif
#ifdef RLIMIT_AS
{ RLIMIT_AS, "AS" },
#endif
{ 0, NULL}
};
struct rlimit_info *r;
for (r = rlimit_vars; r->var; r++) {
long cur;
if (getrlimit (r->res, rlim) < 0) {
error ("getrlimit (%s): %m", r->var);
rc = SLURM_FAILURE; rc = SLURM_FAILURE;
continue;
} }
my_rlimit.rlim_cur = my_rlimit.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &my_rlimit)) { cur = (long) rlim->rlim_cur;
error("Can't set SLURM_RLIMIT_NOFILE value");
if (setenvf ("SLURM_RLIMIT_%s=%ld", r->var, cur) < 0) {
error ("unable to set RLIMIT_%s in environment",
r->var);
rc = SLURM_FAILURE; rc = SLURM_FAILURE;
continue;
} }
} else {
error("Can't get RLIMIT_NOFILE value"); debug ("propagating RLIMIT_%s=%ld", r->var, cur);
rc = SLURM_FAILURE; }
/*
* Now increase NOFILE to the max available for this srun
*/
if (getrlimit (RLIMIT_NOFILE, rlim) < 0)
return (error ("getrlimit (RLIMIT_NOFILE): %m"));
if (rlim->rlim_cur < rlim->rlim_max) {
rlim->rlim_cur = rlim->rlim_max;
if (setrlimit (RLIMIT_NOFILE, rlim) < 0)
return (error ("Unable to increase max no. files: %m"));
} }
#endif
return rc; return rc;
} }
......
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