Re: [PATCH 04/21] sched: implement scheduler notifiers

Peter Zijlstra
2009-11-16T18:40:56Z

On Tue, 2009-11-17 at 02:15 +0900, Tejun Heo wrote:
> @@ -1939,6 +1953,8 @@ static int effective_prio(struct task_struct *p)
> */
> static void activate_task(struct rq *rq, struct task_struct *p, int wakeup)
> {
> + sched_notifier_call(p, SCHED_NOTIFIER_ACTIVATED, activated, wakeup);
> +
> if (task_contributes_to_load(p))
> rq->nr_uninterruptible--;
>
> @@ -1951,6 +1967,8 @@ static void activate_task(struct rq *rq, struct task_struct *p, int wakeup)
> */
> static void deactivate_task(struct rq *rq, struct task_struct *p, int sleep)
> {
> + sched_notifier_call(p, SCHED_NOTIFIER_DEACTIVATED, deactivated, sleep);
> +
> if (task_contributes_to_load(p))
> rq->nr_uninterruptible++;
>

I really hate exposing activate/deactivate.

You say:

> Activated and deactivated are called
> when a task's readiness to run changes.

How is that not clear from the out hook? It would seem to me that when
you get scheduled out with a p->state != TASK_RUNNING you're not ready.