Skip to contentSkip to conversation

Fix load balancing problem due to timestamp

PATCH New Peter Williams 1 participant 1 message Oct 5, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix load balancing problem due to timestamp

Please find attached a patch (against 2.6.9-rc3-mm2) that fixes the load balancing problems caused by timestamp being larger than timestamp_last_tick.

Signature · 4 lines
Peter Williams                                   [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce
kernel/sched.c +3 -7
@@ -327,7 +327,7 @@ static inline unsigned int task_timeslic
 	return time_slice_ticks;
 }
 
-#define task_hot(p, sd) ((p)->rq->timestamp_last_tick - (p)->timestamp < (sd)->cache_hot_time)
+#define task_hot(p, sd) ((long long)((p)->rq->timestamp_last_tick - (p)->timestamp) < (long long)(sd)->cache_hot_time)
 
 /*
  * These are the runqueue data structures:
@@ -1196,7 +1196,6 @@ static void activate_task(task_t *p)
 	unsigned long long now = adjusted_sched_clock(p);
 
 	recalc_task_prio(p, now);
-	p->timestamp = now;
 	p->time_slice = task_timeslice(p);
 	p->flags &= ~PF_UISLEEP;
 
@@ -1712,7 +1711,7 @@ void fastcall sched_fork(task_t *p)
 	 * Give the child a new timeslice
 	 */
 	p->time_slice = task_timeslice(p);
-	p->timestamp = sched_clock();
+	p->timestamp = 0;
 	/*
 	 * Initialize the scheduling statistics and bonus counters
 	 */
@@ -4750,10 +4749,7 @@ static void __migrate_task(struct task_s
 		deactivate_task(p);
 		delta_delay_stats(p, adjusted_sched_clock(p));
 		set_task_cpu(p, dest_cpu);
-		/*
-		 *  activate_task() will set the timestamp correctly so there's
-		 *  no need to adjust it here
-		 */
+		adjust_timestamp(p, rq_src);
 		activate_task(p);
 		preempt_curr_if_warranted(p);
 	} else {