mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: Alex Shi <alex.shi@intel.com>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Lukasz Majewski <l.majewski@samsung.com>,
	Jonghwa Lee <jonghwa3.lee@samsung.com>,
	Myungjoo Ham <myungjoo.ham@samsung.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: [PATCH 2/2] sched:fix: Signed overflow prevention for vacancy calculation
Date: Thu, 23 May 2013 10:34:24 +0200	[thread overview]
Message-ID: <1369298064-14998-2-git-send-email-l.majewski@samsung.com> (raw)
In-Reply-To: <1369298064-14998-1-git-send-email-l.majewski@samsung.com>

Nasty bug with vacancy calculation has been fixed.
In the if statement the FULL_UTIL is a large constant, max_cfs_util()
returns unsigned and putil is also defined as unsigned. The outcome
is that this condition is always true.

As observed, this was the reason for frequent jumps of processes between
CPUs.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
This patch was developed on top of the following Alex's repository:
https://github.com/alexshi/power-scheduling/commits/power-scheduling
---
 kernel/sched/fair.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 14d29b3..8b07f6c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3476,9 +3476,10 @@ find_leader_cpu(struct sched_group *group, struct task_struct *p, int this_cpu,
 	do_div(tmp, (p->se.avg.runnable_avg_period + 1));
 	putil = (unsigned) tmp;
 
+	vacancy = (int) (FULL_UTIL - max_cfs_util(this_cpu, wakeup) -
+			 (putil << 2));
 	/* bias toward local cpu */
-	if (cpumask_test_cpu(this_cpu, tsk_cpus_allowed(p)) &&
-		FULL_UTIL - max_cfs_util(this_cpu, wakeup) - (putil << 2) > 0)
+	if (cpumask_test_cpu(this_cpu, tsk_cpus_allowed(p)) && vacancy > 0)
 		return this_cpu;
 
 	/* Traverse only the allowed CPUs */
-- 
1.7.10.4


  reply	other threads:[~2013-05-23  8:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23  8:34 [PATCH 1/2] sched: Use do_div() for 64 bit division at power utilization calculation (putil) Lukasz Majewski
2013-05-23  8:34 ` Lukasz Majewski [this message]
2013-05-30  1:50   ` [PATCH 2/2] sched:fix: Signed overflow prevention for vacancy calculation Alex Shi
2013-05-30  1:48 ` [PATCH 1/2] sched: Use do_div() for 64 bit division at power utilization calculation (putil) Alex Shi
2013-05-31  6:14   ` Lukasz Majewski

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=1369298064-14998-2-git-send-email-l.majewski@samsung.com \
    --to=l.majewski@samsung.com \
    --cc=alex.shi@intel.com \
    --cc=jonghwa3.lee@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=vincent.guittot@linaro.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®