Commit 94c749a3 authored by Liu Shixin's avatar Liu Shixin Committed by Zheng Zengkai
Browse files

mm/dynamic_hugetlb: use mem_cgroup_force_empty to reclaim pages

hulk inclusion
category: bugfix
bugzilla: 46904 https://gitee.com/openeuler/kernel/issues/I4Y0XO



--------------------------------

When all processes in the memory cgroup are finished, some memory may still be
occupied such as file cache. Use mem_cgroup_force_empty to reclaim these pages
that charged in the memory cgroup before merging all pages.

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent c3aad494
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1258,6 +1258,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
+6 −0
Original line number Diff line number Diff line
@@ -849,6 +849,12 @@ int hugetlb_pool_destroy(struct cgroup *cgrp)
	if (!hpool || hpool->attach_memcg != memcg)
		return 0;

	/*
	 * Even if no process exists in the memory cgroup, some pages may still
	 * be occupied. Release these pages before merging them.
	 */
	mem_cgroup_force_empty(hpool->attach_memcg);

	ret = hugetlb_pool_merge_all_pages(hpool);
	if (ret)
		return -ENOMEM;
+1 −1
Original line number Diff line number Diff line
@@ -3407,7 +3407,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;