• Daisuke Nishimura's avatar
    memcg: fix hierarchical reclaim · c268e994
    Daisuke Nishimura authored
    If root_mem has no children, last_scaned_child is set to root_mem itself.
    But after some children added to root_mem, mem_cgroup_get_next_node can
    mem_cgroup_put the root_mem although root_mem has not been mem_cgroup_get.
    
    This patch fixes this behavior by:
    
    - Set last_scanned_child to NULL if root_mem has no children or DFS
      search has returned to root_mem itself(root_mem is not a "child" of
      root_mem).  Make mem_cgroup_get_first_node return root_mem in this case.
       There are no mem_cgroup_get/put for root_mem.
    
    - Rename mem_cgroup_get_next_node to __mem_cgroup_get_next_node, and
      mem_cgroup_get_first_node to mem_cgroup_get_next_node.  Make
      mem_cgroup_hierarchical_reclaim call only new mem_cgroup_get_next_node.
    Signed-off-by: default avatarDaisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
    Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Pavel Emelyanov <xemul@openvz.org>
    Cc: Li Zefan <lizf@cn.fujitsu.com>
    Cc: Paul Menage <menage@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    c268e994
memcontrol.c 56.1 KB