linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] memcg oom: bail out from the charge path if no victim found
@ 2020-04-18 15:13 Yafang Shao
  2020-04-18 15:13 ` [PATCH 1/3] mm: change the return type of out_of_memory() Yafang Shao
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Yafang Shao @ 2020-04-18 15:13 UTC (permalink / raw)
  To: hannes, mhocko, vdavydov.dev, akpm; +Cc: linux-mm, Yafang Shao

Without considering the manually triggered OOM, if no victim found in
system OOM, the system will be deadlocked on memory, however if no
victim found in memcg OOM, it can charge successfully and runs well.
This behavior in memcg oom is not proper because that can prevent the
memcg from being limited.

Take an easy example.
        $ cd /sys/fs/cgroup/foo/
        $ echo $$ > cgroup.procs
        $ echo 200M > memory.max
        $ cat memory.max
        209715200
        $ echo -1000 > /proc/$$/oom_score_adj
Then, let's run a memhog task in memcg foo, which will allocate 1G
memory and keeps running.
        $ /home/yafang/test/memhog &
Then memory.current will be greater than memory.max. Run bellow command
in another shell.
        $ cat /sys/fs/cgroup/foo/memory.current
        1097228288
The tasks which have already allocated memory and won't allocate new
memory still runs well. This behavior makes nonsense.

This patch is to improve it.
If no victim found in memcg oom, we should force the current task to
wait until there's available pages. That is similar with the behavior in
memcg1 when oom_kill_disable is set.

Patch #1 and #2 are the preparation of patch #3.

Yafang Shao (3):
  mm: change the return type of out_of_memory()
  mm, memcg: introduce a new helper task_in_memcg_oom_set()
  memcg oom: bail out from the charge path if no victim found

 include/linux/memcontrol.h | 30 ++++++++++++++++++
 include/linux/oom.h        |  9 +++++-
 include/linux/sched.h      |  1 +
 mm/memcontrol.c            | 63 ++++++++++++++++++++------------------
 mm/oom_kill.c              | 36 +++++++++++++++++-----
 mm/page_alloc.c            |  3 +-
 6 files changed, 104 insertions(+), 38 deletions(-)

-- 
2.18.2



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

end of thread, other threads:[~2020-04-20 11:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-18 15:13 [PATCH 0/3] memcg oom: bail out from the charge path if no victim found Yafang Shao
2020-04-18 15:13 ` [PATCH 1/3] mm: change the return type of out_of_memory() Yafang Shao
2020-04-18 15:13 ` [PATCH 2/3] mm, memcg: introduce a new helper task_in_memcg_oom_set() Yafang Shao
2020-04-18 15:13 ` [PATCH 3/3] memcg oom: bail out from the charge path if no victim found Yafang Shao
2020-04-20  8:13   ` Michal Hocko
2020-04-20  8:52     ` Yafang Shao
2020-04-20  9:14       ` Michal Hocko
2020-04-20  9:58         ` Yafang Shao
2020-04-20 10:31           ` Michal Hocko
2020-04-20 10:51             ` Yafang Shao
2020-04-20 11:10               ` Michal Hocko

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).