Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+6 -16
+1
fs/exec.c
··· 819 819 /* Notify parent that we're no longer interested in the old VM */ 820 820 tsk = current; 821 821 old_mm = current->mm; 822 + sync_mm_rss(old_mm); 822 823 mm_release(tsk, old_mm); 823 824 824 825 if (old_mm) {
+5 -8
kernel/exit.c
··· 423 423 * user space pages. We don't need them, and if we didn't close them 424 424 * they would be locked into memory. 425 425 */ 426 - mm_release(current, current->mm); 427 426 exit_mm(current); 428 427 /* 429 428 * We don't want to get frozen, in case system-wide hibernation ··· 640 641 struct mm_struct *mm = tsk->mm; 641 642 struct core_state *core_state; 642 643 644 + mm_release(tsk, mm); 643 645 if (!mm) 644 646 return; 645 647 /* ··· 960 960 preempt_count()); 961 961 962 962 acct_update_integrals(tsk); 963 - 964 - /* Set exit_code before complete_vfork_done() in mm_release() */ 965 - tsk->exit_code = code; 966 - 967 - /* Release mm and sync mm's RSS info before statistics gathering */ 968 - mm_release(tsk, tsk->mm); 969 - 963 + /* sync mm's RSS info before statistics gathering */ 964 + if (tsk->mm) 965 + sync_mm_rss(tsk->mm); 970 966 group_dead = atomic_dec_and_test(&tsk->signal->live); 971 967 if (group_dead) { 972 968 hrtimer_cancel(&tsk->signal->real_timer); ··· 975 979 tty_audit_exit(); 976 980 audit_free(tsk); 977 981 982 + tsk->exit_code = code; 978 983 taskstats_exit(tsk, group_dead); 979 984 980 985 exit_mm(tsk);
-8
kernel/fork.c
··· 619 619 module_put(mm->binfmt->module); 620 620 mmdrop(mm); 621 621 } 622 - 623 - /* 624 - * Final rss-counter synchronization. After this point there must be 625 - * no pagefaults into this mm from the current context. Otherwise 626 - * mm->rss_stat will be inconsistent. 627 - */ 628 - if (mm) 629 - sync_mm_rss(mm); 630 622 } 631 623 EXPORT_SYMBOL_GPL(mmput); 632 624