From 8f5ccb717e426d3863ac3835c47624851be20125 Mon Sep 17 00:00:00 2001
From: Marcin Stolarek <stolarek.marcin@gmail.com>
Date: Mon, 31 Mar 2014 10:12:43 -0700
Subject: [PATCH] select/cons_res - fix for preempt_mode=off

Do not overcommit partitions with PreemptMode=off
---
 src/plugins/select/cons_res/job_test.c | 13 ++++++++++++-
 src/plugins/select/serial/job_test.c   |  3 ++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/plugins/select/cons_res/job_test.c b/src/plugins/select/cons_res/job_test.c
index 778e7c6c127..555565dcd22 100644
--- a/src/plugins/select/cons_res/job_test.c
+++ b/src/plugins/select/cons_res/job_test.c
@@ -2318,9 +2318,20 @@ extern int cr_job_test(struct job_record *job_ptr, bitstr_t *node_bitmap,
 
 	/* remove existing allocations (jobs) from higher-priority partitions
 	 * from avail_cores */
+	if (select_debug_flags & DEBUG_FLAG_CPU_BIND) {
+		info("cons_res: cr_job_test: looking for higher-priority or "
+		     "PREEMPT_MODE_OFF part's to remove from avail_cores");
+	}
+
 	for (p_ptr = cr_part_ptr; p_ptr; p_ptr = p_ptr->next) {
-		if (p_ptr->part_ptr->priority <= jp_ptr->part_ptr->priority)
+		if ((p_ptr->part_ptr->priority <= jp_ptr->part_ptr->priority) &&
+		    (p_ptr->part_ptr->preempt_mode != PREEMPT_MODE_OFF)) {
+			if (select_debug_flags & DEBUG_FLAG_CPU_BIND) {
+				info("cons_res: cr_job_test: continuing on "
+				     "part: %s  ", p_ptr->part_ptr->name);
+			}
 			continue;
+		}
 		if (!p_ptr->row)
 			continue;
 		for (i = 0; i < p_ptr->num_rows; i++) {
diff --git a/src/plugins/select/serial/job_test.c b/src/plugins/select/serial/job_test.c
index 17fc1c4b29d..ed868ea552c 100644
--- a/src/plugins/select/serial/job_test.c
+++ b/src/plugins/select/serial/job_test.c
@@ -656,7 +656,8 @@ extern int cr_job_test(struct job_record *job_ptr, bitstr_t *bitmap, int mode,
 	/* remove existing allocations (jobs) from higher-priority partitions
 	 * from avail_cores */
 	for (p_ptr = cr_part_ptr; p_ptr; p_ptr = p_ptr->next) {
-		if (p_ptr->part_ptr->priority <= jp_ptr->part_ptr->priority)
+		if ((p_ptr->part_ptr->priority <= jp_ptr->part_ptr->priority) &&
+		    (p_ptr->part_ptr->preempt_mode != PREEMPT_MODE_OFF))
 			continue;
 		if (!p_ptr->row)
 			continue;
-- 
GitLab