Skip to contentSkip to conversation

sched: optimize activate_task for RT task

PATCH New Chen, Kenneth W 1 participant 1 message Nov 14, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: optimize activate_task for RT task

RT task does not participate in interactiveness priority and thus shouldn't be bothered with timestamp when task is being put on run queue. We should push all of the time calculation inside already existed if (!rt_task) block.

kernel/sched.c renamed from kernel/sched.c.orig +10 -12
@@ -936,20 +936,19 @@ static int recalc_task_prio(struct task_
  */
 static void activate_task(struct task_struct *p, struct rq *rq, int local)
 {
-	unsigned long long now;
-
-	now = sched_clock();
+	if (!rt_task(p)) {
+		unsigned long long now = sched_clock();
 #ifdef CONFIG_SMP
-	if (!local) {
-		/* Compensate for drifting sched_clock */
-		struct rq *this_rq = this_rq();
-		now = (now - this_rq->timestamp_last_tick)
-			+ rq->timestamp_last_tick;
-	}
+		if (!local) {
+			/* Compensate for drifting sched_clock */
+			struct rq *this_rq = this_rq();
+			now = (now - this_rq->timestamp_last_tick)
+				+ rq->timestamp_last_tick;
+		}
 #endif
-
-	if (!rt_task(p))
 		p->prio = recalc_task_prio(p, now);
+		p->timestamp = now;
+	}
 
 	/*
 	 * This checks to make sure it's not an uninterruptible task
@@ -973,7 +972,6 @@ static void activate_task(struct task_st
 			p->sleep_type = SLEEP_INTERACTIVE;
 		}
 	}
-	p->timestamp = now;
 
 	__activate_task(p, rq);
 }