linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Shi <alex.shi@intel.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, suresh.b.siddha@intel.com,
	alex.shi@intel.com
Subject: [PATCH 2/2] sched: fix a logical error in select_task_rq_fair
Date: Thu, 26 Jul 2012 13:27:26 +0800	[thread overview]
Message-ID: <1343280446-24019-2-git-send-email-alex.shi@intel.com> (raw)
In-Reply-To: <1343280446-24019-1-git-send-email-alex.shi@intel.com>

If find_idlest_cpu() return '-1', and sd->child is NULL. The function
select_task_rq_fair will return -1. That is not the function's purpose.

The patch introduced a latest_cpu as temporay varible to store
find_idlest_cpu() return value, and let new_cpu to store the latest
workable cpu. If find_idlest_cpu() doesn't find idlest cpu, we still
have a latest workable cpu.

Signed-off-by: Alex Shi <alex.shi@intel.com>
---
 kernel/sched/fair.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8a1db69..7e4bab48 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2730,6 +2730,7 @@ select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flags)
 		int load_idx = sd->forkexec_idx;
 		struct sched_group *group;
 		int weight;
+		int latest_cpu;
 
 		if (!(sd->flags & sd_flag)) {
 			sd = sd->child;
@@ -2745,8 +2746,12 @@ select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flags)
 			continue;
 		}
 
-		new_cpu = find_idlest_cpu(group, p, cpu);
-		if (new_cpu == -1 || new_cpu == cpu) {
+		latest_cpu = find_idlest_cpu(group, p, cpu);
+
+		if (latest_cpu != -1)
+			new_cpu = latest_cpu;
+
+		if (latest_cpu == -1 || latest_cpu == cpu) {
 			/* Now try balancing at a lower domain level of cpu */
 			sd = sd->child;
 			continue;
-- 
1.7.5.4


  reply	other threads:[~2012-07-26  5:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26  5:27 [PATCH 1/2] sched: recover SD_WAKE_AFFINE in select_task_rq_fair and code clean up Alex Shi
2012-07-26  5:27 ` Alex Shi [this message]
2012-07-26  8:17   ` [PATCH 2/2] sched: fix a logical error in select_task_rq_fair Peter Zijlstra
2012-07-26  9:11     ` Alex Shi
2012-07-27  1:50       ` Alex Shi
2012-07-26  9:37 ` [PATCH 1/2] sched: recover SD_WAKE_AFFINE in select_task_rq_fair and code clean up Mike Galbraith
2012-07-26  9:42   ` Alex Shi
2012-07-27  1:47   ` Alex Shi
2012-07-27  3:22     ` Mike Galbraith
2012-07-27  8:32     ` Peter Zijlstra
2012-07-27 14:42       ` Alex Shi
2012-08-13 12:33       ` Alex Shi
2012-08-13 17:14         ` [tip:sched/core] " tip-bot for Alex Shi

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=1343280446-24019-2-git-send-email-alex.shi@intel.com \
    --to=alex.shi@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=suresh.b.siddha@intel.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;
as well as URLs for NNTP newsgroup(s).