aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index d0b7d988f873..294b1709170d 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -51,6 +51,7 @@
51#include <trace/events/sched.h> 51#include <trace/events/sched.h>
52#include <linux/hw_breakpoint.h> 52#include <linux/hw_breakpoint.h>
53#include <linux/oom.h> 53#include <linux/oom.h>
54#include <linux/writeback.h>
54 55
55#include <asm/uaccess.h> 56#include <asm/uaccess.h>
56#include <asm/unistd.h> 57#include <asm/unistd.h>
@@ -121,9 +122,9 @@ static void __exit_signal(struct task_struct *tsk)
121 * We won't ever get here for the group leader, since it 122 * We won't ever get here for the group leader, since it
122 * will have been the last reference on the signal_struct. 123 * will have been the last reference on the signal_struct.
123 */ 124 */
124 sig->utime = cputime_add(sig->utime, tsk->utime); 125 sig->utime += tsk->utime;
125 sig->stime = cputime_add(sig->stime, tsk->stime); 126 sig->stime += tsk->stime;
126 sig->gtime = cputime_add(sig->gtime, tsk->gtime); 127 sig->gtime += tsk->gtime;
127 sig->min_flt += tsk->min_flt; 128 sig->min_flt += tsk->min_flt;
128 sig->maj_flt += tsk->maj_flt; 129 sig->maj_flt += tsk->maj_flt;
129 sig->nvcsw += tsk->nvcsw; 130 sig->nvcsw += tsk->nvcsw;
@@ -679,8 +680,6 @@ static void exit_mm(struct task_struct * tsk)
679 tsk->mm = NULL; 680 tsk->mm = NULL;
680 up_read(&mm->mmap_sem); 681 up_read(&mm->mmap_sem);
681 enter_lazy_tlb(mm, current); 682 enter_lazy_tlb(mm, current);
682 /* We don't want this task to be frozen prematurely */
683 clear_freeze_flag(tsk);
684 task_unlock(tsk); 683 task_unlock(tsk);
685 mm_update_next_owner(mm); 684 mm_update_next_owner(mm);
686 mmput(mm); 685 mmput(mm);
@@ -888,7 +887,7 @@ static void check_stack_usage(void)
888static inline void check_stack_usage(void) {} 887static inline void check_stack_usage(void) {}
889#endif 888#endif
890 889
891NORET_TYPE void do_exit(long code) 890void do_exit(long code)
892{ 891{
893 struct task_struct *tsk = current; 892 struct task_struct *tsk = current;
894 int group_dead; 893 int group_dead;
@@ -965,8 +964,7 @@ NORET_TYPE void do_exit(long code)
965 acct_collect(code, group_dead); 964 acct_collect(code, group_dead);
966 if (group_dead) 965 if (group_dead)
967 tty_audit_exit(); 966 tty_audit_exit();
968 if (unlikely(tsk->audit_context)) 967 audit_free(tsk);
969 audit_free(tsk);
970 968
971 tsk->exit_code = code; 969 tsk->exit_code = code;
972 taskstats_exit(tsk, group_dead); 970 taskstats_exit(tsk, group_dead);
@@ -1037,9 +1035,12 @@ NORET_TYPE void do_exit(long code)
1037 validate_creds_for_do_exit(tsk); 1035 validate_creds_for_do_exit(tsk);
1038 1036
1039 preempt_disable(); 1037 preempt_disable();
1038 if (tsk->nr_dirtied)
1039 __this_cpu_add(dirty_throttle_leaks, tsk->nr_dirtied);
1040 exit_rcu(); 1040 exit_rcu();
1041 /* causes final put_task_struct in finish_task_switch(). */ 1041 /* causes final put_task_struct in finish_task_switch(). */
1042 tsk->state = TASK_DEAD; 1042 tsk->state = TASK_DEAD;
1043 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
1043 schedule(); 1044 schedule();
1044 BUG(); 1045 BUG();
1045 /* Avoid "noreturn function does return". */ 1046 /* Avoid "noreturn function does return". */
@@ -1049,7 +1050,7 @@ NORET_TYPE void do_exit(long code)
1049 1050
1050EXPORT_SYMBOL_GPL(do_exit); 1051EXPORT_SYMBOL_GPL(do_exit);
1051 1052
1052NORET_TYPE void complete_and_exit(struct completion *comp, long code) 1053void complete_and_exit(struct completion *comp, long code)
1053{ 1054{
1054 if (comp) 1055 if (comp)
1055 complete(comp); 1056 complete(comp);
@@ -1068,7 +1069,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
1068 * Take down every thread in the group. This is called by fatal signals 1069 * Take down every thread in the group. This is called by fatal signals
1069 * as well as by sys_exit_group (below). 1070 * as well as by sys_exit_group (below).
1070 */ 1071 */
1071NORET_TYPE void 1072void
1072do_group_exit(int exit_code) 1073do_group_exit(int exit_code)
1073{ 1074{
1074 struct signal_struct *sig = current->signal; 1075 struct signal_struct *sig = current->signal;
@@ -1255,19 +1256,9 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
1255 spin_lock_irq(&p->real_parent->sighand->siglock); 1256 spin_lock_irq(&p->real_parent->sighand->siglock);
1256 psig = p->real_parent->signal; 1257 psig = p->real_parent->signal;
1257 sig = p->signal; 1258 sig = p->signal;
1258 psig->cutime = 1259 psig->cutime += tgutime + sig->cutime;
1259 cputime_add(psig->cutime, 1260 psig->cstime += tgstime + sig->cstime;
1260 cputime_add(tgutime, 1261 psig->cgtime += p->gtime + sig->gtime + sig->cgtime;
1261 sig->cutime));
1262 psig->cstime =
1263 cputime_add(psig->cstime,
1264 cputime_add(tgstime,
1265 sig->cstime));
1266 psig->cgtime =
1267 cputime_add(psig->cgtime,
1268 cputime_add(p->gtime,
1269 cputime_add(sig->gtime,
1270 sig->cgtime)));
1271 psig->cmin_flt += 1262 psig->cmin_flt +=
1272 p->min_flt + sig->min_flt + sig->cmin_flt; 1263 p->min_flt + sig->min_flt + sig->cmin_flt;
1273 psig->cmaj_flt += 1264 psig->cmaj_flt +=
@@ -1540,8 +1531,15 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
1540 } 1531 }
1541 1532
1542 /* dead body doesn't have much to contribute */ 1533 /* dead body doesn't have much to contribute */
1543 if (p->exit_state == EXIT_DEAD) 1534 if (unlikely(p->exit_state == EXIT_DEAD)) {
1535 /*
1536 * But do not ignore this task until the tracer does
1537 * wait_task_zombie()->do_notify_parent().
1538 */
1539 if (likely(!ptrace) && unlikely(ptrace_reparented(p)))
1540 wo->notask_error = 0;
1544 return 0; 1541 return 0;
1542 }
1545 1543
1546 /* slay zombie? */ 1544 /* slay zombie? */
1547 if (p->exit_state == EXIT_ZOMBIE) { 1545 if (p->exit_state == EXIT_ZOMBIE) {