[PATCH] DLS: fix select_task_rq_dl

From: Hillf Danton
Date: Mon Apr 09 2012 - 08:39:07 EST


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@xxxxxxxxx>
---

--- 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)
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/