[PATCH, ZAPHOD] Fix load balancing problem due to timestamp

From: Peter Williams
Date: Tue Oct 05 2004 - 17:48:26 EST


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.

--
Peter Williams pwil3058@xxxxxxxxxxxxxx

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce
--- linux-2.6.9-rc3-mm2/kernel/sched.c 2004-10-05 15:17:09.000000000 +1000
+++ linux-2.6.9-rc3-mm2-mod/kernel/sched.c 2004-10-06 08:30:26.538386290 +1000
@@ -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 {