Commit 2daa3577 authored by Ingo Molnar's avatar Ingo Molnar

sched: optimize activate_task()

optimize activate_task() by removing update_rq_clock() from it.
(and add update_rq_clock() to all callsites of activate_task() that
did not have it before.)
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent c3b64f1e
...@@ -910,8 +910,6 @@ static int effective_prio(struct task_struct *p) ...@@ -910,8 +910,6 @@ static int effective_prio(struct task_struct *p)
*/ */
static void activate_task(struct rq *rq, struct task_struct *p, int wakeup) static void activate_task(struct rq *rq, struct task_struct *p, int wakeup)
{ {
update_rq_clock(rq);
if (p->state == TASK_UNINTERRUPTIBLE) if (p->state == TASK_UNINTERRUPTIBLE)
rq->nr_uninterruptible--; rq->nr_uninterruptible--;
...@@ -1510,6 +1508,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync) ...@@ -1510,6 +1508,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
out_activate: out_activate:
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
update_rq_clock(rq);
activate_task(rq, p, 1); activate_task(rq, p, 1);
/* /*
* Sync wakeups (i.e. those types of wakeups where the waker * Sync wakeups (i.e. those types of wakeups where the waker
...@@ -2117,6 +2116,7 @@ static void pull_task(struct rq *src_rq, struct task_struct *p, ...@@ -2117,6 +2116,7 @@ static void pull_task(struct rq *src_rq, struct task_struct *p,
update_rq_clock(src_rq); update_rq_clock(src_rq);
deactivate_task(src_rq, p, 0); deactivate_task(src_rq, p, 0);
set_task_cpu(p, this_cpu); set_task_cpu(p, this_cpu);
__update_rq_clock(this_rq);
activate_task(this_rq, p, 0); activate_task(this_rq, p, 0);
/* /*
* Note that idle threads have a prio of MAX_PRIO, for this test * Note that idle threads have a prio of MAX_PRIO, for this test
...@@ -4207,11 +4207,10 @@ int sched_setscheduler(struct task_struct *p, int policy, ...@@ -4207,11 +4207,10 @@ int sched_setscheduler(struct task_struct *p, int policy,
spin_unlock_irqrestore(&p->pi_lock, flags); spin_unlock_irqrestore(&p->pi_lock, flags);
goto recheck; goto recheck;
} }
on_rq = p->se.on_rq;
if (on_rq) {
update_rq_clock(rq); update_rq_clock(rq);
on_rq = p->se.on_rq;
if (on_rq)
deactivate_task(rq, p, 0); deactivate_task(rq, p, 0);
}
oldprio = p->prio; oldprio = p->prio;
__setscheduler(rq, p, policy, param->sched_priority); __setscheduler(rq, p, policy, param->sched_priority);
if (on_rq) { if (on_rq) {
...@@ -4969,6 +4968,7 @@ static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu) ...@@ -4969,6 +4968,7 @@ static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
} }
set_task_cpu(p, dest_cpu); set_task_cpu(p, dest_cpu);
if (on_rq) { if (on_rq) {
update_rq_clock(rq_dest);
activate_task(rq_dest, p, 0); activate_task(rq_dest, p, 0);
check_preempt_curr(rq_dest, p); check_preempt_curr(rq_dest, p);
} }
...@@ -6623,14 +6623,13 @@ void normalize_rt_tasks(void) ...@@ -6623,14 +6623,13 @@ void normalize_rt_tasks(void)
goto out_unlock; goto out_unlock;
#endif #endif
update_rq_clock(rq);
on_rq = p->se.on_rq; on_rq = p->se.on_rq;
if (on_rq) { if (on_rq)
update_rq_clock(task_rq(p)); deactivate_task(rq, p, 0);
deactivate_task(task_rq(p), p, 0);
}
__setscheduler(rq, p, SCHED_NORMAL, 0); __setscheduler(rq, p, SCHED_NORMAL, 0);
if (on_rq) { if (on_rq) {
activate_task(task_rq(p), p, 0); activate_task(rq, p, 0);
resched_task(rq->curr); resched_task(rq->curr);
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment