• Y
    mm: thp: extract split_queue_* into a struct · c9acf2bd
    Yang Shi 提交于
    commit 364c1eebe453f06f0c1e837eb155a5725c9cd272 upstream
    
    Patch series "Make deferred split shrinker memcg aware", v6.
    
    Currently THP deferred split shrinker is not memcg aware, this may cause
    premature OOM with some configuration.  For example the below test would
    run into premature OOM easily:
    
    $ cgcreate -g memory:thp
    $ echo 4G > /sys/fs/cgroup/memory/thp/memory/limit_in_bytes
    $ cgexec -g memory:thp transhuge-stress 4000
    
    transhuge-stress comes from kernel selftest.
    
    It is easy to hit OOM, but there are still a lot THP on the deferred
    split queue, memcg direct reclaim can't touch them since the deferred split
    shrinker is not memcg aware.
    
    Convert deferred split shrinker memcg aware by introducing per memcg
    deferred split queue.  The THP should be on either per node or per memcg
    deferred split queue if it belongs to a memcg.  When the page is
    immigrated to the other memcg, it will be immigrated to the target
    memcg's deferred split queue too.
    
    Reuse the second tail page's deferred_list for per memcg list since the
    same THP can't be on multiple deferred split queues.
    
    Make deferred split shrinker not depend on memcg kmem since it is not
    slab.  It doesn't make sense to not shrink THP even though memcg kmem is
    disabled.
    
    With the above change the test demonstrated above doesn't trigger OOM
    even though with cgroup.memory=nokmem.
    
    This patch (of 4):
    
    Put split_queue, split_queue_lock and split_queue_len into a struct in
    order to reduce code duplication when we convert deferred_split to memcg
    aware in the later patches.
    
    Link: http://lkml.kernel.org/r/1565144277-36240-2-git-send-email-yang.shi@linux.alibaba.comSigned-off-by: NYang Shi <yang.shi@linux.alibaba.com>
    Suggested-by: N"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
    Acked-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Reviewed-by: NKirill Tkhai <ktkhai@virtuozzo.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Shakeel Butt <shakeelb@google.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Qian Cai <cai@lca.pw>
    Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    Reviewed-by: NXunlei Pang <xlpang@linux.alibaba.com>
    c9acf2bd
page_alloc.c 224.0 KB