From 27155dc808d068f74b8fbf0a27750e91a9941c54 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Tue, 24 Apr 2012 11:30:33 -0700
Subject: [PATCH] Fix to job preemption logic to preempt multiple jobs at the
 same time.

---
 NEWS                                          |  1 +
 src/plugins/select/cons_res/select_cons_res.c | 25 +++++++++++++------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index 05961e024cc..8d37ad7caf9 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,7 @@ documents those changes that are of interest to users and admins.
  -- CRAY - fix for handling memory requests from user for an allocation.
  -- Add support for switches parameter to the job_submit/lua plugin. Work by
     Par Andersson, NSC.
+ -- Fix to job preemption logic to preempt multiple jobs at the same time.
 
 * Changes in SLURM 2.3.4
 ========================
diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index 02413b03d8d..7534a9292c9 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -1577,22 +1577,34 @@ top:	orig_map = bit_copy(save_bitmap);
 					 cr_type, job_node_req,
 					 select_node_cnt,
 					 future_part, future_usage);
-			tmp_job_ptr->details->usable_nodes =
-				 bit_overlap(bitmap, tmp_job_ptr->node_bitmap);
+			tmp_job_ptr->details->usable_nodes = 0;
 			/*
 			 * If successful, set the last job's usable count to a
 			 * large value so that it will be first after sorting.
+			 * usable_nodes count set to zero above to eliminate
+			 * values previously set to 9999.
 			 * Note: usable_count is only used for sorting purposes
 			 */
 			if (rc == SLURM_SUCCESS) {
-				if (pass_count++ ||
-				    (list_count(preemptee_candidates) == 1))
-					break;
 				tmp_job_ptr->details->usable_nodes = 9999;
+				list_iterator_reset(job_iterator);
+				while ((tmp_job_ptr = (struct job_record *)
+					list_next(job_iterator))) {
+					if (tmp_job_ptr->details->usable_nodes
+					    == 9999)
+						break;
+					tmp_job_ptr->details->usable_nodes =
+						bit_overlap(bitmap,
+							    tmp_job_ptr->
+							    node_bitmap);
+				}
 				while ((tmp_job_ptr = (struct job_record *)
 					list_next(job_iterator))) {
 					tmp_job_ptr->details->usable_nodes = 0;
 				}
+				if (pass_count++ ||
+				    (list_count(preemptee_candidates) == 1))
+					break;
 				list_sort(preemptee_candidates,
 					  (ListCmpF)_sort_usable_nodes_dec);
 				FREE_NULL_BITMAP(orig_map);
@@ -1622,9 +1634,6 @@ top:	orig_map = bit_copy(save_bitmap);
 				    (mode != PREEMPT_MODE_CHECKPOINT) &&
 				    (mode != PREEMPT_MODE_CANCEL))
 					continue;
-				if (bit_overlap(bitmap,
-						tmp_job_ptr->node_bitmap) == 0)
-					continue;
 				if (tmp_job_ptr->details->usable_nodes == 0)
 					continue;
 				list_append(*preemptee_job_list,
-- 
GitLab