From: Gautham R Shenoy <ego@in.ibm.com>
To: Ingo Molnar <mingo@elte.hu>, npiggin@suse.de
Cc: linux-kernel@vger.kernel.org, Srivatsa Vaddagiri <vatsa@in.ibm.com>
Subject: [PATCH] sched: Improve readability in update_cpu_load() code
Date: Thu, 15 May 2008 18:34:59 +0530 [thread overview]
Message-ID: <20080515130459.GA9650@in.ibm.com> (raw)
Author: Gautham R Shenoy <ego@in.ibm.com>
Date: Thu May 15 17:55:49 2008 +0530
sched: Improve readability in update_cpu_load() code
Currently the cpu_load[i] is calculated as:
this_rq->cpu_load[i] = (old_load*(scale-1) + new_load) >> i;
However, since scale = 2^i, this can be simplified as:
this_rq->cpu_load[i] = old_load + ((new_load - old_load) >> i);
Makes it easier to read.
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
diff --git a/kernel/sched.c b/kernel/sched.c
index 2d7d8f1..e1a6985 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2921,7 +2921,7 @@ static void update_cpu_load(struct rq *this_rq)
*/
if (new_load > old_load)
new_load += scale-1;
- this_rq->cpu_load[i] = (old_load*(scale-1) + new_load) >> i;
+ this_rq->cpu_load[i] = old_load + ((new_load - old_load) >> i);
}
}
--
Thanks and Regards
gautham
next reply other threads:[~2008-05-15 13:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-15 13:04 Gautham R Shenoy [this message]
2008-05-15 14:52 ` [PATCH] sched: Improve readability in update_cpu_load() code Srivatsa Vaddagiri
2008-05-15 15:02 ` Srivatsa Vaddagiri
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=20080515130459.GA9650@in.ibm.com \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.