public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] DLS: cleanup pulling task
@ 2012-04-07  9:59 Hillf Danton
  2012-04-07 10:14 ` Hillf Danton
  0 siblings, 1 reply; 3+ messages in thread
From: Hillf Danton @ 2012-04-07  9:59 UTC (permalink / raw)
  To: Dario Faggioli, Juri Lelli; +Cc: LKML, Hillf Danton

First add check for CPU online.
Second initialize dmin to be as minimum as possible.
Third dl_time_before is replaced with dl_entity_preempt for easy read.

Due to re-init of dmin, a couple of preempt checks are removed.

With runqueue lock, a couple of caution checks are also removed.

Finally the jump label, skip, is replaced with unlock.

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

--- a/kernel/sched_dl.c	Sat Apr  7 15:00:28 2012
+++ b/kernel/sched_dl.c	Sat Apr  7 17:33:44 2012
@@ -1287,71 +1287,53 @@ static void push_dl_tasks(struct rq *rq)

 static int pull_dl_task(struct rq *this_rq)
 {
-	int this_cpu = this_rq->cpu, ret = 0, cpu;
-	struct task_struct *p;
-	struct rq *src_rq;
-	u64 dmin = LONG_MAX;
+	int this_cpu = this_rq->cpu;
+	int cpu;
+	u64 dmin;
+	int ret = 0;

 	if (likely(!dl_overloaded(this_rq)))
 		return 0;

-	for_each_cpu(cpu, this_rq->rd->dlo_mask) {
+	if (this_rq->dl.dl_nr_running)
+		dmin = this_rq->dl.earliest_dl.curr;
+	else
+		dmin = -1ULL;
+
+	for_each_cpu_and(cpu, this_rq->rd->dlo_mask, cpu_online_mask) {
+		struct task_struct *p;
+		struct rq *src_rq;
+
 		if (this_cpu == cpu)
 			continue;

 		src_rq = cpu_rq(cpu);

-		/*
-		 * It looks racy, abd it is! However, as in sched_rt.c,
-		 * we are fine with this.
-		 */
-		if (this_rq->dl.dl_nr_running &&
-		    dl_time_before(this_rq->dl.earliest_dl.curr,
-				   src_rq->dl.earliest_dl.next))
+		/* Racy without runqueue lock, but we are fine now */
+		if (!dl_entity_preempt(src_rq->dl.earliest_dl.next, dmin))
 			continue;

-		/* Might drop this_rq->lock */
 		double_lock_balance(this_rq, src_rq);

-		/*
-		 * If there are no more pullable tasks on the
-		 * rq, we're done with it.
-		 */
 		if (src_rq->dl.dl_nr_running <= 1)
-			goto skip;
+			goto unlock;

 		p = pick_next_earliest_dl_task(src_rq, this_cpu);

-		/*
-		 * We found a task to be pulled if:
-		 *  - it preempts our current (if there's one),
-		 *  - it will preempt the last one we pulled (if any).
-		 */
-		if (p && dl_time_before(p->dl.deadline, dmin) &&
-		    (!this_rq->dl.dl_nr_running ||
-		     dl_time_before(p->dl.deadline,
-				    this_rq->dl.earliest_dl.curr))) {
-			WARN_ON(p == src_rq->curr);
-			WARN_ON(!p->on_rq);
-
-			/*
-			 * Then we pull iff p has actually an earlier
-			 * deadline than the current task of its runqueue.
-			 */
-			if (dl_time_before(p->dl.deadline,
-					   src_rq->curr->dl.deadline))
-				goto skip;
+		/* With runqueue lock, recheck preempty */
+		if (p && dl_entity_preempt(p->dl.deadline, dmin)) {

-			ret = 1;
+			/* We dont pull running task */
+			if (p == src_rq->curr)
+				goto unlock;

 			deactivate_task(src_rq, p, 0);
 			set_task_cpu(p, this_cpu);
 			activate_task(this_rq, p, 0);
+			ret++;
 			dmin = p->dl.deadline;
-
-			/* Is there any other task even earlier? */
 		}
-skip:
+unlock:
 		double_unlock_balance(this_rq, src_rq);
 	}

--

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

end of thread, other threads:[~2012-04-22  9:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-07  9:59 [PATCH] DLS: cleanup pulling task Hillf Danton
2012-04-07 10:14 ` Hillf Danton
2012-04-22  9:48   ` Juri Lelli

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