All of lore.kernel.org
 help / color / mirror / Atom feed
* [v3 PATCH 0/4] Make deferred split shrinker memcg aware
@ 2019-06-12 21:56 Yang Shi
  2019-06-12 21:56 ` [v3 PATCH 1/4] mm: thp: extract split_queue_* into a struct Yang Shi
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Yang Shi @ 2019-06-12 21:56 UTC (permalink / raw)
  To: ktkhai, kirill.shutemov, hannes, mhocko, hughd, shakeelb, rientjes, akpm
  Cc: yang.shi, linux-mm, linux-kernel


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.


Changelog:
v3: * Adopted the suggestion from Kirill Shutemov to move mem_cgroup_uncharge()
      out of __page_cache_release() in order to handle THP free properly. 
    * Adjusted the sequence of the patches per Kirill Shutemov. Dropped the
      patch 3/4 in v2.
    * Moved enqueuing THP onto "to" memcg deferred split queue after
      page->mem_cgroup is changed in memcg account move per Kirill Tkhai.
 
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: move mem_cgroup_uncharge out of __page_cache_release()
      mm: shrinker: make shrinker not depend on memcg kmem
      mm: thp: make deferred split shrinker memcg aware

 include/linux/huge_mm.h    |  9 ++++++++
 include/linux/memcontrol.h |  4 ++++
 include/linux/mm_types.h   |  1 +
 include/linux/mmzone.h     | 12 ++++++++---
 include/linux/shrinker.h   |  3 +--
 mm/huge_memory.c           | 80 +++++++++++++++++++++++++++++++++++++++++++++-----------------------
 mm/memcontrol.c            | 24 +++++++++++++++++++++
 mm/page_alloc.c            |  9 +++++---
 mm/swap.c                  |  2 +-
 mm/vmscan.c                | 27 ++++++-----------------
 10 files changed, 114 insertions(+), 57 deletions(-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-06-25 22:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 21:56 [v3 PATCH 0/4] Make deferred split shrinker memcg aware Yang Shi
2019-06-12 21:56 ` [v3 PATCH 1/4] mm: thp: extract split_queue_* into a struct Yang Shi
2019-06-12 21:56 ` [v3 PATCH 2/4] mm: move mem_cgroup_uncharge out of __page_cache_release() Yang Shi
2019-06-13 11:39   ` Kirill A. Shutemov
2019-06-13 17:13     ` Yang Shi
2019-06-24 16:54       ` Yang Shi
2019-06-25  9:35         ` Kirill A. Shutemov
2019-06-25 15:49           ` Yang Shi
2019-06-12 21:56 ` [v3 PATCH 3/4] mm: shrinker: make shrinker not depend on memcg kmem Yang Shi
2019-06-25 22:14   ` Andrew Morton
2019-06-25 22:30     ` Yang Shi
2019-06-12 21:56 ` [v3 PATCH 4/4] mm: thp: make deferred split shrinker memcg aware Yang Shi
2019-06-25 22:00   ` Andrew Morton
2019-06-25 22:33     ` Yang Shi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.