linux/Documentation/admin-guide/mm
Usama Arif dafff3f4c8 mm: split underused THPs
This is an attempt to mitigate the issue of running out of memory when THP
is always enabled.  During runtime whenever a THP is being faulted in
(__do_huge_pmd_anonymous_page) or collapsed by khugepaged
(collapse_huge_page), the THP is added to _deferred_list.  Whenever memory
reclaim happens in linux, the kernel runs the deferred_split shrinker
which goes through the _deferred_list.

If the folio was partially mapped, the shrinker attempts to split it.  If
the folio is not partially mapped, the shrinker checks if the THP was
underused, i.e.  how many of the base 4K pages of the entire THP were
zero-filled.  If this number goes above a certain threshold (decided by
/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none), the
shrinker will attempt to split that THP.  Then at remap time, the pages
that were zero-filled are mapped to the shared zeropage, hence saving
memory.

Link: https://lkml.kernel.org/r/20240830100438.3623486-6-usamaarif642@gmail.com
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
Suggested-by: Rik van Riel <riel@surriel.com>
Co-authored-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Alexander Zhu <alexlzhu@fb.com>
Cc: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kairui Song <ryncsn@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nico Pache <npache@redhat.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Shuang Zhai <zhais@google.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Shuang Zhai <szhai2@cs.rochester.edu>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-09-09 16:39:04 -07:00
..
damon Docs/damon: use damonitor GitHub organization instead of awslabs 2024-09-09 16:39:00 -07:00
cma_debugfs.rst mm/cma_debug: show complete cma name in debugfs directories 2022-09-11 20:25:50 -07:00
concepts.rst docs/admin-guide/mm: remove useless markup 2023-02-02 10:18:05 -07:00
hugetlbpage.rst docs: hugetlbpage.rst: add hugetlb migration description 2024-04-25 20:56:06 -07:00
idle_page_tracking.rst - Daniel Verkamp has contributed a memfd series ("mm/memfd: add 2023-02-23 17:09:35 -08:00
index.rst docs/admin-guide/mm: correct typo 'quired' to 'queried' 2024-07-03 16:22:36 -06:00
ksm.rst Docs: typos/spelling 2024-05-02 10:02:29 -06:00
memory-hotplug.rst The number of commits for documentation is not huge this time around, but 2023-11-01 17:11:41 -10:00
multigen_lru.rst mm: multi-gen LRU: admin guide 2022-09-26 19:46:10 -07:00
nommu-mmap.rst docs: move nommu-mmap.txt to admin-guide and rename to ReST 2020-06-26 11:33:35 -06:00
numa_memory_policy.rst mm/mempolicy: introduce MPOL_WEIGHTED_INTERLEAVE for weighted interleaving 2024-02-22 10:24:46 -08:00
numaperf.rst - Daniel Verkamp has contributed a memfd series ("mm/memfd: add 2023-02-23 17:09:35 -08:00
pagemap.rst kpageflags: detect isolated KPF_THP folios 2024-07-12 15:52:21 -07:00
shrinker_debugfs.rst docs/admin-guide/mm: remove useless markup 2023-02-02 10:18:05 -07:00
soft-dirty.rst docs/admin-guide/mm: remove useless markup 2023-02-02 10:18:05 -07:00
swap_numa.rst docs/admin-guide/mm: remove useless markup 2023-02-02 10:18:05 -07:00
transhuge.rst mm: split underused THPs 2024-09-09 16:39:04 -07:00
userfaultfd.rst userfaultfd: UFFDIO_MOVE uABI 2023-12-29 11:58:24 -08:00
zswap.rst mm: zswap: remove same_filled module params 2024-05-05 17:53:38 -07:00