All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Paul Turner <pjt@google.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	a.p.zijlstra@chello.nl, pjt@google.com, tglx@linutronix.de,
	mingo@elte.hu
Subject: [tip:sched/core] sched: Fix sign under-flows in wake_affine
Date: Wed, 26 Jan 2011 12:09:50 GMT	[thread overview]
Message-ID: <tip-e37b6a7b27b400c3aa488db8c6629a05095bc79c@git.kernel.org> (raw)
In-Reply-To: <20110122044851.734245014@google.com>

Commit-ID:  e37b6a7b27b400c3aa488db8c6629a05095bc79c
Gitweb:     http://git.kernel.org/tip/e37b6a7b27b400c3aa488db8c6629a05095bc79c
Author:     Paul Turner <pjt@google.com>
AuthorDate: Fri, 21 Jan 2011 20:44:59 -0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 26 Jan 2011 12:31:01 +0100

sched: Fix sign under-flows in wake_affine

While care is taken around the zero-point in effective_load to not exceed
the instantaneous rq->weight, it's still possible (e.g. using wake_idx != 0)
for (load + effective_load) to underflow.

In this case the comparing the unsigned values can result in incorrect balanced
decisions.

Signed-off-by: Paul Turner <pjt@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20110122044851.734245014@google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched_fair.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 3547699..ccecfec 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1432,7 +1432,7 @@ static inline unsigned long effective_load(struct task_group *tg, int cpu,
 
 static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
 {
-	unsigned long this_load, load;
+	s64 this_load, load;
 	int idx, this_cpu, prev_cpu;
 	unsigned long tl_per_task;
 	struct task_group *tg;
@@ -1471,8 +1471,8 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
 	 * Otherwise check if either cpus are near enough in load to allow this
 	 * task to be woken on this_cpu.
 	 */
-	if (this_load) {
-		unsigned long this_eff_load, prev_eff_load;
+	if (this_load > 0) {
+		s64 this_eff_load, prev_eff_load;
 
 		this_eff_load = 100;
 		this_eff_load *= power_of(prev_cpu);

  reply	other threads:[~2011-01-26 12:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-22  4:44 [patch 0/5] scheduler fixlets Paul Turner
2011-01-22  4:44 ` [patch 1/5] sched: fix sign under-flows in wake_affine Paul Turner
2011-01-26 12:09   ` tip-bot for Paul Turner [this message]
2011-01-22  4:45 ` [patch 2/5] sched: (cleanup) remove redundant cfs_rq checks Paul Turner
2011-01-26 12:10   ` [tip:sched/core] sched: Fix/remove " tip-bot for Paul Turner
2011-01-22  4:45 ` [patch 3/5] sched: simplify update_cfs_shares parameters Paul Turner
2011-01-26 12:11   ` [tip:sched/core] sched: Simplify " tip-bot for Paul Turner
2011-01-22  4:45 ` [patch 4/5] sched: use rq->clock_task instead of rq->clock for maintaining load averages Paul Turner
2011-01-26 12:10   ` [tip:sched/core] sched: Use rq->clock_task instead of rq->clock for correctly " tip-bot for Paul Turner
2011-01-22  4:45 ` [patch 5/5] sched: avoid expensive initial update_cfs_load() Paul Turner
2011-01-26 12:11   ` [tip:sched/core] sched: Avoid " tip-bot for Paul Turner
2011-01-26 12:36     ` Peter Zijlstra
2011-01-26 12:45   ` [tip:sched/core] sched: Avoid expensive initial update_cfs_load(), on UP too tip-bot for Peter Zijlstra
2011-01-27 11:58   ` tip-bot for Peter Zijlstra
2011-01-24 10:17 ` [patch 0/5] scheduler fixlets Peter Zijlstra

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=tip-e37b6a7b27b400c3aa488db8c6629a05095bc79c@git.kernel.org \
    --to=pjt@google.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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.