From: Michal Hocko <mhocko@kernel.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: rientjes@google.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: Re: [patch] mm, oom: prevent additional oom kills before memory is freed
Date: Fri, 23 Jun 2017 14:38:30 +0200 [thread overview]
Message-ID: <20170623123830.GW5308@dhcp22.suse.cz> (raw)
In-Reply-To: <201706172230.DBG40327.tJMHOFFFQVOLSO@I-love.SAKURA.ne.jp>
On Sat 17-06-17 22:30:31, Tetsuo Handa wrote:
> Michal Hocko wrote:
[...]
> > What does this dissassemble to on your kernel? Care to post addr2line?
>
[...]
> The __oom_reap_task_mm+0xa1/0x160 is __oom_reap_task_mm at mm/oom_kill.c:472
> which is "struct vm_area_struct *vma;" line in __oom_reap_task_mm().
> The __oom_reap_task_mm+0xb1/0x160 is __oom_reap_task_mm at mm/oom_kill.c:519
> which is "if (vma_is_anonymous(vma) || !(vma->vm_flags & VM_SHARED))" line.
> The <49> 8b 46 50 is "vma->vm_flags" in can_madv_dontneed_vma(vma) from __oom_reap_task_mm().
OK, I see what is going on here. I could have noticed earlier. Sorry my
fault. We are simply accessing a stale mm->mmap. exit_mmap() does
remove_vma which frees all the vmas but it doesn't reset mm->mmap to
NULL. Trivial to fix.
diff --git a/mm/mmap.c b/mm/mmap.c
index ca58f8a2a217..253808e716dc 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2979,6 +2979,7 @@ void exit_mmap(struct mm_struct *mm)
nr_accounted += vma_pages(vma);
vma = remove_vma(vma);
}
+ mm->mmap = NULL;
vm_unacct_memory(nr_accounted);
up_write(&mm->mmap_sem);
}
> Is it safe for the OOM reaper to call tlb_gather_mmu()/unmap_page_range()/tlb_finish_mmu() sequence
> after the OOM victim already completed tlb_gather_mmu()/unmap_vmas()/free_pgtables()/tlb_finish_mmu()/
> remove_vma() sequence from exit_mmap() from __mmput() from mmput() from exit_mm() from do_exit() ?
It is safe to race until unmap_vmas because that only needs mmap_sem for
read mode (e.g. madvise MADV_DONTNEED) and all the later operations have
to be linearized because we cannot tear down page tables while the oom
reaper is doing pte walk. After we drop mmap_sem for write in the
exit_mmap then there are no vmas and so there is nothing to do in the
reaper.
I will give the patch more testing next week. This one was busy as hell
(i was travelling and then the stack gap thingy...).
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-06-23 12:38 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-14 23:43 David Rientjes
2017-06-15 10:39 ` Michal Hocko
2017-06-15 10:53 ` Tetsuo Handa
2017-06-15 11:01 ` Michal Hocko
2017-06-15 11:32 ` Tetsuo Handa
2017-06-15 12:03 ` Michal Hocko
2017-06-15 12:13 ` Michal Hocko
2017-06-15 13:01 ` Tetsuo Handa
2017-06-15 13:22 ` Michal Hocko
2017-06-15 21:43 ` Tetsuo Handa
2017-06-15 21:37 ` David Rientjes
2017-06-15 12:20 ` Michal Hocko
2017-06-15 21:26 ` David Rientjes
2017-06-15 21:41 ` Michal Hocko
2017-06-15 22:03 ` David Rientjes
2017-06-15 22:12 ` Michal Hocko
2017-06-15 22:42 ` David Rientjes
2017-06-16 8:06 ` Michal Hocko
2017-06-16 0:54 ` Tetsuo Handa
2017-06-16 4:00 ` Tetsuo Handa
2017-06-16 8:39 ` Michal Hocko
2017-06-16 10:27 ` Tetsuo Handa
2017-06-16 11:02 ` Michal Hocko
2017-06-16 14:26 ` Re: [patch] mm, oom: prevent additional oom kills before memoryis freed Tetsuo Handa
2017-06-16 14:42 ` Michal Hocko
2017-06-17 13:30 ` Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa
2017-06-23 12:38 ` Michal Hocko [this message]
2017-06-16 12:22 ` Tetsuo Handa
2017-06-16 14:12 ` Michal Hocko
2017-06-17 5:17 ` [PATCH] mm,oom_kill: Close race window of needlessly selecting new victims Tetsuo Handa
2017-06-20 22:12 ` David Rientjes
2017-06-21 2:17 ` Tetsuo Handa
2017-06-21 20:31 ` David Rientjes
2017-06-22 0:53 ` Tetsuo Handa
2017-06-23 12:45 ` Michal Hocko
2017-06-21 13:18 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170623123830.GW5308@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox