LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: <linux-mm@kvack.org>
Cc: <linux-kernel@vger.kernel.org>, <kernel-team@fb.com>,
	Roman Gushchin <guro@fb.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.com>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Tejun Heo <tj@kernel.org>
Subject: [PATCH v3 2/2] mm: ignore memory.min of abandoned memory cgroups
Date: Thu, 3 May 2018 12:43:58 +0100	[thread overview]
Message-ID: <20180503114358.7952-2-guro@fb.com> (raw)
In-Reply-To: <20180503114358.7952-1-guro@fb.com>

If a cgroup has no associated tasks, invoking the OOM killer
won't help release any memory, so respecting the memory.min
can lead to an infinite OOM loop or system stall.

Let's ignore memory.min of unpopulated cgroups.

Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
---
 include/linux/memcontrol.h | 10 ++++++++++
 mm/vmscan.c                |  6 +++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 3b65d092614f..7d8472022aae 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -374,6 +374,11 @@ static inline void mem_cgroup_put(struct mem_cgroup *memcg)
 	css_put(&memcg->css);
 }
 
+static inline bool mem_cgroup_is_populated(struct mem_cgroup *memcg)
+{
+	return cgroup_is_populated(memcg->css.cgroup);
+}
+
 #define mem_cgroup_from_counter(counter, member)	\
 	container_of(counter, struct mem_cgroup, member)
 
@@ -835,6 +840,11 @@ static inline void mem_cgroup_put(struct mem_cgroup *memcg)
 {
 }
 
+static inline bool mem_cgroup_is_populated(struct mem_cgroup *memcg)
+{
+	return false;
+}
+
 static inline struct mem_cgroup *
 mem_cgroup_iter(struct mem_cgroup *root,
 		struct mem_cgroup *prev,
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 50055d72f294..5e2047e04770 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2549,8 +2549,12 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 				/*
 				 * Hard protection.
 				 * If there is no reclaimable memory, OOM.
+				 * Abandoned cgroups are losing protection,
+				 * because OOM killer won't release any memory.
 				 */
-				continue;
+				if (mem_cgroup_is_populated(memcg))
+					continue;
+				break;
 			case MEMCG_PROT_LOW:
 				/*
 				 * Soft protection.
-- 
2.14.3

  reply	other threads:[~2018-05-03 11:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 11:43 [PATCH v3 1/2] mm: introduce memory.min Roman Gushchin
2018-05-03 11:43 ` Roman Gushchin [this message]
2018-05-03 17:38   ` [PATCH v3 2/2] mm: ignore memory.min of abandoned memory cgroups Johannes Weiner
2018-05-09 18:07     ` Roman Gushchin
2018-05-09 22:38       ` Andrew Morton
2018-05-10 13:08         ` Roman Gushchin
2018-05-10 13:30 ` [PATCH v3 1/2] mm: introduce memory.min Michal Hocko
2018-05-10 14:04   ` Roman Gushchin

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=20180503114358.7952-2-guro@fb.com \
    --to=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=tj@kernel.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH v3 2/2] mm: ignore memory.min of abandoned memory cgroups' \
    /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

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