From e99926fdfa9537d7e5132219332c54538c52de56 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Mon, 15 Nov 2021 15:39:21 -0800 Subject: [PATCH] ANDROID: mm/oom_kill: allow process_mrelease reclaim memory in parallel with exit_mmap To allow process_mrelease to reap targeted mm in parallel with exit_mmap mark the victim with MMF_OOM_VICTIM flag. Bug: 189803002 Signed-off-by: Suren Baghdasaryan Change-Id: I89cf5f8fbeeb18b93a340b9ebe7f200837ebe846 --- mm/oom_kill.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 226940116bd5..69d583ea1a1b 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1233,6 +1233,12 @@ SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags) mm = p->mm; mmgrab(mm); + /* + * If we are too late and exit_mmap already checked mm_is_oom_victim + * then will block on mmap_read_lock until exit_mmap releases mmap_lock + */ + set_bit(MMF_OOM_VICTIM, &mm->flags); + if (task_will_free_mem(p)) reap = true; else {