public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: correct how RT task is picked
@ 2011-05-10 13:04 Hillf Danton
  2011-05-11  8:43 ` Yong Zhang
  0 siblings, 1 reply; 14+ messages in thread
From: Hillf Danton @ 2011-05-10 13:04 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Mike Galbraith, Yong Zhang

When picking RT task for given CPU,
[1] if the cpu is invalid for cpumask test, right result could not be
reached even by further checking nr_cpus_allowed,
on the other hand, the input cpu is valid in two cases that
pick_next_highest_task_rt() is called, thus the invalid input cpu
looks over-concern.
[2] if the cpu is valid for cpumask test, further checking
nr_cpus_allowed looks overwork, since it is computed based on
cpus_allowed,
what is more, the combination of cpus_allowed and nr_cpus_allowed
could lead to incorrect result if the input cpu == rq->cpu, as in the
case of next_prio() where no pulling task is concerned.

In this work, invalid cpu is not removed but leads to negative result,
but nr_cpus_allowed is.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
---

--- a/kernel/sched_rt.c	2011-04-27 11:48:50.000000000 +0800
+++ b/kernel/sched_rt.c	2011-05-10 20:30:38.000000000 +0800
@@ -1149,10 +1149,12 @@ static void deactivate_task(struct rq *r

 static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu)
 {
-	if (!task_running(rq, p) &&
-	    (cpu < 0 || cpumask_test_cpu(cpu, &p->cpus_allowed)) &&
-	    (p->rt.nr_cpus_allowed > 1))
-		return 1;
+	if (!task_running(rq, p)) {
+		if (cpu < 0)
+			return 0;
+		if (cpumask_test_cpu(cpu, &p->cpus_allowed))
+			return 1;
+	}
 	return 0;
 }

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-05-19 12:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-10 13:04 [PATCH] sched: correct how RT task is picked Hillf Danton
2011-05-11  8:43 ` Yong Zhang
2011-05-11 13:44   ` Hillf Danton
2011-05-12 12:06     ` Yong Zhang
2011-05-18  1:38       ` Steven Rostedt
2011-05-18  2:31         ` Yong Zhang
2011-05-18 13:19           ` Hillf Danton
2011-05-18 13:24             ` Steven Rostedt
2011-05-18 14:46               ` Hillf Danton
2011-05-18 15:15                 ` Steven Rostedt
2011-05-18 15:20                   ` Peter Zijlstra
2011-05-19 12:49                     ` [PATCH resend] " Hillf Danton
2011-05-19  1:41                 ` [PATCH] " Yong Zhang
2011-05-19  1:44                   ` Yong Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox