From c36947a7a8c76567433b9813847bc6ba6499a559 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 5 Apr 2007 22:44:14 +0000
Subject: [PATCH] svn merge -r11310:11312
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.1

---
 NEWS                           |  2 ++
 src/slurmctld/node_scheduler.c | 34 +++++++++++++++++++++++++---------
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index a825748b2a6..96b4a79cac8 100644
--- a/NEWS
+++ b/NEWS
@@ -272,6 +272,8 @@ documents those changes that are of interest to users and admins.
 =========================
  - In sched/wiki - Add support for CMD=SIGNALJOB to accept option
    of VALUE=SIGXXX in addition to VALUE=# and VALUE=XXX options
+ - Correct logic for job allocation with task count (srun -n ...) AND
+   FastSchedule=0 AND low CPUs count in Slurm's node configuration.
 
 * Changes in SLURM 1.1.34
 =========================
diff --git a/src/slurmctld/node_scheduler.c b/src/slurmctld/node_scheduler.c
index 952c043d44b..c888b63ad80 100644
--- a/src/slurmctld/node_scheduler.c
+++ b/src/slurmctld/node_scheduler.c
@@ -885,7 +885,16 @@ _add_node_set_info(struct node_set *node_set_ptr,
 				fatal("bit_copy malloc failure");
 		}
                 *node_cnt += node_set_ptr->nodes;
-                *cpu_cnt  += node_set_ptr->nodes * node_set_ptr->cpus_per_node;
+		if (slurmctld_conf.fast_schedule) {
+			*cpu_cnt  += node_set_ptr->nodes * 
+				node_set_ptr->cpus_per_node;
+		} else {
+			for (i = 0; i < node_record_count; i++) {
+				if (bit_test (node_set_ptr->my_bitmap, i) == 0)
+					continue;
+				*cpu_cnt  += node_record_table_ptr[i].cpus;
+			}
+		}
         } else {
                 for (i = 0; i < node_record_count; i++) {
                         if (bit_test (node_set_ptr->my_bitmap, i) == 0)
@@ -896,8 +905,8 @@ _add_node_set_info(struct node_set *node_set_ptr,
 				SELECT_ALLOC_CPUS, 
 				&alloc_cpus);
                         if (error_code != SLURM_SUCCESS) {
-				error(" cons_res: Invalid Node reference", 
-				      node_record_table_ptr[i]);
+				error("cons_res: Invalid Node reference %s", 
+				      node_record_table_ptr[i].name);
 				return error_code;
 			}
                         alloc_mem = 0;
@@ -906,14 +915,21 @@ _add_node_set_info(struct node_set *node_set_ptr,
 				SELECT_ALLOC_MEMORY, 
 				&alloc_mem);
                         if (error_code != SLURM_SUCCESS) {
-				error(" cons_res: Invalid Node reference", 
-				      node_record_table_ptr[i]);
+				error("cons_res: Invalid Node reference %s", 
+				      node_record_table_ptr[i]. name);
 				return error_code;
 			}
-			this_cpu_cnt = node_set_ptr->cpus_per_node - 
-				alloc_cpus;
-			this_mem_cnt = (node_set_ptr->real_memory - 
-				alloc_mem) - mem_cnt;                       
+			if (slurmctld_conf.fast_schedule) {
+				this_cpu_cnt = node_set_ptr->cpus_per_node - 
+					alloc_cpus;
+				this_mem_cnt = (node_set_ptr->real_memory - 
+					alloc_mem) - mem_cnt;
+			} else {
+				this_cpu_cnt = node_record_table_ptr[i].cpus -
+					alloc_cpus;
+				this_mem_cnt = (node_record_table_ptr[i].real_memory -
+					alloc_mem) - mem_cnt;
+			}                       
 
 			debug3("_add_node_set_info %d %s this_cpu_cnt %d"
 			       " this_mem_cnt %d", job_id, 
-- 
GitLab