• K
    memcg: use for_each_mem_cgroup · 7d74b06f
    KAMEZAWA Hiroyuki 提交于
    In memory cgroup management, we sometimes have to walk through
    subhierarchy of cgroup to gather informaiton, or lock something, etc.
    
    Now, to do that, mem_cgroup_walk_tree() function is provided.  It calls
    given callback function per cgroup found.  But the bad thing is that it
    has to pass a fixed style function and argument, "void*" and it adds much
    type casting to memcontrol.c.
    
    To make the code clean, this patch replaces walk_tree() with
    
      for_each_mem_cgroup_tree(iter, root)
    
    An iterator style call.  The good point is that iterator call doesn't have
    to assume what kind of function is called under it.  A bad point is that
    it may cause reference-count leak if a caller use "break" from the loop by
    mistake.
    
    I think the benefit is larger.  The modified code seems straigtforward and
    easy to read because we don't have misterious callbacks and pointer cast.
    Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Balbir Singh <balbir@in.ibm.com>
    Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    7d74b06f
memcontrol.c 122.6 KB