[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200703021735.55142.dada1@cosmosbay.com>
Date: Fri, 2 Mar 2007 17:35:55 +0100
From: Eric Dumazet <dada1@...mosbay.com>
To: Simon Arlott <simon@...e.lp0.eu>
Cc: akpm@...ux-foundation.org, Bill Irwin <bill.irwin@...cle.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
arjan@...ux.intel.com
Subject: Re: [PATCH (update 3)] timer: Run calc_load halfway through each round_jiffies second
On Friday 02 March 2007 16:15, Simon Arlott wrote:
> Whenever jiffies is started at a multiple of 5*HZ or wraps, calc_load is
> run exactly on the second which is when tasks using round_jiffies will
> be scheduled to run. This has a bad effect on the load average, making
> it tend towards 1.00 if a task happens to run every time the load is
> being calculated.
>
> This changes calc_load so that it updates load half a second after any
> tasks scheduled using round_jiffies.
>
Simon
I believe this patch is too complex/hazardous and may break exp decay
computation.
(Even if nobody care about avenrun[] those days :), do you ? )
You could just change LOAD_FREQ from (5*HZ) to (5*HZ+1)
#define LOAD_FREQ (5*HZ+1)
Mathematical proof (well... sort of)
$ cat prog.c
#define FSHIFT 11 /* nr of bits of precision */
#define FIXED_1 ((double)(1<<FSHIFT)) /* 1.0 as fixed-point */
#include <math.h>
#include <stdio.h>
int main()
{
printf("Old values :\n");
printf("#define EXP_1 %g\n", FIXED_1/exp(5.0/60.0));
printf("#define EXP_5 %g\n", FIXED_1/exp(5.0/(5*60.0)));
printf("#define EXP_15 %g\n", FIXED_1/exp(5.0/(15*60.0)));
printf("New values :\n");
printf("%g\n", FIXED_1/exp(5.01/60.0));
printf("%g\n", FIXED_1/exp(5.01/(5*60.0)));
printf("%g\n", FIXED_1/exp(5.01/(15*60.0)));
return 0;
}
# gcc -o prog prog.c -lm
# ./prog
Old values :
#define EXP_1 1884.25
#define EXP_5 2014.15
#define EXP_15 2036.65
New values :
1883.94
2014.08
2036.63
You can see that 5.01 instead of 5.00 second gives the same EXP_xx values.
So (5*HZ + 1) is safe. (because HZ >= 100)
Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists