[Devel] [PATCH rh7 2/2] mm/memcontrol: try to free all memcg during offline.
Andrey Ryabinin
aryabinin at virtuozzo.com
Mon Apr 23 16:00:46 MSK 2018
Currently we don't reclaim memory on memcg offlining.
kmem in memcg pins cgroup indefinitely which don't allow
us to reuse cgroup's id. Since cgroups id count is limited
to ~65K we may exhaust all possible ids.
Try to free all memcg memory during offline. This should
allow us to destroy cgroup almost immedieatly and reuse id.
https://jira.sw.ru/browse/PSBM-83628
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
mm/memcontrol.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d68650ad7a53..590851f6c1d3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6146,6 +6146,19 @@ static void mem_cgroup_invalidate_reclaim_iterators(struct mem_cgroup *memcg)
mem_cgroup_iter_invalidate(root_mem_cgroup);
}
+static void mem_cgroup_free_all(struct mem_cgroup *memcg)
+{
+ int nr_retries = 5;
+
+ lru_add_drain_all();
+
+ while (nr_retries && page_counter_read(&memcg->memory))
+ if (!try_to_free_mem_cgroup_pages(memcg, -1UL, GFP_KERNEL, 0))
+ nr_retries--;
+
+ lru_add_drain();
+}
+
static void mem_cgroup_css_offline(struct cgroup *cont)
{
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
@@ -6175,6 +6188,7 @@ static void mem_cgroup_css_offline(struct cgroup *cont)
rcu_read_lock();
}
rcu_read_unlock();
+ mem_cgroup_free_all(memcg);
mem_cgroup_reparent_charges(memcg);
/*
--
2.16.1
More information about the Devel
mailing list