[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1559887659-23121-1-git-send-email-yang.shi@linux.alibaba.com>
Date: Fri, 7 Jun 2019 14:07:35 +0800
From: Yang Shi <yang.shi@...ux.alibaba.com>
To: ktkhai@...tuozzo.com, kirill.shutemov@...ux.intel.com,
hannes@...xchg.org, mhocko@...e.com, hughd@...gle.com,
shakeelb@...gle.com, rientjes@...gle.com, akpm@...ux-foundation.org
Cc: yang.shi@...ux.alibaba.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [v2 PATCH 0/4] Make deferred split shrinker memcg aware
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.
And, move deleting THP from deferred split queue in page free before
memcg uncharge so that the page's memcg information is available.
Reuse the second tail page's deferred_list for per memcg list since the
same THP can't be on multiple deferred split queues.
Remove THP specific destructor since it is not used anymore with memcg
aware THP shrinker (Please see the commit log of patch 3/4 for the details).
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.
Changelog:
v2: * Adopted the suggestion from Krill Shutemov to extract deferred split
fields into a struct to reduce code duplication (patch 1/4). With this
change, the lines of change is shrunk down to 198 from 278.
* Removed memcg_deferred_list. Use deferred_list for both global and memcg.
With the code deduplication, it doesn't make too much sense to keep it.
Kirill Tkhai also suggested so.
* Fixed typo for SHRINKER_NONSLAB.
Yang Shi (4):
mm: thp: extract split_queue_* into a struct
mm: thp: make deferred split shrinker memcg aware
mm: thp: remove THP destructor
mm: shrinker: make shrinker not depend on memcg kmem
include/linux/huge_mm.h | 15 +++++++++++
include/linux/memcontrol.h | 4 +++
include/linux/mm.h | 3 ---
include/linux/mm_types.h | 1 +
include/linux/mmzone.h | 12 ++++++---
include/linux/shrinker.h | 3 +--
mm/huge_memory.c | 99 ++++++++++++++++++++++++++++++++++++++++++++------------------------
mm/memcontrol.c | 19 +++++++++++++
mm/page_alloc.c | 11 ++++----
mm/swap.c | 4 +++
mm/vmscan.c | 27 +++++--------------
11 files changed, 129 insertions(+), 69 deletions(-)
Powered by blists - more mailing lists