]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
sched: Add WF_FORK
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Mon, 14 Sep 2009 18:02:34 +0000 (20:02 +0200)
committerIngo Molnar <mingo@elte.hu>
Tue, 15 Sep 2009 14:51:31 +0000 (16:51 +0200)
Avoid the cache buddies from biasing the time distribution away
from fork()ers. Normally the next buddy will be the preferred
scheduling target, but this makes fork()s prefer to run the new
child, whereas we prefer to run the parent, since that will
generate more work.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/sched.h
kernel/sched.c
kernel/sched_fair.c

index 3b07168b6f03cb3e0926e75c7c94c5f6a0502d44..ee1f88993097f83cbde861a3040640258347d505 100644 (file)
@@ -1028,6 +1028,7 @@ struct sched_domain;
  * wake flags
  */
 #define WF_SYNC                0x01            /* waker goes to sleep after wakup */
+#define WF_FORK                0x02            /* child wakeup after fork */
 
 struct sched_class {
        const struct sched_class *next;
index 4da335cec8ee127dc2ffacf947e78a21cb091568..0d4c4fea33171d204d702ce9f7e6fda06de2b2ae 100644 (file)
@@ -2602,7 +2602,7 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
                inc_nr_running(rq);
        }
        trace_sched_wakeup_new(rq, p, 1);
-       check_preempt_curr(rq, p, 0);
+       check_preempt_curr(rq, p, WF_FORK);
 #ifdef CONFIG_SMP
        if (p->sched_class->task_wake_up)
                p->sched_class->task_wake_up(rq, p);
index 007958e3c93ab414f76af7de0b2b8d4eee209f44..6766959c7f449b4a3d6c0aab4deeb7b7dc396f53 100644 (file)
@@ -1580,7 +1580,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int flags
         */
        if (sched_feat(LAST_BUDDY) && likely(se->on_rq && curr != rq->idle))
                set_last_buddy(se);
-       if (sched_feat(NEXT_BUDDY))
+       if (sched_feat(NEXT_BUDDY) && !(flags & WF_FORK))
                set_next_buddy(pse);
 
        /*