From: Lei Wen <leiwen@marvell.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, <mingo@redhat.com>,
<leiwen@marvell.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] sched: fix underflow when doing fix_small_imbalance
Date: Tue, 18 Jun 2013 15:56:38 +0800 [thread overview]
Message-ID: <1371542198-29879-1-git-send-email-leiwen@marvell.com> (raw)
Since sds->max_load, sds->this_load, scaled_busy_load_per_task are all
unsigned long type, so it make even sds->max_load less than
sds->this_load, the statement as below would still be true.
(sds->max_load - sds->this_load + scaled_busy_load_per_task >=
(scaled_busy_load_per_task * imbn)
This would make load balance happen, even the busiest group's load is
less than local group's load...
Signed-off-by: Lei Wen <leiwen@marvell.com>
---
kernel/sched/fair.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c61a614..8d11a69 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4693,6 +4693,7 @@ void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds)
unsigned long tmp, pwr_now = 0, pwr_move = 0;
unsigned int imbn = 2;
unsigned long scaled_busy_load_per_task;
+ int balance;
if (sds->this_nr_running) {
sds->this_load_per_task /= sds->this_nr_running;
@@ -4708,8 +4709,9 @@ void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds)
* SCHED_POWER_SCALE;
scaled_busy_load_per_task /= sds->busiest->sgp->power;
- if (sds->max_load - sds->this_load + scaled_busy_load_per_task >=
- (scaled_busy_load_per_task * imbn)) {
+ balance = sds->max_load - sds->this_load
+ + scaled_busy_load_per_task * (1 - imbn);
+ if (balance >=0) {
env->imbalance = sds->busiest_load_per_task;
return;
}
--
1.7.10.4
reply other threads:[~2013-06-18 7:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1371542198-29879-1-git-send-email-leiwen@marvell.com \
--to=leiwen@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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
all inboxes | Powered by JetHome®