diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-26 05:26:19 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-26 05:26:19 -0400 |
commit | 88bef5a4074e0568cf54df410f41065c06694d8a (patch) | |
tree | bc4d59f57ce315bcb16dad5491ab9983ab122d8a /kernel/fork.c | |
parent | 054a3fd824705543322d787893de9f3755151517 (diff) | |
parent | 024e8ac04453b3525448c31ef39848cf675ba6db (diff) |
Merge branch 'linus' into x86/urgent
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index adefc1131f27..b99d73e971a4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/cpu.h> | 33 | #include <linux/cpu.h> |
34 | #include <linux/cgroup.h> | 34 | #include <linux/cgroup.h> |
35 | #include <linux/security.h> | 35 | #include <linux/security.h> |
36 | #include <linux/hugetlb.h> | ||
36 | #include <linux/swap.h> | 37 | #include <linux/swap.h> |
37 | #include <linux/syscalls.h> | 38 | #include <linux/syscalls.h> |
38 | #include <linux/jiffies.h> | 39 | #include <linux/jiffies.h> |
@@ -92,6 +93,23 @@ int nr_processes(void) | |||
92 | static struct kmem_cache *task_struct_cachep; | 93 | static struct kmem_cache *task_struct_cachep; |
93 | #endif | 94 | #endif |
94 | 95 | ||
96 | #ifndef __HAVE_ARCH_THREAD_INFO_ALLOCATOR | ||
97 | static inline struct thread_info *alloc_thread_info(struct task_struct *tsk) | ||
98 | { | ||
99 | #ifdef CONFIG_DEBUG_STACK_USAGE | ||
100 | gfp_t mask = GFP_KERNEL | __GFP_ZERO; | ||
101 | #else | ||
102 | gfp_t mask = GFP_KERNEL; | ||
103 | #endif | ||
104 | return (struct thread_info *)__get_free_pages(mask, THREAD_SIZE_ORDER); | ||
105 | } | ||
106 | |||
107 | static inline void free_thread_info(struct thread_info *ti) | ||
108 | { | ||
109 | free_pages((unsigned long)ti, THREAD_SIZE_ORDER); | ||
110 | } | ||
111 | #endif | ||
112 | |||
95 | /* SLAB cache for signal_struct structures (tsk->signal) */ | 113 | /* SLAB cache for signal_struct structures (tsk->signal) */ |
96 | static struct kmem_cache *signal_cachep; | 114 | static struct kmem_cache *signal_cachep; |
97 | 115 | ||
@@ -307,6 +325,14 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) | |||
307 | } | 325 | } |
308 | 326 | ||
309 | /* | 327 | /* |
328 | * Clear hugetlb-related page reserves for children. This only | ||
329 | * affects MAP_PRIVATE mappings. Faults generated by the child | ||
330 | * are not guaranteed to succeed, even if read-only | ||
331 | */ | ||
332 | if (is_vm_hugetlb_page(tmp)) | ||
333 | reset_vma_resv_huge_pages(tmp); | ||
334 | |||
335 | /* | ||
310 | * Link in the new vma and copy the page table entries. | 336 | * Link in the new vma and copy the page table entries. |
311 | */ | 337 | */ |
312 | *pprev = tmp; | 338 | *pprev = tmp; |
@@ -374,7 +400,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) | |||
374 | INIT_LIST_HEAD(&mm->mmlist); | 400 | INIT_LIST_HEAD(&mm->mmlist); |
375 | mm->flags = (current->mm) ? current->mm->flags | 401 | mm->flags = (current->mm) ? current->mm->flags |
376 | : MMF_DUMP_FILTER_DEFAULT; | 402 | : MMF_DUMP_FILTER_DEFAULT; |
377 | mm->core_waiters = 0; | 403 | mm->core_state = NULL; |
378 | mm->nr_ptes = 0; | 404 | mm->nr_ptes = 0; |
379 | set_mm_counter(mm, file_rss, 0); | 405 | set_mm_counter(mm, file_rss, 0); |
380 | set_mm_counter(mm, anon_rss, 0); | 406 | set_mm_counter(mm, anon_rss, 0); |
@@ -448,7 +474,7 @@ EXPORT_SYMBOL_GPL(mmput); | |||
448 | /** | 474 | /** |
449 | * get_task_mm - acquire a reference to the task's mm | 475 | * get_task_mm - acquire a reference to the task's mm |
450 | * | 476 | * |
451 | * Returns %NULL if the task has no mm. Checks PF_BORROWED_MM (meaning | 477 | * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning |
452 | * this kernel workthread has transiently adopted a user mm with use_mm, | 478 | * this kernel workthread has transiently adopted a user mm with use_mm, |
453 | * to do its AIO) is not set and if so returns a reference to it, after | 479 | * to do its AIO) is not set and if so returns a reference to it, after |
454 | * bumping up the use count. User must release the mm via mmput() | 480 | * bumping up the use count. User must release the mm via mmput() |
@@ -461,7 +487,7 @@ struct mm_struct *get_task_mm(struct task_struct *task) | |||
461 | task_lock(task); | 487 | task_lock(task); |
462 | mm = task->mm; | 488 | mm = task->mm; |
463 | if (mm) { | 489 | if (mm) { |
464 | if (task->flags & PF_BORROWED_MM) | 490 | if (task->flags & PF_KTHREAD) |
465 | mm = NULL; | 491 | mm = NULL; |
466 | else | 492 | else |
467 | atomic_inc(&mm->mm_users); | 493 | atomic_inc(&mm->mm_users); |
@@ -786,6 +812,12 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
786 | sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; | 812 | sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; |
787 | sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; | 813 | sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; |
788 | sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; | 814 | sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; |
815 | #ifdef CONFIG_TASK_XACCT | ||
816 | sig->rchar = sig->wchar = sig->syscr = sig->syscw = 0; | ||
817 | #endif | ||
818 | #ifdef CONFIG_TASK_IO_ACCOUNTING | ||
819 | memset(&sig->ioac, 0, sizeof(sig->ioac)); | ||
820 | #endif | ||
789 | sig->sum_sched_runtime = 0; | 821 | sig->sum_sched_runtime = 0; |
790 | INIT_LIST_HEAD(&sig->cpu_timers[0]); | 822 | INIT_LIST_HEAD(&sig->cpu_timers[0]); |
791 | INIT_LIST_HEAD(&sig->cpu_timers[1]); | 823 | INIT_LIST_HEAD(&sig->cpu_timers[1]); |
@@ -1081,6 +1113,12 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1081 | if (clone_flags & CLONE_THREAD) | 1113 | if (clone_flags & CLONE_THREAD) |
1082 | p->tgid = current->tgid; | 1114 | p->tgid = current->tgid; |
1083 | 1115 | ||
1116 | if (current->nsproxy != p->nsproxy) { | ||
1117 | retval = ns_cgroup_clone(p, pid); | ||
1118 | if (retval) | ||
1119 | goto bad_fork_free_pid; | ||
1120 | } | ||
1121 | |||
1084 | p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; | 1122 | p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; |
1085 | /* | 1123 | /* |
1086 | * Clear TID on mm_release()? | 1124 | * Clear TID on mm_release()? |