From: Zhou Guanghui zhouguanghui1@huawei.com
ascend inclusion category: feature bugzilla: NA CVE: NA
------------------------------------------------------------------
Normally, pages can not be allocated from CDM node(explicit allocation requests from kernel or user process MPOL_BIND policy which has CDM nodes).
This situation may happen. Within the limit bytes range of the memcg, the CDM nodes have a large amount of free memory, and other nodes have no available free memory. Then, the kernel or user process can not get required memory resources normally.
For example: size of CMD : A mbytes size of non CMD : B mbytes limit mbytes of memcg : C mbytes. A,B < C < (A + B). If app(user app and OS service app) used up non CMD memory, but a large amount of CDM memory is available. Since OS service app can't get pages from CDM node, the allocating of pages should be failed. This is not what we expect. We hope that the memcg can be used to restrict the memory used by some user apps to ensure that certain memory is available for system services.
Therefore, the CDM memory does not need to be charged in the memcg. The total size of CDM is already a limit.
Signed-off-by: Zhou Guanghui zhouguanghui1@huawei.com Reviewed-by: Ding Tianhong dingtianhong@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- mm/memcontrol.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a63bfd73da9a1..1342b9540476d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2696,10 +2696,15 @@ int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
memcg = get_mem_cgroup_from_current(); if (!mem_cgroup_is_root(memcg)) { + if (is_cdm_node(page_to_nid(page))) + goto out; + ret = __memcg_kmem_charge_memcg(page, gfp, order, memcg); if (!ret) __SetPageKmemcg(page); } + +out: css_put(&memcg->css); return ret; } @@ -6016,6 +6021,12 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, if (!memcg) memcg = get_mem_cgroup_from_mm(mm);
+ if (!mem_cgroup_is_root(memcg) && is_cdm_node(page_to_nid(page))) { + css_put(&memcg->css); + memcg = NULL; + goto out; + } + ret = try_charge(memcg, gfp_mask, nr_pages);
css_put(&memcg->css);