aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-12-16 12:04:40 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-16 13:01:58 -0500
commitefbbd05a595343a413964ad85a2ad359b7b7efbd (patch)
treec1bf0d86134187e127a00067b50b0684c2988860
parent881232b70b195768a71cd74ff4b4e8ab9502997b (diff)
sched: Add pre and post wakeup hooks
As will be apparent in the next patch, we need a pre wakeup hook for sched_fair task migration, hence rename the post wakeup hook and one pre wakeup. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> LKML-Reference: <20091216170518.114746117@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--include/linux/sched.h3
-rw-r--r--kernel/sched.c12
-rw-r--r--kernel/sched_rt.c4
3 files changed, 12 insertions, 7 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 5c858f38e81a..2c9fa1ccebff 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1091,7 +1091,8 @@ struct sched_class {
1091 enum cpu_idle_type idle); 1091 enum cpu_idle_type idle);
1092 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task); 1092 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
1093 void (*post_schedule) (struct rq *this_rq); 1093 void (*post_schedule) (struct rq *this_rq);
1094 void (*task_wake_up) (struct rq *this_rq, struct task_struct *task); 1094 void (*task_waking) (struct rq *this_rq, struct task_struct *task);
1095 void (*task_woken) (struct rq *this_rq, struct task_struct *task);
1095 1096
1096 void (*set_cpus_allowed)(struct task_struct *p, 1097 void (*set_cpus_allowed)(struct task_struct *p,
1097 const struct cpumask *newmask); 1098 const struct cpumask *newmask);
diff --git a/kernel/sched.c b/kernel/sched.c
index 297dc441ff96..6c571bdd5658 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2412,6 +2412,10 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state,
2412 if (task_contributes_to_load(p)) 2412 if (task_contributes_to_load(p))
2413 rq->nr_uninterruptible--; 2413 rq->nr_uninterruptible--;
2414 p->state = TASK_WAKING; 2414 p->state = TASK_WAKING;
2415
2416 if (p->sched_class->task_waking)
2417 p->sched_class->task_waking(rq, p);
2418
2415 __task_rq_unlock(rq); 2419 __task_rq_unlock(rq);
2416 2420
2417 cpu = select_task_rq(p, SD_BALANCE_WAKE, wake_flags); 2421 cpu = select_task_rq(p, SD_BALANCE_WAKE, wake_flags);
@@ -2475,8 +2479,8 @@ out_running:
2475 2479
2476 p->state = TASK_RUNNING; 2480 p->state = TASK_RUNNING;
2477#ifdef CONFIG_SMP 2481#ifdef CONFIG_SMP
2478 if (p->sched_class->task_wake_up) 2482 if (p->sched_class->task_woken)
2479 p->sched_class->task_wake_up(rq, p); 2483 p->sched_class->task_woken(rq, p);
2480 2484
2481 if (unlikely(rq->idle_stamp)) { 2485 if (unlikely(rq->idle_stamp)) {
2482 u64 delta = rq->clock - rq->idle_stamp; 2486 u64 delta = rq->clock - rq->idle_stamp;
@@ -2666,8 +2670,8 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
2666 trace_sched_wakeup_new(rq, p, 1); 2670 trace_sched_wakeup_new(rq, p, 1);
2667 check_preempt_curr(rq, p, WF_FORK); 2671 check_preempt_curr(rq, p, WF_FORK);
2668#ifdef CONFIG_SMP 2672#ifdef CONFIG_SMP
2669 if (p->sched_class->task_wake_up) 2673 if (p->sched_class->task_woken)
2670 p->sched_class->task_wake_up(rq, p); 2674 p->sched_class->task_woken(rq, p);
2671#endif 2675#endif
2672 task_rq_unlock(rq, &flags); 2676 task_rq_unlock(rq, &flags);
2673} 2677}
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index d2ea2828164e..f48328ac216f 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1472,7 +1472,7 @@ static void post_schedule_rt(struct rq *rq)
1472 * If we are not running and we are not going to reschedule soon, we should 1472 * If we are not running and we are not going to reschedule soon, we should
1473 * try to push tasks away now 1473 * try to push tasks away now
1474 */ 1474 */
1475static void task_wake_up_rt(struct rq *rq, struct task_struct *p) 1475static void task_woken_rt(struct rq *rq, struct task_struct *p)
1476{ 1476{
1477 if (!task_running(rq, p) && 1477 if (!task_running(rq, p) &&
1478 !test_tsk_need_resched(rq->curr) && 1478 !test_tsk_need_resched(rq->curr) &&
@@ -1753,7 +1753,7 @@ static const struct sched_class rt_sched_class = {
1753 .rq_offline = rq_offline_rt, 1753 .rq_offline = rq_offline_rt,
1754 .pre_schedule = pre_schedule_rt, 1754 .pre_schedule = pre_schedule_rt,
1755 .post_schedule = post_schedule_rt, 1755 .post_schedule = post_schedule_rt,
1756 .task_wake_up = task_wake_up_rt, 1756 .task_woken = task_woken_rt,
1757 .switched_from = switched_from_rt, 1757 .switched_from = switched_from_rt,
1758#endif 1758#endif
1759 1759