diff options
author | David Woodhouse <dwmw2@shinybook.infradead.org> | 2005-07-02 08:39:09 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@shinybook.infradead.org> | 2005-07-02 08:39:09 -0400 |
commit | d2f6409584e2c62ffad81690562330ff3bf4a458 (patch) | |
tree | 3bdfb97d0b51be2f7f414f2107e97603c1206abb /kernel/fork.c | |
parent | e1b09eba2686eca94a3a188042b518df6044a3c1 (diff) | |
parent | 4a89a04f1ee21a7c1f4413f1ad7dcfac50ff9b63 (diff) |
Merge with master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index f42a17f88699..cdef6cea8900 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -194,6 +194,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) | |||
194 | mm->mmap = NULL; | 194 | mm->mmap = NULL; |
195 | mm->mmap_cache = NULL; | 195 | mm->mmap_cache = NULL; |
196 | mm->free_area_cache = oldmm->mmap_base; | 196 | mm->free_area_cache = oldmm->mmap_base; |
197 | mm->cached_hole_size = ~0UL; | ||
197 | mm->map_count = 0; | 198 | mm->map_count = 0; |
198 | set_mm_counter(mm, rss, 0); | 199 | set_mm_counter(mm, rss, 0); |
199 | set_mm_counter(mm, anon_rss, 0); | 200 | set_mm_counter(mm, anon_rss, 0); |
@@ -249,8 +250,9 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) | |||
249 | 250 | ||
250 | /* | 251 | /* |
251 | * Link in the new vma and copy the page table entries: | 252 | * Link in the new vma and copy the page table entries: |
252 | * link in first so that swapoff can see swap entries, | 253 | * link in first so that swapoff can see swap entries. |
253 | * and try_to_unmap_one's find_vma find the new vma. | 254 | * Note that, exceptionally, here the vma is inserted |
255 | * without holding mm->mmap_sem. | ||
254 | */ | 256 | */ |
255 | spin_lock(&mm->page_table_lock); | 257 | spin_lock(&mm->page_table_lock); |
256 | *pprev = tmp; | 258 | *pprev = tmp; |
@@ -322,6 +324,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm) | |||
322 | mm->ioctx_list = NULL; | 324 | mm->ioctx_list = NULL; |
323 | mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm); | 325 | mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm); |
324 | mm->free_area_cache = TASK_UNMAPPED_BASE; | 326 | mm->free_area_cache = TASK_UNMAPPED_BASE; |
327 | mm->cached_hole_size = ~0UL; | ||
325 | 328 | ||
326 | if (likely(!mm_alloc_pgd(mm))) { | 329 | if (likely(!mm_alloc_pgd(mm))) { |
327 | mm->def_flags = 0; | 330 | mm->def_flags = 0; |
@@ -1000,9 +1003,6 @@ static task_t *copy_process(unsigned long clone_flags, | |||
1000 | p->pdeath_signal = 0; | 1003 | p->pdeath_signal = 0; |
1001 | p->exit_state = 0; | 1004 | p->exit_state = 0; |
1002 | 1005 | ||
1003 | /* Perform scheduler related setup */ | ||
1004 | sched_fork(p); | ||
1005 | |||
1006 | /* | 1006 | /* |
1007 | * Ok, make it visible to the rest of the system. | 1007 | * Ok, make it visible to the rest of the system. |
1008 | * We dont wake it up yet. | 1008 | * We dont wake it up yet. |
@@ -1011,18 +1011,24 @@ static task_t *copy_process(unsigned long clone_flags, | |||
1011 | INIT_LIST_HEAD(&p->ptrace_children); | 1011 | INIT_LIST_HEAD(&p->ptrace_children); |
1012 | INIT_LIST_HEAD(&p->ptrace_list); | 1012 | INIT_LIST_HEAD(&p->ptrace_list); |
1013 | 1013 | ||
1014 | /* Perform scheduler related setup. Assign this task to a CPU. */ | ||
1015 | sched_fork(p, clone_flags); | ||
1016 | |||
1014 | /* Need tasklist lock for parent etc handling! */ | 1017 | /* Need tasklist lock for parent etc handling! */ |
1015 | write_lock_irq(&tasklist_lock); | 1018 | write_lock_irq(&tasklist_lock); |
1016 | 1019 | ||
1017 | /* | 1020 | /* |
1018 | * The task hasn't been attached yet, so cpus_allowed mask cannot | 1021 | * The task hasn't been attached yet, so its cpus_allowed mask will |
1019 | * have changed. The cpus_allowed mask of the parent may have | 1022 | * not be changed, nor will its assigned CPU. |
1020 | * changed after it was copied first time, and it may then move to | 1023 | * |
1021 | * another CPU - so we re-copy it here and set the child's CPU to | 1024 | * The cpus_allowed mask of the parent may have changed after it was |
1022 | * the parent's CPU. This avoids alot of nasty races. | 1025 | * copied first time - so re-copy it here, then check the child's CPU |
1026 | * to ensure it is on a valid CPU (and if not, just force it back to | ||
1027 | * parent's CPU). This avoids alot of nasty races. | ||
1023 | */ | 1028 | */ |
1024 | p->cpus_allowed = current->cpus_allowed; | 1029 | p->cpus_allowed = current->cpus_allowed; |
1025 | set_task_cpu(p, smp_processor_id()); | 1030 | if (unlikely(!cpu_isset(task_cpu(p), p->cpus_allowed))) |
1031 | set_task_cpu(p, smp_processor_id()); | ||
1026 | 1032 | ||
1027 | /* | 1033 | /* |
1028 | * Check for pending SIGKILL! The new thread should not be allowed | 1034 | * Check for pending SIGKILL! The new thread should not be allowed |
@@ -1084,6 +1090,11 @@ static task_t *copy_process(unsigned long clone_flags, | |||
1084 | spin_unlock(¤t->sighand->siglock); | 1090 | spin_unlock(¤t->sighand->siglock); |
1085 | } | 1091 | } |
1086 | 1092 | ||
1093 | /* | ||
1094 | * inherit ioprio | ||
1095 | */ | ||
1096 | p->ioprio = current->ioprio; | ||
1097 | |||
1087 | SET_LINKS(p); | 1098 | SET_LINKS(p); |
1088 | if (unlikely(p->ptrace & PT_PTRACED)) | 1099 | if (unlikely(p->ptrace & PT_PTRACED)) |
1089 | __ptrace_link(p, current->parent); | 1100 | __ptrace_link(p, current->parent); |