diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-05-09 23:29:19 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-05-09 23:29:19 -0700 |
| commit | 8c8cfc36d9ec9e9cd6a440fd7bf8b5404bd11635 (patch) | |
| tree | 4a0083c3db59626be538d56645069eaa6e01726d /kernel/fork.c | |
| parent | a690c9b7ac0ddc28785c38526a69a7fe2e692500 (diff) | |
[PATCH] sched: balance-on-clone
From: Ingo Molnar <mingo@elte.hu>
Implement balancing during clone(). It does the following things:
- introduces SD_BALANCE_CLONE that can serve as a tool for an
architecture to limit the search-idlest-CPU scope on clone().
E.g. the 512-CPU systems should rather not enable this.
- uses the highest sd for the imbalance_pct, not this_rq (which didnt
make sense).
- unifies balance-on-exec and balance-on-clone via the find_idlest_cpu()
function. Gets rid of sched_best_cpu() which was still a bit
inconsistent IMO, it used 'min_load < load' as a condition for
balancing - while a more correct approach would be to use half of the
imbalance_pct, like passive balancing does.
- the patch also reintroduces the possibility to do SD_BALANCE_EXEC on
SMP systems, and activates it - to get testing.
- NOTE: there's one thing in this patch that is slightly unclean: i
introduced wake_up_forked_thread. I did this to make it easier to get
rid of this patch later (wake_up_forked_process() has lots of
dependencies in various architectures). If this capability remains in
the kernel then i'll clean it up and introduce one function for
wake_up_forked_process/thread.
- NOTE2: i added the SD_BALANCE_CLONE flag to the NUMA CPU template too.
Some NUMA architectures probably want to disable this.
Diffstat (limited to 'kernel/fork.c')
| -rw-r--r-- | kernel/fork.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 68597bc347f2..c3af0b74708a 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1180,9 +1180,23 @@ long do_fork(unsigned long clone_flags, set_tsk_thread_flag(p, TIF_SIGPENDING); } - if (!(clone_flags & CLONE_STOPPED)) - wake_up_forked_process(p); /* do this last */ - else + if (!(clone_flags & CLONE_STOPPED)) { + /* + * Do the wakeup last. On SMP we treat fork() and + * CLONE_VM separately, because fork() has already + * created cache footprint on this CPU (due to + * copying the pagetables), hence migration would + * probably be costy. Threads on the other hand + * have less traction to the current CPU, and if + * there's an imbalance then the scheduler can + * migrate this fresh thread now, before it + * accumulates a larger cache footprint: + */ + if (clone_flags & CLONE_VM) + wake_up_forked_thread(p); + else + wake_up_forked_process(p); + } else p->state = TASK_STOPPED; ++total_forks; |
