linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] DLS: fix select_task_rq_dl
@ 2012-04-09 12:39 Hillf Danton
  0 siblings, 0 replies; only message in thread
From: Hillf Danton @ 2012-04-09 12:39 UTC (permalink / raw)
  To: Dario Faggioli, Juri Lelli; +Cc: LKML, Hillf Danton

Check for CPU online is added for correct reference of rq->curr, and for the
chance to find another runqueue for given task.

We never find other runqueue if the current task could be peempted, no matter
its migratary or not. IOW, preempt check should never be bypassed.

BTW, SD_BALANCE_XXX matches DLS?

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

--- a/kernel/sched_dl.c	Mon Apr  9 19:39:56 2012
+++ b/kernel/sched_dl.c	Mon Apr  9 19:57:12 2012
@@ -806,8 +806,7 @@ static void yield_task_dl(struct rq *rq)

 static int find_later_rq(struct task_struct *task);

-static int
-select_task_rq_dl(struct task_struct *p, int sd_flag, int flags)
+static int select_task_rq_dl(struct task_struct *p, int sd_flag, int flags)
 {
 	struct task_struct *curr;
 	struct rq *rq;
@@ -815,36 +814,40 @@ select_task_rq_dl(struct task_struct *p,

 	cpu = task_cpu(p);

+	if (!cpu_online(cpu))
+		goto find;
+	if (!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)))
+		goto find;
+
 	if (sd_flag != SD_BALANCE_WAKE && sd_flag != SD_BALANCE_FORK)
 		goto out;

 	rq = cpu_rq(cpu);

 	rcu_read_lock();
-	curr = ACCESS_ONCE(rq->curr); /* unlocked access */

-	/*
-	 * If we are dealing with a -deadline task, we must
-	 * decide where to wake it up.
-	 * If it has a later deadline and the current task
-	 * on this rq can't move (provided the waking task
-	 * can!) we prefer to send it somewhere else. On the
-	 * other hand, if it has a shorter deadline, we
-	 * try to make it stay here, it might be important.
-	 */
-	if (unlikely(dl_task(curr)) &&
-	    (curr->dl.nr_cpus_allowed < 2 ||
-	     !dl_entity_preempt(&p->dl, &curr->dl)) &&
-	    (p->dl.nr_cpus_allowed > 1)) {
+	curr = ACCESS_ONCE(rq->curr);
+
+	if (!dl_task(curr))
+		goto unlock;
+
+	if (dl_entity_preempt(&p->dl, &curr->dl))
+		goto unlock;
+
+	rcu_read_unlock();
+find:
+	if (p->dl.nr_cpus_allowed > 1) {
 		int target = find_later_rq(p);

 		if (target != -1)
 			cpu = target;
 	}
-	rcu_read_unlock();

 out:
 	return cpu;
+unlock:
+	rcu_read_unlock();
+	goto out;
 }

 static void check_preempt_equal_dl(struct rq *rq, struct task_struct *p)
--

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-04-09 12:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-09 12:39 [PATCH] DLS: fix select_task_rq_dl Hillf Danton

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).