linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch -mm] mm, oom: remove oom_lock from exit_mmap
@ 2018-07-12 21:34 David Rientjes
  2018-07-13  6:20 ` Tetsuo Handa
  2018-07-13 14:26 ` Michal Hocko
  0 siblings, 2 replies; 11+ messages in thread
From: David Rientjes @ 2018-07-12 21:34 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Michal Hocko, Tetsuo Handa, linux-mm, linux-kernel

oom_lock isn't needed for __oom_reap_task_mm().  If MMF_UNSTABLE is 
already set for the mm, we can simply back out immediately since oom 
reaping is already in progress (or done).

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/mmap.c     | 2 --
 mm/oom_kill.c | 6 ++++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index cd2431f46188..7f918eb725f6 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3072,9 +3072,7 @@ void exit_mmap(struct mm_struct *mm)
 		 * to mmu_notifier_release(mm) ensures mmu notifier callbacks in
 		 * __oom_reap_task_mm() will not block.
 		 */
-		mutex_lock(&oom_lock);
 		__oom_reap_task_mm(mm);
-		mutex_unlock(&oom_lock);
 
 		/*
 		 * Now, set MMF_UNSTABLE to avoid racing with the oom reaper.
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 0fe4087d5151..e6328cef090f 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -488,9 +488,11 @@ void __oom_reap_task_mm(struct mm_struct *mm)
 	 * Tell all users of get_user/copy_from_user etc... that the content
 	 * is no longer stable. No barriers really needed because unmapping
 	 * should imply barriers already and the reader would hit a page fault
-	 * if it stumbled over a reaped memory.
+	 * if it stumbled over a reaped memory. If MMF_UNSTABLE is already set,
+	 * reaping as already occurred so nothing left to do.
 	 */
-	set_bit(MMF_UNSTABLE, &mm->flags);
+	if (test_and_set_bit(MMF_UNSTABLE, &mm->flags))
+		return;
 
 	for (vma = mm->mmap ; vma; vma = vma->vm_next) {
 		if (!can_madv_dontneed_vma(vma))

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-07-17  4:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 21:34 [patch -mm] mm, oom: remove oom_lock from exit_mmap David Rientjes
2018-07-13  6:20 ` Tetsuo Handa
2018-07-13 14:26 ` Michal Hocko
2018-07-13 21:18   ` Tetsuo Handa
2018-07-16  6:13     ` Michal Hocko
2018-07-16  7:04       ` Tetsuo Handa
2018-07-16  7:44         ` Michal Hocko
2018-07-16 10:38           ` Tetsuo Handa
2018-07-16 11:15             ` Michal Hocko
2018-07-17  4:22     ` David Rientjes
2018-07-17  4:14   ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).