aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-06-07 20:54:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-06-07 20:54:07 -0400
commit48d212a2eecaca2e1875925837ad27b2f43f48a3 (patch)
treefbd83c7b15856971f6d7297e1d23dc862ba2989c /kernel/exit.c
parent46edaedaf3842164281d0f86c41bc152f4b4d32e (diff)
Revert "mm: correctly synchronize rss-counters at exit/exec"
This reverts commit 40af1bbdca47e5c8a2044039bb78ca8fd8b20f94. It's horribly and utterly broken for at least the following reasons: - calling sync_mm_rss() from mmput() is fundamentally wrong, because there's absolutely no reason to believe that the task that does the mmput() always does it on its own VM. Example: fork, ptrace, /proc - you name it. - calling it *after* having done mmdrop() on it is doubly insane, since the mm struct may well be gone now. - testing mm against NULL before you call it is insane too, since a NULL mm there would have caused oopses long before. .. and those are just the three bugs I found before I decided to give up looking for me and revert it asap. I should have caught it before I even took it, but I trusted Andrew too much. Cc: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Markus Trippelsdorf <markus@trippelsdorf.de> Cc: Hugh Dickins <hughd@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 804fb6bb8161..34867cc5b42a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -423,7 +423,6 @@ void daemonize(const char *name, ...)
423 * user space pages. We don't need them, and if we didn't close them 423 * user space pages. We don't need them, and if we didn't close them
424 * they would be locked into memory. 424 * they would be locked into memory.
425 */ 425 */
426 mm_release(current, current->mm);
427 exit_mm(current); 426 exit_mm(current);
428 /* 427 /*
429 * We don't want to get frozen, in case system-wide hibernation 428 * We don't want to get frozen, in case system-wide hibernation
@@ -641,6 +640,7 @@ static void exit_mm(struct task_struct * tsk)
641 struct mm_struct *mm = tsk->mm; 640 struct mm_struct *mm = tsk->mm;
642 struct core_state *core_state; 641 struct core_state *core_state;
643 642
643 mm_release(tsk, mm);
644 if (!mm) 644 if (!mm)
645 return; 645 return;
646 /* 646 /*
@@ -960,13 +960,9 @@ void do_exit(long code)
960 preempt_count()); 960 preempt_count());
961 961
962 acct_update_integrals(tsk); 962 acct_update_integrals(tsk);
963 963 /* sync mm's RSS info before statistics gathering */
964 /* Set exit_code before complete_vfork_done() in mm_release() */ 964 if (tsk->mm)
965 tsk->exit_code = code; 965 sync_mm_rss(tsk->mm);
966
967 /* Release mm and sync mm's RSS info before statistics gathering */
968 mm_release(tsk, tsk->mm);
969
970 group_dead = atomic_dec_and_test(&tsk->signal->live); 966 group_dead = atomic_dec_and_test(&tsk->signal->live);
971 if (group_dead) { 967 if (group_dead) {
972 hrtimer_cancel(&tsk->signal->real_timer); 968 hrtimer_cancel(&tsk->signal->real_timer);
@@ -979,6 +975,7 @@ void do_exit(long code)
979 tty_audit_exit(); 975 tty_audit_exit();
980 audit_free(tsk); 976 audit_free(tsk);
981 977
978 tsk->exit_code = code;
982 taskstats_exit(tsk, group_dead); 979 taskstats_exit(tsk, group_dead);
983 980
984 exit_mm(tsk); 981 exit_mm(tsk);