hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8S9BY CVE: NA
--------------------------------
Before restore pool, call mem_cgroup_force_empty to release pages.
Signed-off-by: Liu Shixin liushixin2@huawei.com --- include/linux/memcontrol.h | 2 ++ mm/dynamic_pool.c | 6 ++++++ mm/memcontrol.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 72323733d95c..649fbb5c1adc 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1236,6 +1236,8 @@ static inline bool memcg_has_children(struct mem_cgroup *memcg) return ret; }
+int mem_cgroup_force_empty(struct mem_cgroup *memcg); + #else /* CONFIG_MEMCG */
#define MEM_CGROUP_ID_SHIFT 0 diff --git a/mm/dynamic_pool.c b/mm/dynamic_pool.c index 51f4d0cd04f8..a1f9adbbae7e 100644 --- a/mm/dynamic_pool.c +++ b/mm/dynamic_pool.c @@ -430,6 +430,12 @@ int dynamic_pool_destroy(struct cgroup *cgrp, bool *clear_css_online) /* A offline dpool is not allowed for allocation */ dpool->online = false;
+ /* + * Even if no process exists in the memory cgroup, some pages may + * still be occupied. Release these pages before restore pool. + */ + mem_cgroup_force_empty(dpool->memcg); + BUG_ON(!dpool->ops->restore_pool); ret = dpool->ops->restore_pool(dpool); if (ret) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b81533d9cb4c..9dd5d97d97d0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3729,7 +3729,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, * * Caller is responsible for holding css reference for memcg. */ -static int mem_cgroup_force_empty(struct mem_cgroup *memcg) +int mem_cgroup_force_empty(struct mem_cgroup *memcg) { int nr_retries = MAX_RECLAIM_RETRIES;