From: Chris Down <chris@chrisdown.name>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: mhocko@kernel.org, penguin-kernel@i-love.sakura.ne.jp,
rientjes@google.com, akpm@linux-foundation.org,
hannes@cmpxchg.org, linux-mm@kvack.org
Subject: Re: [PATCH v2] memcg, oom: check memcg margin for parallel oom
Date: Tue, 14 Jul 2020 15:30:18 +0100 [thread overview]
Message-ID: <20200714143018.GB2080@chrisdown.name> (raw)
In-Reply-To: <1594735034-19190-1-git-send-email-laoar.shao@gmail.com>
Yafang Shao writes:
>Memcg oom killer invocation is synchronized by the global oom_lock and
>tasks are sleeping on the lock while somebody is selecting the victim or
>potentially race with the oom_reaper is releasing the victim's memory.
>This can result in a pointless oom killer invocation because a waiter
>might be racing with the oom_reaper
>
> P1 oom_reaper P2
> oom_reap_task mutex_lock(oom_lock)
> out_of_memory # no victim because we have one already
> __oom_reap_task_mm mute_unlock(oom_lock)
> mutex_lock(oom_lock)
> set MMF_OOM_SKIP
> select_bad_process
> # finds a new victim
>
>The page allocator prevents from this race by trying to allocate after
>the lock can be acquired (in __alloc_pages_may_oom) which acts as a last
>minute check. Moreover page allocator simply doesn't block on the
>oom_lock and simply retries the whole reclaim process.
>
>Memcg oom killer should do the last minute check as well. Call
>mem_cgroup_margin to do that. Trylock on the oom_lock could be done as
>well but this doesn't seem to be necessary at this stage.
>
>[mhocko@kernel.org: commit log]
>Suggested-by: Michal Hocko <mhocko@kernel.org>
>Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
>Cc: Michal Hocko <mhocko@kernel.org>
>Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
>Cc: David Rientjes <rientjes@google.com>
>Cc: Johannes Weiner <hannes@cmpxchg.org>
Good catch, thanks.
Acked-by: Chris Down <chris@chrisdown.name>
next prev parent reply other threads:[~2020-07-14 14:30 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-14 13:57 Yafang Shao
2020-07-14 14:05 ` Michal Hocko
2020-07-14 14:30 ` Chris Down [this message]
2020-07-14 18:46 ` David Rientjes
2020-07-15 1:44 ` Yafang Shao
2020-07-15 2:44 ` David Rientjes
2020-07-15 3:10 ` Yafang Shao
2020-07-15 3:18 ` David Rientjes
2020-07-15 3:31 ` Yafang Shao
2020-07-15 17:30 ` David Rientjes
2020-07-16 2:38 ` Yafang Shao
2020-07-16 7:04 ` David Rientjes
2020-07-16 11:53 ` Yafang Shao
2020-07-16 12:21 ` Michal Hocko
2020-07-16 13:09 ` Tetsuo Handa
2020-07-16 19:53 ` David Rientjes
2020-07-17 1:35 ` Yafang Shao
2020-07-17 19:26 ` David Rientjes
2020-07-18 2:15 ` Yafang Shao
2020-07-16 5:54 ` Tetsuo Handa
2020-07-16 6:11 ` Michal Hocko
2020-07-16 7:06 ` David Rientjes
2020-07-16 6:08 ` Michal Hocko
2020-07-16 6:56 ` David Rientjes
2020-07-16 7:12 ` Michal Hocko
2020-07-16 20:04 ` David Rientjes
2020-07-28 18:04 ` Johannes Weiner
2020-07-15 6:56 ` 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=20200714143018.GB2080@chrisdown.name \
--to=chris@chrisdown.name \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=laoar.shao@gmail.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.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