Skip to contentSkip to conversation

sched: smpnice - fix average load per run queue calculations

PATCH In review Peter Williams 1 participant 2 messages Feb 27, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: smpnice - fix average load per run queue calculations

The logical value to use for the average load per task on a run queue without any runnable tasks is the "default" load for a nice==0 task. Failure to do this may lead to anomalies in try_to_wake_up(), etc.

Peter

Signature · 4 lines
Peter Williams                                   [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce
kernel/sched.c +1 -1
Index: MM-2.6.X/kernel/sched.c
===================================================================
@@ -1058,7 +1058,7 @@ static inline unsigned long cpu_avg_load
 	runqueue_t *rq = cpu_rq(cpu);
 	unsigned long n = rq->nr_running;
 
-	return n ?  rq->raw_weighted_load / n : rq->raw_weighted_load;
+	return n ?  rq->raw_weighted_load / n : SCHED_LOAD_SCALE;
 }
 
 /*
#1 lore raw
Quoted 3 lines · Peter Williams

The logical value to use for the average load per task on a run queue without any runnable tasks is the "default" load for a nice==0 task. Failure to do this may lead to anomalies in try_to_wake_up(), etc.

I missed a bit. Here's a fixed patch.

Sorry,
Peter

Signature · 4 lines
Peter Williams                                   [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce
kernel/sched.c +3 -1
Index: MM-2.6.X/kernel/sched.c
===================================================================
@@ -1058,7 +1058,7 @@ static inline unsigned long cpu_avg_load
 	runqueue_t *rq = cpu_rq(cpu);
 	unsigned long n = rq->nr_running;
 
-	return n ?  rq->raw_weighted_load / n : rq->raw_weighted_load;
+	return n ?  rq->raw_weighted_load / n : SCHED_LOAD_SCALE;
 }
 
 /*
@@ -2153,6 +2153,8 @@ find_busiest_group(struct sched_domain *
 			min(busiest_load_per_task, max_load);
 		if (this_nr_running)
 			this_load_per_task /= this_nr_running;
+		else
+			this_load_per_task = SCHED_LOAD_SCALE;
 		pwr_now += this->cpu_power *
 			min(this_load_per_task, this_load);
 		pwr_now /= SCHED_LOAD_SCALE;