内存cgroup---CGroup中参数由来篇

内存中cgroup:

发现memory cgroup中mem.usage_in_bytes是通过下面这个数值得到的:

 val = page_counter_read(&memcg->memory);

  然后计数的增加在函数:mm/page_counter.c文件中的:page_counter_charge函数,

mem_cgroup_try_charge-->

                                                                     -----> try_charge--->page_counter_charge(memcg->memory)

mem_cgroup_try_charge_skmem -->

soft_limit_excess(struct memcgroup)

 446 static unsigned long soft_limit_excess(struct mem_cgroup *memcg)
 447 {
 448     unsigned long nr_pages = page_counter_read(&memcg->memory);
 449     unsigned long soft_limit = READ_ONCE(memcg->soft_limit);
 450     unsigned long excess = 0;
 451 
 452     if (nr_pages > soft_limit)
 453         excess = nr_pages - soft_limit;
 454 
 455     return excess;
 456 }
 457 

PATH1)   do_try_to_free_pages---->shrink_zones----->

                                                                                  mem_cgroup_soft_limit_reclaim ---> mem_cgroup_soft_reclaim-->mem_cgroup_shrink_node

PATH2)   kswapd_init----->kswaped---->balance_bgdat---->

 

其中PATH1)有这么几条路到达:try_to_free_pages    try_to_free_mem_cgroup_pages  shrink_all_memory

try_to_free_mem_cgroup_pages(mm/memcontrol.c) 在try_charge/force_empty/memory_max_write......等等条件的时候就会触发

 

posted @ 2017-10-30 23:33  honpey  阅读(1147)  评论(0编辑  收藏  举报