All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: mhocko@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com,
	akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH] mm, memcg: show memcg min setting in oom messages
Date: Wed, 20 Nov 2019 03:53:05 -0500	[thread overview]
Message-ID: <1574239985-1916-1-git-send-email-laoar.shao@gmail.com> (raw)

A task running in a memcg may OOM because of the memory.min settings of his
slibing and parent. If this happens, the current oom messages can't show
why file page cache can't be reclaimed. So it is better to show the memcg
min settings.
Let's take an example.
      bar    bar/memory.max = 1200M memory.min=800M
     /  \
   barA barB barA/memory.min = 800M memory.current=1G (file page cache)
             barB/memory.min = 0 (process in this memcg is allocating page)

The process will do memcg reclaim if the bar/memory.max is reached. Once
the barA/memory.min is reached it will stop reclaiming file page caches in
barA, and if there is no reclaimable pages in bar and bar/barB it will
enter memcg OOM then.
After this pacch, bellow messages will be show then (only includeing the
relevant messages here). The lines begin with '#' are newly added info (the
'#' symbol is not in the original messages).
	memory: usage 1228800kB, limit 1228800kB, failcnt 18337
	...
	# Memory cgroup min setting:
	# /bar: min 819200KB emin 0KB
	# /bar/barA: min 819200KB emin 819200KB
	# /bar/barB: min 0KB emin 0KB
	...
	Memory cgroup stats for /bar:
	anon 418328576
	file 835756032
	...
	unevictable 0
	...
	oom-kill:constraint=CONSTRAINT_MEMCG..oom_memcg=/bar,task_memcg=/bar/barB

With the new added information, we can find the memory.min in bar/barA is
reached and the processes in bar/barB can't reclaim file page cache from
bar/barA any more. While without this new added information we don't know
why the file page cache in bar can't be reclaimed.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 mm/memcontrol.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1c4c08b..97fdd93 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1519,16 +1519,27 @@ void mem_cgroup_print_oom_context(struct mem_cgroup *memcg, struct task_struct *
  */
 void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)
 {
+	struct mem_cgroup *iter;
 	char *buf;
 
 	pr_info("memory: usage %llukB, limit %llukB, failcnt %lu\n",
 		K((u64)page_counter_read(&memcg->memory)),
 		K((u64)memcg->memory.max), memcg->memory.failcnt);
-	if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+	if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
 		pr_info("swap: usage %llukB, limit %llukB, failcnt %lu\n",
 			K((u64)page_counter_read(&memcg->swap)),
 			K((u64)memcg->swap.max), memcg->swap.failcnt);
-	else {
+
+		pr_info("Memory cgroup min setting:\n");
+		for_each_mem_cgroup_tree(iter, memcg) {
+			pr_cont_cgroup_path(iter->css.cgroup);
+			pr_cont(":");
+
+			pr_cont(" min %lluKB emin %lluKB\n",
+				K((u64)iter->memory.min),
+				K((u64)iter->memory.emin));
+		}
+	} else {
 		pr_info("memory+swap: usage %llukB, limit %llukB, failcnt %lu\n",
 			K((u64)page_counter_read(&memcg->memsw)),
 			K((u64)memcg->memsw.max), memcg->memsw.failcnt);
-- 
1.8.3.1



             reply	other threads:[~2019-11-20  8:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20  8:53 Yafang Shao [this message]
2019-11-20 10:21 ` [PATCH] mm, memcg: show memcg min setting in oom messages Michal Hocko
2019-11-20 10:53   ` Yafang Shao
2019-11-20 11:40     ` Michal Hocko
2019-11-20 12:23       ` Yafang Shao
2019-11-22 10:28         ` Michal Hocko
2019-11-23  5:52           ` Yafang Shao
2019-11-25  8:20             ` Michal Hocko
2019-11-25  9:12               ` Yafang Shao
2019-11-25  9:27                 ` 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=1574239985-1916-1-git-send-email-laoar.shao@gmail.com \
    --to=laoar.shao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=vdavydov.dev@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.