Re: [PATCH] sched: Improve readability in update_cpu_load() code

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Gautham R Shenoy <ego@...>
Cc: Ingo Molnar <mingo@...>, <npiggin@...>, <linux-kernel@...>, Srivatsa Vaddagiri <vatsa@...>
Date: Thursday, May 15, 2008 - 10:52 am

On Thu, May 15, 2008 at 06:34:59PM +0530, Gautham R Shenoy wrote:

This wont work when new_load < old_load ..

For ex: I tried this prog:

#include <stdio.h>

main()
{
	unsigned long old_load = 100, new_load = 90, this_load, this_load1;
	int i = 1, scale = 2 << i;

	this_load = (old_load*(scale-1) + new_load) >> i;
	this_load1 = old_load + ((new_load - old_load) >> i);

	printf ("this_load = %u, this_load1 = %u \n", this_load, this_load1);
}

This is what I get:

$ ./a.out
this_load = 195, this_load1 = 2147483743
$

	

-- 
Regards,
vatsa
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] sched: Improve readability in update_cpu_load() code, Gautham R Shenoy, (Thu May 15, 9:04 am)
Re: [PATCH] sched: Improve readability in update_cpu_load() ..., Srivatsa Vaddagiri, (Thu May 15, 10:52 am)
Re: [PATCH] sched: Improve readability in update_cpu_load() ..., Dmitry Adamushko, (Thu May 15, 11:15 am)
Re: [PATCH] sched: Improve readability in update_cpu_load() ..., Dmitry Adamushko, (Thu May 15, 11:31 am)
Re: [PATCH] sched: Improve readability in update_cpu_load() ..., Srivatsa Vaddagiri, (Thu May 15, 11:02 am)