aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index e5c4668f1799..32c58f7433a3 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -59,7 +59,7 @@
59#include <asm/pgtable.h> 59#include <asm/pgtable.h>
60#include <asm/mmu_context.h> 60#include <asm/mmu_context.h>
61 61
62static void exit_mm(struct task_struct * tsk); 62static void exit_mm(struct task_struct *tsk);
63 63
64static void __unhash_process(struct task_struct *p, bool group_dead) 64static void __unhash_process(struct task_struct *p, bool group_dead)
65{ 65{
@@ -151,7 +151,7 @@ static void __exit_signal(struct task_struct *tsk)
151 spin_unlock(&sighand->siglock); 151 spin_unlock(&sighand->siglock);
152 152
153 __cleanup_sighand(sighand); 153 __cleanup_sighand(sighand);
154 clear_tsk_thread_flag(tsk,TIF_SIGPENDING); 154 clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
155 if (group_dead) { 155 if (group_dead) {
156 flush_sigqueue(&sig->shared_pending); 156 flush_sigqueue(&sig->shared_pending);
157 tty_kref_put(tty); 157 tty_kref_put(tty);
@@ -168,7 +168,7 @@ static void delayed_put_task_struct(struct rcu_head *rhp)
168} 168}
169 169
170 170
171void release_task(struct task_struct * p) 171void release_task(struct task_struct *p)
172{ 172{
173 struct task_struct *leader; 173 struct task_struct *leader;
174 int zap_leader; 174 int zap_leader;
@@ -192,7 +192,8 @@ repeat:
192 */ 192 */
193 zap_leader = 0; 193 zap_leader = 0;
194 leader = p->group_leader; 194 leader = p->group_leader;
195 if (leader != p && thread_group_empty(leader) && leader->exit_state == EXIT_ZOMBIE) { 195 if (leader != p && thread_group_empty(leader)
196 && leader->exit_state == EXIT_ZOMBIE) {
196 /* 197 /*
197 * If we were the last child thread and the leader has 198 * If we were the last child thread and the leader has
198 * exited already, and the leader's parent ignores SIGCHLD, 199 * exited already, and the leader's parent ignores SIGCHLD,
@@ -241,7 +242,8 @@ struct pid *session_of_pgrp(struct pid *pgrp)
241 * 242 *
242 * "I ask you, have you ever known what it is to be an orphan?" 243 * "I ask you, have you ever known what it is to be an orphan?"
243 */ 244 */
244static int will_become_orphaned_pgrp(struct pid *pgrp, struct task_struct *ignored_task) 245static int will_become_orphaned_pgrp(struct pid *pgrp,
246 struct task_struct *ignored_task)
245{ 247{
246 struct task_struct *p; 248 struct task_struct *p;
247 249
@@ -294,9 +296,9 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
294 struct task_struct *ignored_task = tsk; 296 struct task_struct *ignored_task = tsk;
295 297
296 if (!parent) 298 if (!parent)
297 /* exit: our father is in a different pgrp than 299 /* exit: our father is in a different pgrp than
298 * we are and we were the only connection outside. 300 * we are and we were the only connection outside.
299 */ 301 */
300 parent = tsk->real_parent; 302 parent = tsk->real_parent;
301 else 303 else
302 /* reparent: our child is in a different pgrp than 304 /* reparent: our child is in a different pgrp than
@@ -405,7 +407,7 @@ assign_new_owner:
405 * Turn us into a lazy TLB process if we 407 * Turn us into a lazy TLB process if we
406 * aren't already.. 408 * aren't already..
407 */ 409 */
408static void exit_mm(struct task_struct * tsk) 410static void exit_mm(struct task_struct *tsk)
409{ 411{
410 struct mm_struct *mm = tsk->mm; 412 struct mm_struct *mm = tsk->mm;
411 struct core_state *core_state; 413 struct core_state *core_state;
@@ -425,6 +427,7 @@ static void exit_mm(struct task_struct * tsk)
425 core_state = mm->core_state; 427 core_state = mm->core_state;
426 if (core_state) { 428 if (core_state) {
427 struct core_thread self; 429 struct core_thread self;
430
428 up_read(&mm->mmap_sem); 431 up_read(&mm->mmap_sem);
429 432
430 self.task = tsk; 433 self.task = tsk;
@@ -455,6 +458,7 @@ static void exit_mm(struct task_struct * tsk)
455 task_unlock(tsk); 458 task_unlock(tsk);
456 mm_update_next_owner(mm); 459 mm_update_next_owner(mm);
457 mmput(mm); 460 mmput(mm);
461 clear_thread_flag(TIF_MEMDIE);
458} 462}
459 463
460/* 464/*
@@ -565,6 +569,7 @@ static void forget_original_parent(struct task_struct *father)
565 569
566 list_for_each_entry_safe(p, n, &father->children, sibling) { 570 list_for_each_entry_safe(p, n, &father->children, sibling) {
567 struct task_struct *t = p; 571 struct task_struct *t = p;
572
568 do { 573 do {
569 t->real_parent = reaper; 574 t->real_parent = reaper;
570 if (t->parent == father) { 575 if (t->parent == father) {
@@ -598,7 +603,7 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
598 /* 603 /*
599 * This does two things: 604 * This does two things:
600 * 605 *
601 * A. Make init inherit all the child processes 606 * A. Make init inherit all the child processes
602 * B. Check to see if any process groups have become orphaned 607 * B. Check to see if any process groups have become orphaned
603 * as a result of our exiting, and if they have any stopped 608 * as a result of our exiting, and if they have any stopped
604 * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2) 609 * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
@@ -648,9 +653,8 @@ static void check_stack_usage(void)
648 653
649 spin_lock(&low_water_lock); 654 spin_lock(&low_water_lock);
650 if (free < lowest_to_date) { 655 if (free < lowest_to_date) {
651 printk(KERN_WARNING "%s (%d) used greatest stack depth: " 656 pr_warn("%s (%d) used greatest stack depth: %lu bytes left\n",
652 "%lu bytes left\n", 657 current->comm, task_pid_nr(current), free);
653 current->comm, task_pid_nr(current), free);
654 lowest_to_date = free; 658 lowest_to_date = free;
655 } 659 }
656 spin_unlock(&low_water_lock); 660 spin_unlock(&low_water_lock);
@@ -691,8 +695,7 @@ void do_exit(long code)
691 * leave this task alone and wait for reboot. 695 * leave this task alone and wait for reboot.
692 */ 696 */
693 if (unlikely(tsk->flags & PF_EXITING)) { 697 if (unlikely(tsk->flags & PF_EXITING)) {
694 printk(KERN_ALERT 698 pr_alert("Fixing recursive fault but reboot is needed!\n");
695 "Fixing recursive fault but reboot is needed!\n");
696 /* 699 /*
697 * We can do this unlocked here. The futex code uses 700 * We can do this unlocked here. The futex code uses
698 * this flag just to verify whether the pi state 701 * this flag just to verify whether the pi state
@@ -716,9 +719,9 @@ void do_exit(long code)
716 raw_spin_unlock_wait(&tsk->pi_lock); 719 raw_spin_unlock_wait(&tsk->pi_lock);
717 720
718 if (unlikely(in_atomic())) 721 if (unlikely(in_atomic()))
719 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n", 722 pr_info("note: %s[%d] exited with preempt_count %d\n",
720 current->comm, task_pid_nr(current), 723 current->comm, task_pid_nr(current),
721 preempt_count()); 724 preempt_count());
722 725
723 acct_update_integrals(tsk); 726 acct_update_integrals(tsk);
724 /* sync mm's RSS info before statistics gathering */ 727 /* sync mm's RSS info before statistics gathering */
@@ -836,7 +839,6 @@ void do_exit(long code)
836 for (;;) 839 for (;;)
837 cpu_relax(); /* For when BUG is null */ 840 cpu_relax(); /* For when BUG is null */
838} 841}
839
840EXPORT_SYMBOL_GPL(do_exit); 842EXPORT_SYMBOL_GPL(do_exit);
841 843
842void complete_and_exit(struct completion *comp, long code) 844void complete_and_exit(struct completion *comp, long code)
@@ -846,7 +848,6 @@ void complete_and_exit(struct completion *comp, long code)
846 848
847 do_exit(code); 849 do_exit(code);
848} 850}
849
850EXPORT_SYMBOL(complete_and_exit); 851EXPORT_SYMBOL(complete_and_exit);
851 852
852SYSCALL_DEFINE1(exit, int, error_code) 853SYSCALL_DEFINE1(exit, int, error_code)
@@ -869,6 +870,7 @@ do_group_exit(int exit_code)
869 exit_code = sig->group_exit_code; 870 exit_code = sig->group_exit_code;
870 else if (!thread_group_empty(current)) { 871 else if (!thread_group_empty(current)) {
871 struct sighand_struct *const sighand = current->sighand; 872 struct sighand_struct *const sighand = current->sighand;
873
872 spin_lock_irq(&sighand->siglock); 874 spin_lock_irq(&sighand->siglock);
873 if (signal_group_exit(sig)) 875 if (signal_group_exit(sig))
874 /* Another thread got here before we took the lock. */ 876 /* Another thread got here before we took the lock. */
@@ -1033,9 +1035,9 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
1033 * as other threads in the parent group can be right 1035 * as other threads in the parent group can be right
1034 * here reaping other children at the same time. 1036 * here reaping other children at the same time.
1035 * 1037 *
1036 * We use thread_group_cputime_adjusted() to get times for the thread 1038 * We use thread_group_cputime_adjusted() to get times for
1037 * group, which consolidates times for all threads in the 1039 * the thread group, which consolidates times for all threads
1038 * group including the group leader. 1040 * in the group including the group leader.
1039 */ 1041 */
1040 thread_group_cputime_adjusted(p, &tgutime, &tgstime); 1042 thread_group_cputime_adjusted(p, &tgutime, &tgstime);
1041 spin_lock_irq(&p->real_parent->sighand->siglock); 1043 spin_lock_irq(&p->real_parent->sighand->siglock);
@@ -1417,6 +1419,7 @@ static int do_wait_thread(struct wait_opts *wo, struct task_struct *tsk)
1417 1419
1418 list_for_each_entry(p, &tsk->children, sibling) { 1420 list_for_each_entry(p, &tsk->children, sibling) {
1419 int ret = wait_consider_task(wo, 0, p); 1421 int ret = wait_consider_task(wo, 0, p);
1422
1420 if (ret) 1423 if (ret)
1421 return ret; 1424 return ret;
1422 } 1425 }
@@ -1430,6 +1433,7 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk)
1430 1433
1431 list_for_each_entry(p, &tsk->ptraced, ptrace_entry) { 1434 list_for_each_entry(p, &tsk->ptraced, ptrace_entry) {
1432 int ret = wait_consider_task(wo, 1, p); 1435 int ret = wait_consider_task(wo, 1, p);
1436
1433 if (ret) 1437 if (ret)
1434 return ret; 1438 return ret;
1435 } 1439 }