提交 eb773093 编写于 作者: Z Zhou Guanghui 提交者: Yang Yingliang

memcg/ascend: Support not account pages of cdm for memcg

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: NZhou Guanghui <zhouguanghui1@huawei.com>
Reviewed-by: NDing Tianhong <dingtianhong@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 3dbff8cc
...@@ -2696,10 +2696,15 @@ int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order) ...@@ -2696,10 +2696,15 @@ int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
memcg = get_mem_cgroup_from_current(); memcg = get_mem_cgroup_from_current();
if (!mem_cgroup_is_root(memcg)) { 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); ret = __memcg_kmem_charge_memcg(page, gfp, order, memcg);
if (!ret) if (!ret)
__SetPageKmemcg(page); __SetPageKmemcg(page);
} }
out:
css_put(&memcg->css); css_put(&memcg->css);
return ret; return ret;
} }
...@@ -6016,6 +6021,12 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, ...@@ -6016,6 +6021,12 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
if (!memcg) if (!memcg)
memcg = get_mem_cgroup_from_mm(mm); 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); ret = try_charge(memcg, gfp_mask, nr_pages);
css_put(&memcg->css); css_put(&memcg->css);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册