From 39a29ebeaf4da8db704fbccb3a524fd0579ce437 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Fri, 2 Mar 2007 14:57:45 +0000 Subject: timer: Run calc_load halfway through each round_jiffies second --- kernel/timer.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/timer.c b/kernel/timer.c index 6663a87..4abead0 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1226,17 +1226,19 @@ EXPORT_SYMBOL(avenrun); static inline void calc_load(unsigned long ticks) { unsigned long active_tasks; /* fixed-point */ - static int count = LOAD_FREQ; + static int count = 0; count -= ticks; - if (unlikely(count < 0)) { + if (unlikely(count <= 0)) { active_tasks = count_active_tasks(); do { CALC_LOAD(avenrun[0], EXP_1, active_tasks); CALC_LOAD(avenrun[1], EXP_5, active_tasks); CALC_LOAD(avenrun[2], EXP_15, active_tasks); count += LOAD_FREQ; - } while (count < 0); + } while (count <= 0); + + count = round_jiffies_relative(count + HZ/2) - HZ/2; } } -- 1.5.0.1