The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
To: Gautham R Shenoy <ego@in.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	npiggin@suse.de, linux-kernel@vger.kernel.org,
	Srivatsa Vaddagiri <vatsa@in.ibm.com>
Subject: Re: [PATCH] sched: Improve readability in update_cpu_load() code
Date: Thu, 15 May 2008 20:32:30 +0530	[thread overview]
Message-ID: <20080515150230.GE14823@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080515145215.GD14823@linux.vnet.ibm.com>

On Thu, May 15, 2008 at 08:22:15PM +0530, Srivatsa Vaddagiri 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;

s/scale = 2<< i/scale = 2 << (i-1)

> 
> 	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
> $

[with above modification:]

this_load = 95, this_load1 = 2147483743


-- 
Regards,
vatsa

  reply	other threads:[~2008-05-15 14:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 13:04 [PATCH] sched: Improve readability in update_cpu_load() code Gautham R Shenoy
2008-05-15 14:52 ` Srivatsa Vaddagiri
2008-05-15 15:02   ` Srivatsa Vaddagiri [this message]
2008-05-15 15:15   ` Dmitry Adamushko
2008-05-15 15:31     ` Dmitry Adamushko
2008-05-15 17:11   ` Gautham R Shenoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080515150230.GE14823@linux.vnet.ibm.com \
    --to=vatsa@linux.vnet.ibm.com \
    --cc=ego@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=npiggin@suse.de \
    --cc=vatsa@in.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox