diff options
author | Ingo Molnar <mingo@elte.hu> | 2007-08-10 17:05:11 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2007-08-10 17:05:11 -0400 |
commit | 529c77261bccd9d37f110f58b0753d95beaa9fa2 (patch) | |
tree | fff049581ceaa06591ba07938bb370a0ccee7293 /kernel/sched.c | |
parent | ac07860264bd2b18834d3fa3be47032115524cea (diff) |
sched: improve rq-clock overflow logic
improve the rq-clock overflow logic: limit the absolute rq->clock
delta since the last scheduler tick, instead of limiting the delta
itself.
tested by Arjan van de Ven - whole laptop was misbehaving due to
an incorrectly calibrated cpu_khz confusing sched_clock().
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index b0afd8db1396..6247e4a8350f 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -263,6 +263,7 @@ struct rq { | |||
263 | 263 | ||
264 | unsigned int clock_warps, clock_overflows; | 264 | unsigned int clock_warps, clock_overflows; |
265 | unsigned int clock_unstable_events; | 265 | unsigned int clock_unstable_events; |
266 | u64 tick_timestamp; | ||
266 | 267 | ||
267 | atomic_t nr_iowait; | 268 | atomic_t nr_iowait; |
268 | 269 | ||
@@ -341,8 +342,11 @@ static void __update_rq_clock(struct rq *rq) | |||
341 | /* | 342 | /* |
342 | * Catch too large forward jumps too: | 343 | * Catch too large forward jumps too: |
343 | */ | 344 | */ |
344 | if (unlikely(delta > 2*TICK_NSEC)) { | 345 | if (unlikely(clock + delta > rq->tick_timestamp + TICK_NSEC)) { |
345 | clock++; | 346 | if (clock < rq->tick_timestamp + TICK_NSEC) |
347 | clock = rq->tick_timestamp + TICK_NSEC; | ||
348 | else | ||
349 | clock++; | ||
346 | rq->clock_overflows++; | 350 | rq->clock_overflows++; |
347 | } else { | 351 | } else { |
348 | if (unlikely(delta > rq->clock_max_delta)) | 352 | if (unlikely(delta > rq->clock_max_delta)) |
@@ -3308,9 +3312,16 @@ void scheduler_tick(void) | |||
3308 | int cpu = smp_processor_id(); | 3312 | int cpu = smp_processor_id(); |
3309 | struct rq *rq = cpu_rq(cpu); | 3313 | struct rq *rq = cpu_rq(cpu); |
3310 | struct task_struct *curr = rq->curr; | 3314 | struct task_struct *curr = rq->curr; |
3315 | u64 next_tick = rq->tick_timestamp + TICK_NSEC; | ||
3311 | 3316 | ||
3312 | spin_lock(&rq->lock); | 3317 | spin_lock(&rq->lock); |
3313 | __update_rq_clock(rq); | 3318 | __update_rq_clock(rq); |
3319 | /* | ||
3320 | * Let rq->clock advance by at least TICK_NSEC: | ||
3321 | */ | ||
3322 | if (unlikely(rq->clock < next_tick)) | ||
3323 | rq->clock = next_tick; | ||
3324 | rq->tick_timestamp = rq->clock; | ||
3314 | update_cpu_load(rq); | 3325 | update_cpu_load(rq); |
3315 | if (curr != rq->idle) /* FIXME: needed? */ | 3326 | if (curr != rq->idle) /* FIXME: needed? */ |
3316 | curr->sched_class->task_tick(rq, curr); | 3327 | curr->sched_class->task_tick(rq, curr); |