Re: PROBLEM: high load average when idle

From: Linus Torvalds
Date: Wed Oct 03 2007 - 14:03:45 EST




On Wed, 3 Oct 2007, Chuck Ebbert wrote:
>
> But we reduce the number of samples because some ticks just never
> happen when the timers get rounded:
>
> No rounding:
>
> tick ............... tick
> 1 running 1 running
>
> Rounded:
>
> tick
> 2 running
>
> In the first case the average is 1, but it's 2 in the second.

In fact, I think this is it!

The load average is not calculated every tick, because that's not just
expensive, but we also want to have some time-based decay. So it's
calculated every LOAD_FREQ ticks.

And guess what: LOAD_FREQ is defined to be exactly five seconds.

So imagine if the timer gets to be in sync with another event that happens
every five seconds - let's pick at random a 5-second JBD transaction
thing?

Anders - does this idiotic patch make a difference for you?

Without this, I can easily imagine that the rounding code tends to try to
round to an even second, and the load-average code generally also runs at
even seconds!

Linus

---
include/linux/sched.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index a01ac6d..643de0f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -113,7 +113,7 @@ extern unsigned long avenrun[]; /* Load averages */

#define FSHIFT 11 /* nr of bits of precision */
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
-#define LOAD_FREQ (5*HZ) /* 5 sec intervals */
+#define LOAD_FREQ (5*HZ+1) /* ~5 sec intervals */
#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
#define EXP_5 2014 /* 1/exp(5sec/5min) */
#define EXP_15 2037 /* 1/exp(5sec/15min) */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/