• Hirokazu Takahashi's avatar
    memcg: simplify force_empty and move_lists · 9b3c0a07
    Hirokazu Takahashi authored
    As for force_empty, though this may not be the main topic here,
    mem_cgroup_force_empty_list() can be implemented simpler.  It is possible to
    make the function just call mem_cgroup_uncharge_page() instead of releasing
    page_cgroups by itself.  The tip is to call get_page() before invoking
    mem_cgroup_uncharge_page(), so the page won't be released during this
    function.
    
    Kamezawa-san points out that by the time mem_cgroup_uncharge_page() uncharges,
    the page might have been reassigned to an lru of a different mem_cgroup, and
    now be emptied from that; but Hugh claims that's okay, the end state is the
    same as when it hasn't gone to another list.
    
    And once force_empty stops taking lock_page_cgroup within mz->lru_lock,
    mem_cgroup_move_lists() can be simplified to take mz->lru_lock directly while
    holding page_cgroup lock (but still has to use try_lock_page_cgroup).
    Signed-off-by: default avatarHirokazu Takahashi <taka@valinux.co.jp>
    Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
    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>
    9b3c0a07
memcontrol.c 27.2 KB