aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 34867cc5b42a..f65345f9e5bb 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -72,6 +72,18 @@ static void __unhash_process(struct task_struct *p, bool group_dead)
72 list_del_rcu(&p->tasks); 72 list_del_rcu(&p->tasks);
73 list_del_init(&p->sibling); 73 list_del_init(&p->sibling);
74 __this_cpu_dec(process_counts); 74 __this_cpu_dec(process_counts);
75 /*
76 * If we are the last child process in a pid namespace to be
77 * reaped, notify the reaper sleeping zap_pid_ns_processes().
78 */
79 if (IS_ENABLED(CONFIG_PID_NS)) {
80 struct task_struct *parent = p->real_parent;
81
82 if ((task_active_pid_ns(parent)->child_reaper == parent) &&
83 list_empty(&parent->children) &&
84 (parent->flags & PF_EXITING))
85 wake_up_process(parent);
86 }
75 } 87 }
76 list_del_rcu(&p->thread_group); 88 list_del_rcu(&p->thread_group);
77} 89}
@@ -471,7 +483,7 @@ static void close_files(struct files_struct * files)
471 rcu_read_unlock(); 483 rcu_read_unlock();
472 for (;;) { 484 for (;;) {
473 unsigned long set; 485 unsigned long set;
474 i = j * __NFDBITS; 486 i = j * BITS_PER_LONG;
475 if (i >= fdt->max_fds) 487 if (i >= fdt->max_fds)
476 break; 488 break;
477 set = fdt->open_fds[j++]; 489 set = fdt->open_fds[j++];
@@ -643,6 +655,7 @@ static void exit_mm(struct task_struct * tsk)
643 mm_release(tsk, mm); 655 mm_release(tsk, mm);
644 if (!mm) 656 if (!mm)
645 return; 657 return;
658 sync_mm_rss(mm);
646 /* 659 /*
647 * Serialize with any possible pending coredump. 660 * Serialize with any possible pending coredump.
648 * We must hold mmap_sem around checking core_state 661 * We must hold mmap_sem around checking core_state
@@ -719,12 +732,6 @@ static struct task_struct *find_new_reaper(struct task_struct *father)
719 732
720 zap_pid_ns_processes(pid_ns); 733 zap_pid_ns_processes(pid_ns);
721 write_lock_irq(&tasklist_lock); 734 write_lock_irq(&tasklist_lock);
722 /*
723 * We can not clear ->child_reaper or leave it alone.
724 * There may by stealth EXIT_DEAD tasks on ->children,
725 * forget_original_parent() must move them somewhere.
726 */
727 pid_ns->child_reaper = init_pid_ns.child_reaper;
728 } else if (father->signal->has_child_subreaper) { 735 } else if (father->signal->has_child_subreaper) {
729 struct task_struct *reaper; 736 struct task_struct *reaper;
730 737
@@ -946,14 +953,11 @@ void do_exit(long code)
946 exit_signals(tsk); /* sets PF_EXITING */ 953 exit_signals(tsk); /* sets PF_EXITING */
947 /* 954 /*
948 * tsk->flags are checked in the futex code to protect against 955 * tsk->flags are checked in the futex code to protect against
949 * an exiting task cleaning up the robust pi futexes, and in 956 * an exiting task cleaning up the robust pi futexes.
950 * task_work_add() to avoid the race with exit_task_work().
951 */ 957 */
952 smp_mb(); 958 smp_mb();
953 raw_spin_unlock_wait(&tsk->pi_lock); 959 raw_spin_unlock_wait(&tsk->pi_lock);
954 960
955 exit_task_work(tsk);
956
957 if (unlikely(in_atomic())) 961 if (unlikely(in_atomic()))
958 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n", 962 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",
959 current->comm, task_pid_nr(current), 963 current->comm, task_pid_nr(current),
@@ -988,6 +992,7 @@ void do_exit(long code)
988 exit_shm(tsk); 992 exit_shm(tsk);
989 exit_files(tsk); 993 exit_files(tsk);
990 exit_fs(tsk); 994 exit_fs(tsk);
995 exit_task_work(tsk);
991 check_stack_usage(); 996 check_stack_usage();
992 exit_thread(); 997 exit_thread();
993 998