ChangeSet 1.2065.3.22, 2005/03/12 08:26:34-08:00, [EMAIL PROTECTED]
[PATCH] sched: timestamp fixes
Some fixes for unsynchronised TSCs. A task's timestamp may have been
set by
another CPU. Although we try to adjust this correctly with the
timestamp_last_tick field, there is no guarantee this will be exactly
right.
Signed-off-by: Nick Piggin <[EMAIL PROTECTED]>
Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
sched.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff -Nru a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c 2005-03-12 21:29:17 -08:00
+++ b/kernel/sched.c 2005-03-12 21:29:17 -08:00
@@ -650,6 +650,7 @@
static void recalc_task_prio(task_t *p, unsigned long long now)
{
+ /* Caller must always ensure 'now >= p->timestamp' */
unsigned long long __sleep_time = now - p->timestamp;
unsigned long sleep_time;
@@ -2663,9 +2664,11 @@
schedstat_inc(rq, sched_cnt);
now = sched_clock();
- if (likely(now - prev->timestamp < NS_MAX_SLEEP_AVG))
+ if (likely((long long)now - prev->timestamp < NS_MAX_SLEEP_AVG)) {
run_time = now - prev->timestamp;
- else
+ if (unlikely((long long)now - prev->timestamp < 0))
+ run_time = 0;
+ } else
run_time = NS_MAX_SLEEP_AVG;
/*
@@ -2742,6 +2745,8 @@
if (!rt_task(next) && next->activated > 0) {
unsigned long long delta = now - next->timestamp;
+ if (unlikely((long long)now - next->timestamp < 0))
+ delta = 0;
if (next->activated == 1)
delta = delta * (ON_RUNQUEUE_WEIGHT * 128 / 100) / 128;
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html