[PATCH] mm: ignore memory.min of abandoned memory cgroups

From: Roman Gushchin
Date: Tue Apr 24 2018 - 09:44:14 EST


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@xxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
Cc: Tejun Heo <tj@xxxxxxxxxx>
---
mm/vmscan.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 0a42ab1ce42b..e563d67de787 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2549,8 +2549,11 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
/*
* Hard protection.
* If there is no reclaimable memory, OOM.
+ * Abandoned cgroups are loosing protection,
+ * because OOM killer won't release any memory.
*/
- continue;
+ if (cgroup_is_populated(memcg->css.cgroup))
+ continue;
case MEMCG_PROT_LOW:
/*
* Soft protection.
--
2.14.3