From 6f8d8eaffc218cb19b4cc9f5de890219cf067f76 Mon Sep 17 00:00:00 2001
From: Don Lipari <lipari1@llnl.gov>
Date: Wed, 16 Jun 2010 00:04:37 +0000
Subject: [PATCH] -- Manually merged the changes of revision 20487 to v2.1.10: 
   i.e., Fixed a fair-share calculation bug in the priority/multifactor plugin

---
 .../multifactor/priority_multifactor.c        | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/plugins/priority/multifactor/priority_multifactor.c b/src/plugins/priority/multifactor/priority_multifactor.c
index 9bc92b17168..58d0340cc1a 100644
--- a/src/plugins/priority/multifactor/priority_multifactor.c
+++ b/src/plugins/priority/multifactor/priority_multifactor.c
@@ -146,6 +146,9 @@ static int _apply_decay(double decay_factor)
 			continue;
 		assoc->usage->usage_raw *= decay_factor;
 		assoc->usage->grp_used_wall *= decay_factor;
+		if (assoc->user)
+			assoc_mgr_root_assoc->usage->usage_raw +=
+			assoc->usage->usage_raw;
 	}
 	list_iterator_destroy(itr);
 	slurm_mutex_unlock(&assoc_mgr_association_lock);
@@ -718,6 +721,8 @@ static void *_decay_thread(void *no_data)
 		debug3("Decay factor over %d seconds goes from %.15f -> %.15f",
 		       run_delta, decay_factor, real_decay);
 
+		assoc_mgr_root_assoc->usage->usage_raw = 1.0;
+
 		/* first apply decay to used time */
 		if(_apply_decay(real_decay) != SLURM_SUCCESS) {
 			error("problem applying decay");
@@ -781,12 +786,6 @@ static void *_decay_thread(void *no_data)
 
 				slurm_mutex_lock(&assoc_mgr_association_lock);
 				while(assoc) {
-					/* we don't want to make the
-					   root assoc responsible for
-					   keeping track of time
-					*/
-					if (assoc == assoc_mgr_root_assoc)
-						break;
 					assoc->usage->grp_used_wall +=
 						run_decay;
 					assoc->usage->usage_raw +=
@@ -794,13 +793,15 @@ static void *_decay_thread(void *no_data)
 					debug4("adding %f new usage to "
 					       "assoc %u (user='%s' acct='%s') "
 					       "raw usage is now %Lf.  Group "
-					       "wall added %d making it %f.",
+					       "wall added %f making it %f.",
 					       real_decay, assoc->id,
 					       assoc->user, assoc->acct,
 					       assoc->usage->usage_raw,
 					       run_decay,
 					       assoc->usage->grp_used_wall);
 
+					if (assoc == assoc_mgr_root_assoc)
+						break;
 					assoc = assoc->usage->parent_assoc_ptr;
 				}
 				slurm_mutex_unlock(&assoc_mgr_association_lock);
@@ -1035,10 +1036,9 @@ extern int priority_p_set_max_cluster_usage(uint32_t procs, uint32_t half_life)
 	last_procs = procs;
 	last_half_life = half_life;
 
-	/* get the total decay for the entire cluster */
-	assoc_mgr_root_assoc->usage->usage_raw =
-		(long double)procs * (long double)half_life * (long double)2;
+	assoc_mgr_root_assoc->usage->usage_raw = 1.0;
 	assoc_mgr_root_assoc->usage->usage_norm = 1.0;
+	assoc_mgr_root_assoc->usage->usage_efctv = 1.0;
 	debug3("Total possible cpu usage for half_life of %d secs "
 	       "on the system is %.0Lf",
 	       half_life, assoc_mgr_root_assoc->usage->usage_raw);
-- 
GitLab