summaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2014-05-07 07:15:46 -0400
committerIngo Molnar <mingo@kernel.org>2014-05-07 07:15:46 -0400
commit2fe5de9ce7d57498abc14b375cad2fcf8c3ee6cc (patch)
tree9478e8cf470c1d5bdb2d89b57a7e35919ab95e72 /kernel/fork.c
parent08f8aeb55d7727d644dbbbbfb798fe937d47751d (diff)
parent2b4cfe64dee0d84506b951d81bf55d9891744d25 (diff)
Merge branch 'sched/urgent' into sched/core, to avoid conflicts
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 332688e5e7b4..54a8d26f612f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -28,6 +28,8 @@
28#include <linux/mman.h> 28#include <linux/mman.h>
29#include <linux/mmu_notifier.h> 29#include <linux/mmu_notifier.h>
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/mm.h>
32#include <linux/vmacache.h>
31#include <linux/nsproxy.h> 33#include <linux/nsproxy.h>
32#include <linux/capability.h> 34#include <linux/capability.h>
33#include <linux/cpu.h> 35#include <linux/cpu.h>
@@ -71,6 +73,7 @@
71#include <linux/signalfd.h> 73#include <linux/signalfd.h>
72#include <linux/uprobes.h> 74#include <linux/uprobes.h>
73#include <linux/aio.h> 75#include <linux/aio.h>
76#include <linux/compiler.h>
74 77
75#include <asm/pgtable.h> 78#include <asm/pgtable.h>
76#include <asm/pgalloc.h> 79#include <asm/pgalloc.h>
@@ -284,7 +287,7 @@ void __init fork_init(unsigned long mempages)
284 init_task.signal->rlim[RLIMIT_NPROC]; 287 init_task.signal->rlim[RLIMIT_NPROC];
285} 288}
286 289
287int __attribute__((weak)) arch_dup_task_struct(struct task_struct *dst, 290int __weak arch_dup_task_struct(struct task_struct *dst,
288 struct task_struct *src) 291 struct task_struct *src)
289{ 292{
290 *dst = *src; 293 *dst = *src;
@@ -364,7 +367,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
364 367
365 mm->locked_vm = 0; 368 mm->locked_vm = 0;
366 mm->mmap = NULL; 369 mm->mmap = NULL;
367 mm->mmap_cache = NULL; 370 mm->vmacache_seqnum = 0;
368 mm->map_count = 0; 371 mm->map_count = 0;
369 cpumask_clear(mm_cpumask(mm)); 372 cpumask_clear(mm_cpumask(mm));
370 mm->mm_rb = RB_ROOT; 373 mm->mm_rb = RB_ROOT;
@@ -530,8 +533,6 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
530 atomic_set(&mm->mm_count, 1); 533 atomic_set(&mm->mm_count, 1);
531 init_rwsem(&mm->mmap_sem); 534 init_rwsem(&mm->mmap_sem);
532 INIT_LIST_HEAD(&mm->mmlist); 535 INIT_LIST_HEAD(&mm->mmlist);
533 mm->flags = (current->mm) ?
534 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
535 mm->core_state = NULL; 536 mm->core_state = NULL;
536 atomic_long_set(&mm->nr_ptes, 0); 537 atomic_long_set(&mm->nr_ptes, 0);
537 memset(&mm->rss_stat, 0, sizeof(mm->rss_stat)); 538 memset(&mm->rss_stat, 0, sizeof(mm->rss_stat));
@@ -540,8 +541,15 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
540 mm_init_owner(mm, p); 541 mm_init_owner(mm, p);
541 clear_tlb_flush_pending(mm); 542 clear_tlb_flush_pending(mm);
542 543
543 if (likely(!mm_alloc_pgd(mm))) { 544 if (current->mm) {
545 mm->flags = current->mm->flags & MMF_INIT_MASK;
546 mm->def_flags = current->mm->def_flags & VM_INIT_DEF_MASK;
547 } else {
548 mm->flags = default_dump_filter;
544 mm->def_flags = 0; 549 mm->def_flags = 0;
550 }
551
552 if (likely(!mm_alloc_pgd(mm))) {
545 mmu_notifier_mm_init(mm); 553 mmu_notifier_mm_init(mm);
546 return mm; 554 return mm;
547 } 555 }
@@ -877,6 +885,9 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
877 if (!oldmm) 885 if (!oldmm)
878 return 0; 886 return 0;
879 887
888 /* initialize the new vmacache entries */
889 vmacache_flush(tsk);
890
880 if (clone_flags & CLONE_VM) { 891 if (clone_flags & CLONE_VM) {
881 atomic_inc(&oldmm->mm_users); 892 atomic_inc(&oldmm->mm_users);
882 mm = oldmm; 893 mm = oldmm;
@@ -1070,15 +1081,6 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
1070 return 0; 1081 return 0;
1071} 1082}
1072 1083
1073static void copy_flags(unsigned long clone_flags, struct task_struct *p)
1074{
1075 unsigned long new_flags = p->flags;
1076
1077 new_flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER);
1078 new_flags |= PF_FORKNOEXEC;
1079 p->flags = new_flags;
1080}
1081
1082SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr) 1084SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr)
1083{ 1085{
1084 current->clear_child_tid = tidptr; 1086 current->clear_child_tid = tidptr;
@@ -1228,7 +1230,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1228 goto bad_fork_cleanup_count; 1230 goto bad_fork_cleanup_count;
1229 1231
1230 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ 1232 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
1231 copy_flags(clone_flags, p); 1233 p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER);
1234 p->flags |= PF_FORKNOEXEC;
1232 INIT_LIST_HEAD(&p->children); 1235 INIT_LIST_HEAD(&p->children);
1233 INIT_LIST_HEAD(&p->sibling); 1236 INIT_LIST_HEAD(&p->sibling);
1234 rcu_copy_process(p); 1237 rcu_copy_process(p);
@@ -1272,9 +1275,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1272 if (IS_ERR(p->mempolicy)) { 1275 if (IS_ERR(p->mempolicy)) {
1273 retval = PTR_ERR(p->mempolicy); 1276 retval = PTR_ERR(p->mempolicy);
1274 p->mempolicy = NULL; 1277 p->mempolicy = NULL;
1275 goto bad_fork_cleanup_cgroup; 1278 goto bad_fork_cleanup_threadgroup_lock;
1276 } 1279 }
1277 mpol_fix_fork_child_flag(p);
1278#endif 1280#endif
1279#ifdef CONFIG_CPUSETS 1281#ifdef CONFIG_CPUSETS
1280 p->cpuset_mem_spread_rotor = NUMA_NO_NODE; 1282 p->cpuset_mem_spread_rotor = NUMA_NO_NODE;
@@ -1525,11 +1527,10 @@ bad_fork_cleanup_policy:
1525 perf_event_free_task(p); 1527 perf_event_free_task(p);
1526#ifdef CONFIG_NUMA 1528#ifdef CONFIG_NUMA
1527 mpol_put(p->mempolicy); 1529 mpol_put(p->mempolicy);
1528bad_fork_cleanup_cgroup: 1530bad_fork_cleanup_threadgroup_lock:
1529#endif 1531#endif
1530 if (clone_flags & CLONE_THREAD) 1532 if (clone_flags & CLONE_THREAD)
1531 threadgroup_change_end(current); 1533 threadgroup_change_end(current);
1532 cgroup_exit(p, 0);
1533 delayacct_tsk_free(p); 1534 delayacct_tsk_free(p);
1534 module_put(task_thread_info(p)->exec_domain->module); 1535 module_put(task_thread_info(p)->exec_domain->module);
1535bad_fork_cleanup_count: 1536bad_fork_cleanup_count: