diff --git a/NEWS b/NEWS index 0890a62c8036ca6819cedfb9269ffaac2fb18472..6f356557f2dc310a6c123d1d79153a7f79c31d58 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ documents those changes that are of interest to users and administrators. -- Enforce invalid argument combinations with --ntasks-per-gpu -- slurmrestd/auth_local - Verify username on slurm_rest_auth_p_apply() -- Fix requeue of job on node failure. + -- Prevent a job from requesting too much memory if it + requests MEM_PER_CPUS and --threads-per-core < the number of threads + on a core. * Changes in Slurm 20.11.0rc2 ============================== diff --git a/src/plugins/select/cons_common/job_test.c b/src/plugins/select/cons_common/job_test.c index 6879c24474802bab9c8d961209f612901e1e8f6c..3d990ef22e7d7a7ad92c397804b21af2d10ce4c1 100644 --- a/src/plugins/select/cons_common/job_test.c +++ b/src/plugins/select/cons_common/job_test.c @@ -1607,7 +1607,22 @@ alloc_job: avail_mem = select_node_record[i].real_memory - select_node_record[i].mem_spec_limit; if (save_mem & MEM_PER_CPU) { /* Memory per CPU */ - needed_mem = job_res->cpus[j] * + uint16_t cpu_count = job_res->cpus[j]; + /* + * If the job requested less threads that we + * allocated but requested memory based on cpu + * count we would need to adjust that to avoid + * getting more memory than we are actually + * expecting. + */ + if (job_ptr->details->mc_ptr->threads_per_core < + select_node_record[i].vpus) { + cpu_count /= select_node_record[i].vpus; + cpu_count *= job_ptr->details-> + mc_ptr->threads_per_core; + } + + needed_mem = cpu_count * (save_mem & (~MEM_PER_CPU)); } else if (save_mem) { /* Memory per node */ needed_mem = save_mem;