diff options
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 5447dc7defa9..25e429152ddc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -66,6 +66,7 @@ | |||
66 | #include <linux/posix-timers.h> | 66 | #include <linux/posix-timers.h> |
67 | #include <linux/user-return-notifier.h> | 67 | #include <linux/user-return-notifier.h> |
68 | #include <linux/oom.h> | 68 | #include <linux/oom.h> |
69 | #include <linux/khugepaged.h> | ||
69 | 70 | ||
70 | #include <asm/pgtable.h> | 71 | #include <asm/pgtable.h> |
71 | #include <asm/pgalloc.h> | 72 | #include <asm/pgalloc.h> |
@@ -169,6 +170,7 @@ EXPORT_SYMBOL(free_task); | |||
169 | static inline void free_signal_struct(struct signal_struct *sig) | 170 | static inline void free_signal_struct(struct signal_struct *sig) |
170 | { | 171 | { |
171 | taskstats_tgid_free(sig); | 172 | taskstats_tgid_free(sig); |
173 | sched_autogroup_exit(sig); | ||
172 | kmem_cache_free(signal_cachep, sig); | 174 | kmem_cache_free(signal_cachep, sig); |
173 | } | 175 | } |
174 | 176 | ||
@@ -329,6 +331,9 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) | |||
329 | retval = ksm_fork(mm, oldmm); | 331 | retval = ksm_fork(mm, oldmm); |
330 | if (retval) | 332 | if (retval) |
331 | goto out; | 333 | goto out; |
334 | retval = khugepaged_fork(mm, oldmm); | ||
335 | if (retval) | ||
336 | goto out; | ||
332 | 337 | ||
333 | prev = NULL; | 338 | prev = NULL; |
334 | for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) { | 339 | for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) { |
@@ -528,6 +533,9 @@ void __mmdrop(struct mm_struct *mm) | |||
528 | mm_free_pgd(mm); | 533 | mm_free_pgd(mm); |
529 | destroy_context(mm); | 534 | destroy_context(mm); |
530 | mmu_notifier_mm_destroy(mm); | 535 | mmu_notifier_mm_destroy(mm); |
536 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
537 | VM_BUG_ON(mm->pmd_huge_pte); | ||
538 | #endif | ||
531 | free_mm(mm); | 539 | free_mm(mm); |
532 | } | 540 | } |
533 | EXPORT_SYMBOL_GPL(__mmdrop); | 541 | EXPORT_SYMBOL_GPL(__mmdrop); |
@@ -542,6 +550,7 @@ void mmput(struct mm_struct *mm) | |||
542 | if (atomic_dec_and_test(&mm->mm_users)) { | 550 | if (atomic_dec_and_test(&mm->mm_users)) { |
543 | exit_aio(mm); | 551 | exit_aio(mm); |
544 | ksm_exit(mm); | 552 | ksm_exit(mm); |
553 | khugepaged_exit(mm); /* must run before exit_mmap */ | ||
545 | exit_mmap(mm); | 554 | exit_mmap(mm); |
546 | set_mm_exe_file(mm, NULL); | 555 | set_mm_exe_file(mm, NULL); |
547 | if (!list_empty(&mm->mmlist)) { | 556 | if (!list_empty(&mm->mmlist)) { |
@@ -668,6 +677,10 @@ struct mm_struct *dup_mm(struct task_struct *tsk) | |||
668 | mm->token_priority = 0; | 677 | mm->token_priority = 0; |
669 | mm->last_interval = 0; | 678 | mm->last_interval = 0; |
670 | 679 | ||
680 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
681 | mm->pmd_huge_pte = NULL; | ||
682 | #endif | ||
683 | |||
671 | if (!mm_init(mm, tsk)) | 684 | if (!mm_init(mm, tsk)) |
672 | goto fail_nomem; | 685 | goto fail_nomem; |
673 | 686 | ||
@@ -905,9 +918,11 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
905 | posix_cpu_timers_init_group(sig); | 918 | posix_cpu_timers_init_group(sig); |
906 | 919 | ||
907 | tty_audit_fork(sig); | 920 | tty_audit_fork(sig); |
921 | sched_autogroup_fork(sig); | ||
908 | 922 | ||
909 | sig->oom_adj = current->signal->oom_adj; | 923 | sig->oom_adj = current->signal->oom_adj; |
910 | sig->oom_score_adj = current->signal->oom_score_adj; | 924 | sig->oom_score_adj = current->signal->oom_score_adj; |
925 | sig->oom_score_adj_min = current->signal->oom_score_adj_min; | ||
911 | 926 | ||
912 | mutex_init(&sig->cred_guard_mutex); | 927 | mutex_init(&sig->cred_guard_mutex); |
913 | 928 | ||
@@ -1283,7 +1298,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1283 | attach_pid(p, PIDTYPE_SID, task_session(current)); | 1298 | attach_pid(p, PIDTYPE_SID, task_session(current)); |
1284 | list_add_tail(&p->sibling, &p->real_parent->children); | 1299 | list_add_tail(&p->sibling, &p->real_parent->children); |
1285 | list_add_tail_rcu(&p->tasks, &init_task.tasks); | 1300 | list_add_tail_rcu(&p->tasks, &init_task.tasks); |
1286 | __get_cpu_var(process_counts)++; | 1301 | __this_cpu_inc(process_counts); |
1287 | } | 1302 | } |
1288 | attach_pid(p, PIDTYPE_PID, pid); | 1303 | attach_pid(p, PIDTYPE_PID, pid); |
1289 | nr_threads++; | 1304 | nr_threads++; |
@@ -1408,23 +1423,6 @@ long do_fork(unsigned long clone_flags, | |||
1408 | } | 1423 | } |
1409 | 1424 | ||
1410 | /* | 1425 | /* |
1411 | * We hope to recycle these flags after 2.6.26 | ||
1412 | */ | ||
1413 | if (unlikely(clone_flags & CLONE_STOPPED)) { | ||
1414 | static int __read_mostly count = 100; | ||
1415 | |||
1416 | if (count > 0 && printk_ratelimit()) { | ||
1417 | char comm[TASK_COMM_LEN]; | ||
1418 | |||
1419 | count--; | ||
1420 | printk(KERN_INFO "fork(): process `%s' used deprecated " | ||
1421 | "clone flags 0x%lx\n", | ||
1422 | get_task_comm(comm, current), | ||
1423 | clone_flags & CLONE_STOPPED); | ||
1424 | } | ||
1425 | } | ||
1426 | |||
1427 | /* | ||
1428 | * When called from kernel_thread, don't do user tracing stuff. | 1426 | * When called from kernel_thread, don't do user tracing stuff. |
1429 | */ | 1427 | */ |
1430 | if (likely(user_mode(regs))) | 1428 | if (likely(user_mode(regs))) |
@@ -1462,16 +1460,7 @@ long do_fork(unsigned long clone_flags, | |||
1462 | */ | 1460 | */ |
1463 | p->flags &= ~PF_STARTING; | 1461 | p->flags &= ~PF_STARTING; |
1464 | 1462 | ||
1465 | if (unlikely(clone_flags & CLONE_STOPPED)) { | 1463 | wake_up_new_task(p, clone_flags); |
1466 | /* | ||
1467 | * We'll start up with an immediate SIGSTOP. | ||
1468 | */ | ||
1469 | sigaddset(&p->pending.signal, SIGSTOP); | ||
1470 | set_tsk_thread_flag(p, TIF_SIGPENDING); | ||
1471 | __set_task_state(p, TASK_STOPPED); | ||
1472 | } else { | ||
1473 | wake_up_new_task(p, clone_flags); | ||
1474 | } | ||
1475 | 1464 | ||
1476 | tracehook_report_clone_complete(trace, regs, | 1465 | tracehook_report_clone_complete(trace, regs, |
1477 | clone_flags, nr, p); | 1466 | clone_flags, nr, p); |