[PATCH 06/12] sched: relocate fire_sched_notifiers_out() and trace_sched_switch()

Tejun Heo
2010-05-04T12:40:24Z

Relocate fire_sched_notifiers_out() from prepare_task_switch() and
trace_sched_switch() from context_switch() to schedule() so that
trace_sched_switch(), perf_event_task_sched_out() and
fire_sched_notifiers_out() are colocated.

Both are now called before switch counts and rq->curr are updated and
in addition trace_sched_switch() is called before
prepare_lock/arch_switch(); however, this shouldn't make any visible
different for either.

This will help unifying notifiers in sched.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Avi Kivity <avi@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/sched.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index df6e0af..0b753f0 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2753,7 +2753,6 @@ static inline void
prepare_task_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)
{
- fire_sched_notifiers_out(prev, next);
prepare_lock_switch(rq, next);
prepare_arch_switch(next);
}
@@ -2882,7 +2881,6 @@ context_switch(struct rq *rq, struct task_struct *prev,
struct mm_struct *mm, *oldmm;

prepare_task_switch(rq, prev, next);
- trace_sched_switch(rq, prev, next);
mm = next->mm;
oldmm = prev->active_mm;
/*
@@ -3714,7 +3712,9 @@ need_resched_nonpreemptible:

if (likely(prev != next)) {
sched_info_switch(prev, next);
+ trace_sched_switch(rq, prev, next);
perf_event_task_sched_out(rq, prev, next);
+ fire_sched_notifiers_out(prev, next);

rq->nr_switches++;
rq->curr = next;
--
1.6.4.2